]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - docs/module-doc/classFileReader.html
Added docs for new smaller memory footprint classes
[user/henk/code/inspircd.git] / docs / module-doc / classFileReader.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3 <title>InspIRCd: FileReader class Reference</title>
4 <link href="inspircd.css" rel="stylesheet" type="text/css">
5 </head><body>
6 <!-- Generated by Doxygen 1.3.3 -->
7 <div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Compound&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Compound&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a></div>
8 <h1>FileReader Class Reference</h1>Caches a text file into memory and can be used to retrieve lines from it.  
9 <a href="#_details">More...</a>
10 <p>
11 <code>#include &lt;<a class="el" href="modules_8h-source.html">modules.h</a>&gt;</code>
12 <p>
13 Inherits <a class="el" href="classclassbase.html">classbase</a>.
14 <p>
15 <a href="classFileReader-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0>
16 <tr><td></td></tr>
17 <tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr>
18 <tr><td class="memItemLeft" nowrap align=right valign=top>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classFileReader.html#a0">FileReader</a> ()</td></tr>
19
20 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Default constructor. </em> <a href="#a0"></a><em><br><br></td></tr>
21 <tr><td class="memItemLeft" nowrap align=right valign=top>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classFileReader.html#a1">FileReader</a> (std::string filename)</td></tr>
22
23 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Secondary constructor. </em> <a href="#a1"></a><em><br><br></td></tr>
24 <tr><td class="memItemLeft" nowrap align=right valign=top>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classFileReader.html#a2">~FileReader</a> ()</td></tr>
25
26 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Default destructor. </em> <a href="#a2"></a><em><br><br></td></tr>
27 <tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classFileReader.html#a3">LoadFile</a> (std::string filename)</td></tr>
28
29 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Used to load a file. </em> <a href="#a3"></a><em><br><br></td></tr>
30 <tr><td class="memItemLeft" nowrap align=right valign=top>bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classFileReader.html#a4">Exists</a> ()</td></tr>
31
32 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns true if the file exists This function will return false if the file could not be opened. </em> <a href="#a4"></a><em><br><br></td></tr>
33 <tr><td class="memItemLeft" nowrap align=right valign=top>std::string&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classFileReader.html#a5">GetLine</a> (int x)</td></tr>
34
35 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Retrieve one line from the file. </em> <a href="#a5"></a><em><br><br></td></tr>
36 <tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classFileReader.html#a6">FileSize</a> ()</td></tr>
37
38 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns the size of the file in lines. </em> <a href="#a6"></a><em><br><br></td></tr>
39 <tr><td colspan=2><br><h2>Private Attributes</h2></td></tr>
40 <tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="modules_8h.html#a31">file_cache</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classFileReader.html#r0">fc</a></td></tr>
41
42 </table>
43 <hr><a name="_details"></a><h2>Detailed Description</h2>
44 Caches a text file into memory and can be used to retrieve lines from it. 
45 <p>
46 This class contains methods for read-only manipulation of a text file in memory. Either use the constructor type with one parameter to load a file into memory at construction, or use the LoadFile method to load a file. 
47 <p>
48
49 <p>
50 Definition at line <a class="el" href="modules_8h-source.html#l01236">1236</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.<hr><h2>Constructor &amp; Destructor Documentation</h2>
51 <a name="a0" doxytag="FileReader::FileReader"></a><p>
52 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
53   <tr>
54     <td class="mdRow">
55       <table cellpadding="0" cellspacing="0" border="0">
56         <tr>
57           <td class="md" nowrap valign="top"> FileReader::FileReader </td>
58           <td class="md" valign="top">(&nbsp;</td>
59           <td class="mdname1" valign="top" nowrap>          </td>
60           <td class="md" valign="top">&nbsp;)&nbsp;</td>
61           <td class="md" nowrap></td>
62         </tr>
63
64       </table>
65     </td>
66   </tr>
67 </table>
68 <table cellspacing=5 cellpadding=0 border=0>
69   <tr>
70     <td>
71       &nbsp;
72     </td>
73     <td>
74
75 <p>
76 Default constructor. 
77 <p>
78 This method does not load any file into memory, you must use the LoadFile method after constructing the class this way.
79 <p>
80 Definition at line <a class="el" href="modules_8cpp-source.html#l01023">1023</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
81 <p>
82 <div class="fragment"><pre>01024 {
83 01025 }
84 </pre></div>    </td>
85   </tr>
86 </table>
87 <a name="a1" doxytag="FileReader::FileReader"></a><p>
88 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
89   <tr>
90     <td class="mdRow">
91       <table cellpadding="0" cellspacing="0" border="0">
92         <tr>
93           <td class="md" nowrap valign="top"> FileReader::FileReader </td>
94           <td class="md" valign="top">(&nbsp;</td>
95           <td class="md" nowrap valign="top">std::string&nbsp;</td>
96           <td class="mdname1" valign="top" nowrap> <em>filename</em>          </td>
97           <td class="md" valign="top">&nbsp;)&nbsp;</td>
98           <td class="md" nowrap></td>
99         </tr>
100
101       </table>
102     </td>
103   </tr>
104 </table>
105 <table cellspacing=5 cellpadding=0 border=0>
106   <tr>
107     <td>
108       &nbsp;
109     </td>
110     <td>
111
112 <p>
113 Secondary constructor. 
114 <p>
115 This method initialises the class with a file loaded into it ready for GetLine and and other methods to be called. If the file could not be loaded, <a class="el" href="classFileReader.html#a6">FileReader::FileSize</a> returns 0.
116 <p>
117 Definition at line <a class="el" href="modules_8cpp-source.html#l01016">1016</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
118 <p>
119 References <a class="el" href="modules_8h-source.html#l01238">fc</a>, and <a class="el" href="modules_8h-source.html#l00067">file_cache</a>.
120 <p>
121 <div class="fragment"><pre>01017 {
122 01018         <a class="code" href="modules_8h.html#a31">file_cache</a> c;
123 01019         readfile(c,filename.c_str());
124 01020         this-&gt;<a class="code" href="classFileReader.html#r0">fc</a> = c;
125 01021 }
126 </pre></div>    </td>
127   </tr>
128 </table>
129 <a name="a2" doxytag="FileReader::~FileReader"></a><p>
130 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
131   <tr>
132     <td class="mdRow">
133       <table cellpadding="0" cellspacing="0" border="0">
134         <tr>
135           <td class="md" nowrap valign="top"> FileReader::~<a class="el" href="classFileReader.html">FileReader</a> </td>
136           <td class="md" valign="top">(&nbsp;</td>
137           <td class="mdname1" valign="top" nowrap>          </td>
138           <td class="md" valign="top">&nbsp;)&nbsp;</td>
139           <td class="md" nowrap></td>
140         </tr>
141
142       </table>
143     </td>
144   </tr>
145 </table>
146 <table cellspacing=5 cellpadding=0 border=0>
147   <tr>
148     <td>
149       &nbsp;
150     </td>
151     <td>
152
153 <p>
154 Default destructor. 
155 <p>
156 This deletes the memory allocated to the file.
157 <p>
158 Definition at line <a class="el" href="modules_8cpp-source.html#l01035">1035</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
159 <p>
160 <div class="fragment"><pre>01036 {
161 01037 }
162 </pre></div>    </td>
163   </tr>
164 </table>
165 <hr><h2>Member Function Documentation</h2>
166 <a name="a4" doxytag="FileReader::Exists"></a><p>
167 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
168   <tr>
169     <td class="mdRow">
170       <table cellpadding="0" cellspacing="0" border="0">
171         <tr>
172           <td class="md" nowrap valign="top"> bool FileReader::Exists </td>
173           <td class="md" valign="top">(&nbsp;</td>
174           <td class="mdname1" valign="top" nowrap>          </td>
175           <td class="md" valign="top">&nbsp;)&nbsp;</td>
176           <td class="md" nowrap></td>
177         </tr>
178
179       </table>
180     </td>
181   </tr>
182 </table>
183 <table cellspacing=5 cellpadding=0 border=0>
184   <tr>
185     <td>
186       &nbsp;
187     </td>
188     <td>
189
190 <p>
191 Returns true if the file exists This function will return false if the file could not be opened. 
192 <p>
193
194 <p>
195 Definition at line <a class="el" href="modules_8cpp-source.html#l01039">1039</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
196 <p>
197 References <a class="el" href="modules_8h-source.html#l01238">fc</a>.
198 <p>
199 <div class="fragment"><pre>01040 {
200 01041         <span class="keywordflow">if</span> (<a class="code" href="classFileReader.html#r0">fc</a>.size() == 0)
201 01042         {
202 01043                 <span class="keywordflow">return</span>(<span class="keyword">false</span>);
203 01044         }
204 01045         <span class="keywordflow">else</span>
205 01046         {
206 01047                 <span class="keywordflow">return</span>(<span class="keyword">true</span>);
207 01048         }
208 01049 }
209 </pre></div>    </td>
210   </tr>
211 </table>
212 <a name="a6" doxytag="FileReader::FileSize"></a><p>
213 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
214   <tr>
215     <td class="mdRow">
216       <table cellpadding="0" cellspacing="0" border="0">
217         <tr>
218           <td class="md" nowrap valign="top"> int FileReader::FileSize </td>
219           <td class="md" valign="top">(&nbsp;</td>
220           <td class="mdname1" valign="top" nowrap>          </td>
221           <td class="md" valign="top">&nbsp;)&nbsp;</td>
222           <td class="md" nowrap></td>
223         </tr>
224
225       </table>
226     </td>
227   </tr>
228 </table>
229 <table cellspacing=5 cellpadding=0 border=0>
230   <tr>
231     <td>
232       &nbsp;
233     </td>
234     <td>
235
236 <p>
237 Returns the size of the file in lines. 
238 <p>
239 This method returns the number of lines in the read file. If it is 0, no lines have been read into memory, either because the file is empty or it does not exist, or cannot be opened due to permission problems.
240 <p>
241 Definition at line <a class="el" href="modules_8cpp-source.html#l01058">1058</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
242 <p>
243 References <a class="el" href="modules_8h-source.html#l01238">fc</a>.
244 <p>
245 <div class="fragment"><pre>01059 {
246 01060         <span class="keywordflow">return</span> <a class="code" href="classFileReader.html#r0">fc</a>.size();
247 01061 }
248 </pre></div>    </td>
249   </tr>
250 </table>
251 <a name="a5" doxytag="FileReader::GetLine"></a><p>
252 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
253   <tr>
254     <td class="mdRow">
255       <table cellpadding="0" cellspacing="0" border="0">
256         <tr>
257           <td class="md" nowrap valign="top"> std::string FileReader::GetLine </td>
258           <td class="md" valign="top">(&nbsp;</td>
259           <td class="md" nowrap valign="top">int&nbsp;</td>
260           <td class="mdname1" valign="top" nowrap> <em>x</em>          </td>
261           <td class="md" valign="top">&nbsp;)&nbsp;</td>
262           <td class="md" nowrap></td>
263         </tr>
264
265       </table>
266     </td>
267   </tr>
268 </table>
269 <table cellspacing=5 cellpadding=0 border=0>
270   <tr>
271     <td>
272       &nbsp;
273     </td>
274     <td>
275
276 <p>
277 Retrieve one line from the file. 
278 <p>
279 This method retrieves one line from the text file. If an empty non-NULL string is returned, the index was out of bounds, or the line had no data on it.
280 <p>
281 Definition at line <a class="el" href="modules_8cpp-source.html#l01051">1051</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
282 <p>
283 References <a class="el" href="modules_8h-source.html#l01238">fc</a>.
284 <p>
285 <div class="fragment"><pre>01052 {
286 01053         <span class="keywordflow">if</span> ((x&lt;0) || (x&gt;<a class="code" href="classFileReader.html#r0">fc</a>.size()))
287 01054                 <span class="keywordflow">return</span> <span class="stringliteral">""</span>;
288 01055         <span class="keywordflow">return</span> <a class="code" href="classFileReader.html#r0">fc</a>[x];
289 01056 }
290 </pre></div>    </td>
291   </tr>
292 </table>
293 <a name="a3" doxytag="FileReader::LoadFile"></a><p>
294 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
295   <tr>
296     <td class="mdRow">
297       <table cellpadding="0" cellspacing="0" border="0">
298         <tr>
299           <td class="md" nowrap valign="top"> void FileReader::LoadFile </td>
300           <td class="md" valign="top">(&nbsp;</td>
301           <td class="md" nowrap valign="top">std::string&nbsp;</td>
302           <td class="mdname1" valign="top" nowrap> <em>filename</em>          </td>
303           <td class="md" valign="top">&nbsp;)&nbsp;</td>
304           <td class="md" nowrap></td>
305         </tr>
306
307       </table>
308     </td>
309   </tr>
310 </table>
311 <table cellspacing=5 cellpadding=0 border=0>
312   <tr>
313     <td>
314       &nbsp;
315     </td>
316     <td>
317
318 <p>
319 Used to load a file. 
320 <p>
321 This method loads a file into the class ready for GetLine and and other methods to be called. If the file could not be loaded, <a class="el" href="classFileReader.html#a6">FileReader::FileSize</a> returns 0.
322 <p>
323 Definition at line <a class="el" href="modules_8cpp-source.html#l01027">1027</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
324 <p>
325 References <a class="el" href="modules_8h-source.html#l01238">fc</a>, and <a class="el" href="modules_8h-source.html#l00067">file_cache</a>.
326 <p>
327 <div class="fragment"><pre>01028 {
328 01029         <a class="code" href="modules_8h.html#a31">file_cache</a> c;
329 01030         readfile(c,filename.c_str());
330 01031         this-&gt;<a class="code" href="classFileReader.html#r0">fc</a> = c;
331 01032 }
332 </pre></div>    </td>
333   </tr>
334 </table>
335 <hr><h2>Member Data Documentation</h2>
336 <a name="r0" doxytag="FileReader::fc"></a><p>
337 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
338   <tr>
339     <td class="mdRow">
340       <table cellpadding="0" cellspacing="0" border="0">
341         <tr>
342           <td class="md" nowrap valign="top"> <a class="el" href="modules_8h.html#a31">file_cache</a> <a class="el" href="classFileReader.html#r0">FileReader::fc</a><code> [private]</code>
343       </table>
344     </td>
345   </tr>
346 </table>
347 <table cellspacing=5 cellpadding=0 border=0>
348   <tr>
349     <td>
350       &nbsp;
351     </td>
352     <td>
353
354 <p>
355
356 <p>
357 Definition at line <a class="el" href="modules_8h-source.html#l01238">1238</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
358 <p>
359 Referenced by <a class="el" href="modules_8cpp-source.html#l01039">Exists()</a>, <a class="el" href="modules_8cpp-source.html#l01016">FileReader()</a>, <a class="el" href="modules_8cpp-source.html#l01058">FileSize()</a>, <a class="el" href="modules_8cpp-source.html#l01051">GetLine()</a>, and <a class="el" href="modules_8cpp-source.html#l01027">LoadFile()</a>.    </td>
360   </tr>
361 </table>
362 <hr>The documentation for this class was generated from the following files:<ul>
363 <li><a class="el" href="modules_8h-source.html">modules.h</a><li><a class="el" href="modules_8cpp-source.html">modules.cpp</a></ul>
364 <hr size="1"><address style="align: right;"><small>Generated on Thu May 12 22:59:02 2005 for InspIRCd by
365 <a href="http://www.doxygen.org/index.html">
366 <img src="doxygen.png" alt="doxygen" align="middle" border=0 > 
367 </a>1.3.3 </small></address>
368 </body>
369 </html>