]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - docs/module-doc/classFileReader.html
54dfd90e27597994789e367b340087c9b12129bb
[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>FileReader class Reference</title>
4 <link href="inspircd.css" rel="stylesheet" type="text/css">
5 </head><body>
6 <!-- Generated by Doxygen 1.3-rc3 -->
7 <center>
8 <a class="qindex" href="main.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; </center>
9 <hr><h1>FileReader Class Reference</h1>Caches a text file into memory and can be used to retrieve lines from it. 
10 <a href="#_details">More...</a>
11 <p>
12 <code>#include &lt;<a class="el" href="modules_8h-source.html">modules.h</a>&gt;</code>
13 <p>
14 Inheritance diagram for FileReader:<p><center><img src="classFileReader__inherit__graph.gif" border="0" usemap="#FileReader__inherit__map" alt="Inheritance graph"></center>
15 <map name="FileReader__inherit__map">
16 <area href="classclassbase.html" shape="rect" coords="11,16,77,37" alt="">
17 </map>
18 <center><font size="2">[<a target="top" href="graph_legend.html">legend</a>]</font></center>Collaboration diagram for FileReader:<p><center><img src="classFileReader__coll__graph.gif" border="0" usemap="#FileReader__coll__map" alt="Collaboration graph"></center>
19 <map name="FileReader__coll__map">
20 <area href="classclassbase.html" shape="rect" coords="7,107,73,128" alt="">
21 </map>
22 <center><font size="2">[<a target="top" href="graph_legend.html">legend</a>]</font></center><a href="classFileReader-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0>
23 <tr><td></td></tr>
24 <tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr>
25 <tr><td nowrap align=right valign=top>&nbsp;</td><td valign=bottom><a class="el" href="classFileReader.html#a0">FileReader</a> ()</td></tr>
26 <tr><td>&nbsp;</td><td><font size=-1><em>Default constructor.</em> <a href="#a0"></a><em></em></font><br><br></td></tr>
27 <tr><td nowrap align=right valign=top>&nbsp;</td><td valign=bottom><a class="el" href="classFileReader.html#a1">FileReader</a> (std::string filename)</td></tr>
28 <tr><td>&nbsp;</td><td><font size=-1><em>Secondary constructor.</em> <a href="#a1"></a><em></em></font><br><br></td></tr>
29 <tr><td nowrap align=right valign=top>&nbsp;</td><td valign=bottom><a class="el" href="classFileReader.html#a2">~FileReader</a> ()</td></tr>
30 <tr><td>&nbsp;</td><td><font size=-1><em>Default destructor.</em> <a href="#a2"></a><em></em></font><br><br></td></tr>
31 <tr><td nowrap align=right valign=top>void&nbsp;</td><td valign=bottom><a class="el" href="classFileReader.html#a3">LoadFile</a> (std::string filename)</td></tr>
32 <tr><td>&nbsp;</td><td><font size=-1><em>Used to load a file.</em> <a href="#a3"></a><em></em></font><br><br></td></tr>
33 <tr><td nowrap align=right valign=top>bool&nbsp;</td><td valign=bottom><a class="el" href="classFileReader.html#a4">Exists</a> ()</td></tr>
34 <tr><td>&nbsp;</td><td><font size=-1><em>Retrieve one line from the file.</em> <a href="#a4"></a><em></em></font><br><br></td></tr>
35 <tr><td nowrap align=right valign=top>std::string&nbsp;</td><td valign=bottom><a class="el" href="classFileReader.html#a5">GetLine</a> (int x)</td></tr>
36 <tr><td nowrap align=right valign=top>int&nbsp;</td><td valign=bottom><a class="el" href="classFileReader.html#a6">FileSize</a> ()</td></tr>
37 <tr><td>&nbsp;</td><td><font size=-1><em>Returns the size of the file in lines.</em> <a href="#a6"></a><em></em></font><br><br></td></tr>
38 <tr><td colspan=2><br><h2>Private Attributes</h2></td></tr>
39 <tr><td nowrap align=right valign=top><a class="el" href="modules_8h.html#a10">file_cache</a>&nbsp;</td><td valign=bottom><a class="el" href="classFileReader.html#o0">fc</a></td></tr>
40 </table>
41 <hr><a name="_details"></a><h2>Detailed Description</h2>
42 Caches a text file into memory and can be used to retrieve lines from it.
43 <p>
44 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. 
45 <p>
46
47 <p>
48 Definition at line <a class="el" href="modules_8h-source.html#l00493">493</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.<hr><h2>Constructor &amp; Destructor Documentation</h2>
49 <a name="a0" doxytag="FileReader::FileReader"></a><p>
50 <table width="100%" cellpadding="2" cellspacing="0" border="0">
51   <tr>
52     <td class="md">
53       <table cellpadding="0" cellspacing="0" border="0">
54         <tr>
55           <td class="md" nowrap valign="top"> FileReader::FileReader </td>
56           <td class="md" valign="top">(&nbsp;</td>
57           <td class="mdname1" valign="top" nowrap>&nbsp;          </td>
58           <td class="md" valign="top">)&nbsp;</td>
59           <td class="md" nowrap></td>
60         </tr>
61
62       </table>
63     </td>
64   </tr>
65 </table>
66 <table cellspacing=5 cellpadding=0 border=0>
67   <tr>
68     <td>
69       &nbsp;
70     </td>
71     <td>
72
73 <p>
74 Default constructor.
75 <p>
76 This method does not load any file into memory, you must use the LoadFile method after constructing the class this way.
77 <p>
78 Definition at line <a class="el" href="modules_8cpp-source.html#l00336">336</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
79 <p>
80 <div class="fragment"><pre>00337 {
81 00338 }
82 </pre></div>    </td>
83   </tr>
84 </table>
85 <a name="a1" doxytag="FileReader::FileReader"></a><p>
86 <table width="100%" cellpadding="2" cellspacing="0" border="0">
87   <tr>
88     <td class="md">
89       <table cellpadding="0" cellspacing="0" border="0">
90         <tr>
91           <td class="md" nowrap valign="top"> FileReader::FileReader </td>
92           <td class="md" valign="top">(&nbsp;</td>
93           <td class="md" nowrap valign="top">std::string&nbsp;</td>
94           <td class="mdname1" valign="top" nowrap>&nbsp; <em>filename</em>          </td>
95           <td class="md" valign="top">)&nbsp;</td>
96           <td class="md" nowrap></td>
97         </tr>
98
99       </table>
100     </td>
101   </tr>
102 </table>
103 <table cellspacing=5 cellpadding=0 border=0>
104   <tr>
105     <td>
106       &nbsp;
107     </td>
108     <td>
109
110 <p>
111 Secondary constructor.
112 <p>
113 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.
114 <p>
115 Definition at line <a class="el" href="modules_8cpp-source.html#l00329">329</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
116 <p>
117 References <a class="el" href="modules_8h-source.html#l00495">fc</a>, and <a class="el" href="modules_8h-source.html#l00029">file_cache</a>.
118 <p>
119 <div class="fragment"><pre>00330 {
120 00331         <a class="code" href="modules_8h.html#a10">file_cache</a> c;
121 00332         readfile(c,filename.c_str());
122 00333         this-&gt;<a class="code" href="classFileReader.html#o0">fc</a> = c;
123 00334 }
124 </pre></div>    </td>
125   </tr>
126 </table>
127 <a name="a2" doxytag="FileReader::~FileReader"></a><p>
128 <table width="100%" cellpadding="2" cellspacing="0" border="0">
129   <tr>
130     <td class="md">
131       <table cellpadding="0" cellspacing="0" border="0">
132         <tr>
133           <td class="md" nowrap valign="top"> FileReader::~FileReader </td>
134           <td class="md" valign="top">(&nbsp;</td>
135           <td class="mdname1" valign="top" nowrap>&nbsp;          </td>
136           <td class="md" valign="top">)&nbsp;</td>
137           <td class="md" nowrap></td>
138         </tr>
139
140       </table>
141     </td>
142   </tr>
143 </table>
144 <table cellspacing=5 cellpadding=0 border=0>
145   <tr>
146     <td>
147       &nbsp;
148     </td>
149     <td>
150
151 <p>
152 Default destructor.
153 <p>
154 This deletes the memory allocated to the file.
155 <p>
156 Definition at line <a class="el" href="modules_8cpp-source.html#l00348">348</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
157 <p>
158 <div class="fragment"><pre>00349 {
159 00350 }
160 </pre></div>    </td>
161   </tr>
162 </table>
163 <hr><h2>Member Function Documentation</h2>
164 <a name="a4" doxytag="FileReader::Exists"></a><p>
165 <table width="100%" cellpadding="2" cellspacing="0" border="0">
166   <tr>
167     <td class="md">
168       <table cellpadding="0" cellspacing="0" border="0">
169         <tr>
170           <td class="md" nowrap valign="top"> bool FileReader::Exists </td>
171           <td class="md" valign="top">(&nbsp;</td>
172           <td class="mdname1" valign="top" nowrap>&nbsp;          </td>
173           <td class="md" valign="top">)&nbsp;</td>
174           <td class="md" nowrap></td>
175         </tr>
176
177       </table>
178     </td>
179   </tr>
180 </table>
181 <table cellspacing=5 cellpadding=0 border=0>
182   <tr>
183     <td>
184       &nbsp;
185     </td>
186     <td>
187
188 <p>
189 Retrieve one line from the file.
190 <p>
191 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.
192 <p>
193 Definition at line <a class="el" href="modules_8cpp-source.html#l00352">352</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
194 <p>
195 References <a class="el" href="modules_8h-source.html#l00495">fc</a>.
196 <p>
197 <div class="fragment"><pre>00353 {
198 00354         <span class="keywordflow">if</span> (<a class="code" href="classFileReader.html#o0">fc</a>.size() == 0)
199 00355         {
200 00356                 <span class="keywordflow">return</span>(false);
201 00357         }
202 00358         <span class="keywordflow">else</span>
203 00359         {
204 00360                 <span class="keywordflow">return</span>(true);
205 00361         }
206 00362 }
207 </pre></div>    </td>
208   </tr>
209 </table>
210 <a name="a6" doxytag="FileReader::FileSize"></a><p>
211 <table width="100%" cellpadding="2" cellspacing="0" border="0">
212   <tr>
213     <td class="md">
214       <table cellpadding="0" cellspacing="0" border="0">
215         <tr>
216           <td class="md" nowrap valign="top"> int FileReader::FileSize </td>
217           <td class="md" valign="top">(&nbsp;</td>
218           <td class="mdname1" valign="top" nowrap>&nbsp;          </td>
219           <td class="md" valign="top">)&nbsp;</td>
220           <td class="md" nowrap></td>
221         </tr>
222
223       </table>
224     </td>
225   </tr>
226 </table>
227 <table cellspacing=5 cellpadding=0 border=0>
228   <tr>
229     <td>
230       &nbsp;
231     </td>
232     <td>
233
234 <p>
235 Returns the size of the file in lines.
236 <p>
237 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.
238 <p>
239 Definition at line <a class="el" href="modules_8cpp-source.html#l00371">371</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
240 <p>
241 References <a class="el" href="modules_8h-source.html#l00495">fc</a>.
242 <p>
243 <div class="fragment"><pre>00372 {
244 00373         <span class="keywordflow">return</span> <a class="code" href="classFileReader.html#o0">fc</a>.size();
245 00374 }
246 </pre></div>    </td>
247   </tr>
248 </table>
249 <a name="a5" doxytag="FileReader::GetLine"></a><p>
250 <table width="100%" cellpadding="2" cellspacing="0" border="0">
251   <tr>
252     <td class="md">
253       <table cellpadding="0" cellspacing="0" border="0">
254         <tr>
255           <td class="md" nowrap valign="top"> std::string FileReader::GetLine </td>
256           <td class="md" valign="top">(&nbsp;</td>
257           <td class="md" nowrap valign="top">int&nbsp;</td>
258           <td class="mdname1" valign="top" nowrap>&nbsp; <em>x</em>          </td>
259           <td class="md" valign="top">)&nbsp;</td>
260           <td class="md" nowrap></td>
261         </tr>
262
263       </table>
264     </td>
265   </tr>
266 </table>
267 <table cellspacing=5 cellpadding=0 border=0>
268   <tr>
269     <td>
270       &nbsp;
271     </td>
272     <td>
273
274 <p>
275
276 <p>
277 Definition at line <a class="el" href="modules_8cpp-source.html#l00364">364</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
278 <p>
279 References <a class="el" href="modules_8h-source.html#l00495">fc</a>.
280 <p>
281 <div class="fragment"><pre>00365 {
282 00366         <span class="keywordflow">if</span> ((x&lt;0) || (x&gt;<a class="code" href="classFileReader.html#o0">fc</a>.size()))
283 00367                 <span class="keywordflow">return</span> <span class="stringliteral">""</span>;
284 00368         <span class="keywordflow">return</span> <a class="code" href="classFileReader.html#o0">fc</a>[x];
285 00369 }
286 </pre></div>    </td>
287   </tr>
288 </table>
289 <a name="a3" doxytag="FileReader::LoadFile"></a><p>
290 <table width="100%" cellpadding="2" cellspacing="0" border="0">
291   <tr>
292     <td class="md">
293       <table cellpadding="0" cellspacing="0" border="0">
294         <tr>
295           <td class="md" nowrap valign="top"> void FileReader::LoadFile </td>
296           <td class="md" valign="top">(&nbsp;</td>
297           <td class="md" nowrap valign="top">std::string&nbsp;</td>
298           <td class="mdname1" valign="top" nowrap>&nbsp; <em>filename</em>          </td>
299           <td class="md" valign="top">)&nbsp;</td>
300           <td class="md" nowrap></td>
301         </tr>
302
303       </table>
304     </td>
305   </tr>
306 </table>
307 <table cellspacing=5 cellpadding=0 border=0>
308   <tr>
309     <td>
310       &nbsp;
311     </td>
312     <td>
313
314 <p>
315 Used to load a file.
316 <p>
317 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.
318 <p>
319 Definition at line <a class="el" href="modules_8cpp-source.html#l00340">340</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
320 <p>
321 References <a class="el" href="modules_8h-source.html#l00495">fc</a>, and <a class="el" href="modules_8h-source.html#l00029">file_cache</a>.
322 <p>
323 <div class="fragment"><pre>00341 {
324 00342         <a class="code" href="modules_8h.html#a10">file_cache</a> c;
325 00343         readfile(c,filename.c_str());
326 00344         this-&gt;<a class="code" href="classFileReader.html#o0">fc</a> = c;
327 00345 }
328 </pre></div>    </td>
329   </tr>
330 </table>
331 <hr><h2>Member Data Documentation</h2>
332 <a name="o0" doxytag="FileReader::fc"></a><p>
333 <table width="100%" cellpadding="2" cellspacing="0" border="0">
334   <tr>
335     <td class="md">
336       <table cellpadding="0" cellspacing="0" border="0">
337         <tr>
338           <td class="md" nowrap valign="top"> <a class="el" href="modules_8h.html#a10">file_cache</a> FileReader::fc<code> [private]</code>
339       </table>
340     </td>
341   </tr>
342 </table>
343 <table cellspacing=5 cellpadding=0 border=0>
344   <tr>
345     <td>
346       &nbsp;
347     </td>
348     <td>
349
350 <p>
351
352 <p>
353 Definition at line <a class="el" href="modules_8h-source.html#l00495">495</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
354 <p>
355 Referenced by <a class="el" href="modules_8cpp-source.html#l00352">Exists()</a>, <a class="el" href="modules_8cpp-source.html#l00329">FileReader()</a>, <a class="el" href="modules_8cpp-source.html#l00371">FileSize()</a>, <a class="el" href="modules_8cpp-source.html#l00364">GetLine()</a>, and <a class="el" href="modules_8cpp-source.html#l00340">LoadFile()</a>.    </td>
356   </tr>
357 </table>
358 <hr>The documentation for this class was generated from the following files:<ul>
359 <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>
360 <hr><address style="align: right;"><small>Generated on Tue Apr 6 21:13:59 2004 for InspIRCd by
361 <a href="http://www.doxygen.org/index.html">
362 <img src="doxygen.png" alt="doxygen" align="middle" border=0 
363 width=110 height=53></a>1.3-rc3 </small></address>
364 </body>
365 </html>