]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - docs/module-doc/classFileReader.html
Added manpages, extra docs
[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>Returns true if the file exists This function will return false if the file could not be opened.</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>&nbsp;</td><td><font size=-1><em>Retrieve one line from the file.</em> <a href="#a5"></a><em></em></font><br><br></td></tr>
37 <tr><td nowrap align=right valign=top>int&nbsp;</td><td valign=bottom><a class="el" href="classFileReader.html#a6">FileSize</a> ()</td></tr>
38 <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>
39 <tr><td colspan=2><br><h2>Private Attributes</h2></td></tr>
40 <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>
41 </table>
42 <hr><a name="_details"></a><h2>Detailed Description</h2>
43 Caches a text file into memory and can be used to retrieve lines from it.
44 <p>
45 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. 
46 <p>
47
48 <p>
49 Definition at line <a class="el" href="modules_8h-source.html#l00578">578</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.<hr><h2>Constructor &amp; Destructor Documentation</h2>
50 <a name="a0" doxytag="FileReader::FileReader"></a><p>
51 <table width="100%" cellpadding="2" cellspacing="0" border="0">
52   <tr>
53     <td class="md">
54       <table cellpadding="0" cellspacing="0" border="0">
55         <tr>
56           <td class="md" nowrap valign="top"> FileReader::FileReader </td>
57           <td class="md" valign="top">(&nbsp;</td>
58           <td class="mdname1" valign="top" nowrap>&nbsp;          </td>
59           <td class="md" valign="top">)&nbsp;</td>
60           <td class="md" nowrap></td>
61         </tr>
62
63       </table>
64     </td>
65   </tr>
66 </table>
67 <table cellspacing=5 cellpadding=0 border=0>
68   <tr>
69     <td>
70       &nbsp;
71     </td>
72     <td>
73
74 <p>
75 Default constructor.
76 <p>
77 This method does not load any file into memory, you must use the LoadFile method after constructing the class this way.
78 <p>
79 Definition at line <a class="el" href="modules_8cpp-source.html#l00398">398</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
80 <p>
81 <div class="fragment"><pre>00399 {
82 00400 }
83 </pre></div>    </td>
84   </tr>
85 </table>
86 <a name="a1" doxytag="FileReader::FileReader"></a><p>
87 <table width="100%" cellpadding="2" cellspacing="0" border="0">
88   <tr>
89     <td class="md">
90       <table cellpadding="0" cellspacing="0" border="0">
91         <tr>
92           <td class="md" nowrap valign="top"> FileReader::FileReader </td>
93           <td class="md" valign="top">(&nbsp;</td>
94           <td class="md" nowrap valign="top">std::string&nbsp;</td>
95           <td class="mdname1" valign="top" nowrap>&nbsp; <em>filename</em>          </td>
96           <td class="md" valign="top">)&nbsp;</td>
97           <td class="md" nowrap></td>
98         </tr>
99
100       </table>
101     </td>
102   </tr>
103 </table>
104 <table cellspacing=5 cellpadding=0 border=0>
105   <tr>
106     <td>
107       &nbsp;
108     </td>
109     <td>
110
111 <p>
112 Secondary constructor.
113 <p>
114 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.
115 <p>
116 Definition at line <a class="el" href="modules_8cpp-source.html#l00391">391</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
117 <p>
118 References <a class="el" href="modules_8h-source.html#l00580">fc</a>, and <a class="el" href="modules_8h-source.html#l00030">file_cache</a>.
119 <p>
120 <div class="fragment"><pre>00392 {
121 00393         <a class="code" href="modules_8h.html#a10">file_cache</a> c;
122 00394         readfile(c,filename.c_str());
123 00395         this-&gt;<a class="code" href="classFileReader.html#o0">fc</a> = c;
124 00396 }
125 </pre></div>    </td>
126   </tr>
127 </table>
128 <a name="a2" doxytag="FileReader::~FileReader"></a><p>
129 <table width="100%" cellpadding="2" cellspacing="0" border="0">
130   <tr>
131     <td class="md">
132       <table cellpadding="0" cellspacing="0" border="0">
133         <tr>
134           <td class="md" nowrap valign="top"> FileReader::~FileReader </td>
135           <td class="md" valign="top">(&nbsp;</td>
136           <td class="mdname1" valign="top" nowrap>&nbsp;          </td>
137           <td class="md" valign="top">)&nbsp;</td>
138           <td class="md" nowrap></td>
139         </tr>
140
141       </table>
142     </td>
143   </tr>
144 </table>
145 <table cellspacing=5 cellpadding=0 border=0>
146   <tr>
147     <td>
148       &nbsp;
149     </td>
150     <td>
151
152 <p>
153 Default destructor.
154 <p>
155 This deletes the memory allocated to the file.
156 <p>
157 Definition at line <a class="el" href="modules_8cpp-source.html#l00410">410</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
158 <p>
159 <div class="fragment"><pre>00411 {
160 00412 }
161 </pre></div>    </td>
162   </tr>
163 </table>
164 <hr><h2>Member Function Documentation</h2>
165 <a name="a4" doxytag="FileReader::Exists"></a><p>
166 <table width="100%" cellpadding="2" cellspacing="0" border="0">
167   <tr>
168     <td class="md">
169       <table cellpadding="0" cellspacing="0" border="0">
170         <tr>
171           <td class="md" nowrap valign="top"> bool FileReader::Exists </td>
172           <td class="md" valign="top">(&nbsp;</td>
173           <td class="mdname1" valign="top" nowrap>&nbsp;          </td>
174           <td class="md" valign="top">)&nbsp;</td>
175           <td class="md" nowrap></td>
176         </tr>
177
178       </table>
179     </td>
180   </tr>
181 </table>
182 <table cellspacing=5 cellpadding=0 border=0>
183   <tr>
184     <td>
185       &nbsp;
186     </td>
187     <td>
188
189 <p>
190 Returns true if the file exists This function will return false if the file could not be opened.
191 <p>
192
193 <p>
194 Definition at line <a class="el" href="modules_8cpp-source.html#l00414">414</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
195 <p>
196 References <a class="el" href="modules_8h-source.html#l00580">fc</a>.
197 <p>
198 <div class="fragment"><pre>00415 {
199 00416         <span class="keywordflow">if</span> (<a class="code" href="classFileReader.html#o0">fc</a>.size() == 0)
200 00417         {
201 00418                 <span class="keywordflow">return</span>(false);
202 00419         }
203 00420         <span class="keywordflow">else</span>
204 00421         {
205 00422                 <span class="keywordflow">return</span>(true);
206 00423         }
207 00424 }
208 </pre></div>    </td>
209   </tr>
210 </table>
211 <a name="a6" doxytag="FileReader::FileSize"></a><p>
212 <table width="100%" cellpadding="2" cellspacing="0" border="0">
213   <tr>
214     <td class="md">
215       <table cellpadding="0" cellspacing="0" border="0">
216         <tr>
217           <td class="md" nowrap valign="top"> int FileReader::FileSize </td>
218           <td class="md" valign="top">(&nbsp;</td>
219           <td class="mdname1" valign="top" nowrap>&nbsp;          </td>
220           <td class="md" valign="top">)&nbsp;</td>
221           <td class="md" nowrap></td>
222         </tr>
223
224       </table>
225     </td>
226   </tr>
227 </table>
228 <table cellspacing=5 cellpadding=0 border=0>
229   <tr>
230     <td>
231       &nbsp;
232     </td>
233     <td>
234
235 <p>
236 Returns the size of the file in lines.
237 <p>
238 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.
239 <p>
240 Definition at line <a class="el" href="modules_8cpp-source.html#l00433">433</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
241 <p>
242 References <a class="el" href="modules_8h-source.html#l00580">fc</a>.
243 <p>
244 <div class="fragment"><pre>00434 {
245 00435         <span class="keywordflow">return</span> <a class="code" href="classFileReader.html#o0">fc</a>.size();
246 00436 }
247 </pre></div>    </td>
248   </tr>
249 </table>
250 <a name="a5" doxytag="FileReader::GetLine"></a><p>
251 <table width="100%" cellpadding="2" cellspacing="0" border="0">
252   <tr>
253     <td class="md">
254       <table cellpadding="0" cellspacing="0" border="0">
255         <tr>
256           <td class="md" nowrap valign="top"> std::string FileReader::GetLine </td>
257           <td class="md" valign="top">(&nbsp;</td>
258           <td class="md" nowrap valign="top">int&nbsp;</td>
259           <td class="mdname1" valign="top" nowrap>&nbsp; <em>x</em>          </td>
260           <td class="md" valign="top">)&nbsp;</td>
261           <td class="md" nowrap></td>
262         </tr>
263
264       </table>
265     </td>
266   </tr>
267 </table>
268 <table cellspacing=5 cellpadding=0 border=0>
269   <tr>
270     <td>
271       &nbsp;
272     </td>
273     <td>
274
275 <p>
276 Retrieve one line from the file.
277 <p>
278 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.
279 <p>
280 Definition at line <a class="el" href="modules_8cpp-source.html#l00426">426</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
281 <p>
282 References <a class="el" href="modules_8h-source.html#l00580">fc</a>.
283 <p>
284 <div class="fragment"><pre>00427 {
285 00428         <span class="keywordflow">if</span> ((x&lt;0) || (x&gt;<a class="code" href="classFileReader.html#o0">fc</a>.size()))
286 00429                 <span class="keywordflow">return</span> <span class="stringliteral">""</span>;
287 00430         <span class="keywordflow">return</span> <a class="code" href="classFileReader.html#o0">fc</a>[x];
288 00431 }
289 </pre></div>    </td>
290   </tr>
291 </table>
292 <a name="a3" doxytag="FileReader::LoadFile"></a><p>
293 <table width="100%" cellpadding="2" cellspacing="0" border="0">
294   <tr>
295     <td class="md">
296       <table cellpadding="0" cellspacing="0" border="0">
297         <tr>
298           <td class="md" nowrap valign="top"> void FileReader::LoadFile </td>
299           <td class="md" valign="top">(&nbsp;</td>
300           <td class="md" nowrap valign="top">std::string&nbsp;</td>
301           <td class="mdname1" valign="top" nowrap>&nbsp; <em>filename</em>          </td>
302           <td class="md" valign="top">)&nbsp;</td>
303           <td class="md" nowrap></td>
304         </tr>
305
306       </table>
307     </td>
308   </tr>
309 </table>
310 <table cellspacing=5 cellpadding=0 border=0>
311   <tr>
312     <td>
313       &nbsp;
314     </td>
315     <td>
316
317 <p>
318 Used to load a file.
319 <p>
320 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.
321 <p>
322 Definition at line <a class="el" href="modules_8cpp-source.html#l00402">402</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
323 <p>
324 References <a class="el" href="modules_8h-source.html#l00580">fc</a>, and <a class="el" href="modules_8h-source.html#l00030">file_cache</a>.
325 <p>
326 <div class="fragment"><pre>00403 {
327 00404         <a class="code" href="modules_8h.html#a10">file_cache</a> c;
328 00405         readfile(c,filename.c_str());
329 00406         this-&gt;<a class="code" href="classFileReader.html#o0">fc</a> = c;
330 00407 }
331 </pre></div>    </td>
332   </tr>
333 </table>
334 <hr><h2>Member Data Documentation</h2>
335 <a name="o0" doxytag="FileReader::fc"></a><p>
336 <table width="100%" cellpadding="2" cellspacing="0" border="0">
337   <tr>
338     <td class="md">
339       <table cellpadding="0" cellspacing="0" border="0">
340         <tr>
341           <td class="md" nowrap valign="top"> <a class="el" href="modules_8h.html#a10">file_cache</a> FileReader::fc<code> [private]</code>
342       </table>
343     </td>
344   </tr>
345 </table>
346 <table cellspacing=5 cellpadding=0 border=0>
347   <tr>
348     <td>
349       &nbsp;
350     </td>
351     <td>
352
353 <p>
354
355 <p>
356 Definition at line <a class="el" href="modules_8h-source.html#l00580">580</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
357 <p>
358 Referenced by <a class="el" href="modules_8cpp-source.html#l00414">Exists()</a>, <a class="el" href="modules_8cpp-source.html#l00391">FileReader()</a>, <a class="el" href="modules_8cpp-source.html#l00433">FileSize()</a>, <a class="el" href="modules_8cpp-source.html#l00426">GetLine()</a>, and <a class="el" href="modules_8cpp-source.html#l00402">LoadFile()</a>.    </td>
359   </tr>
360 </table>
361 <hr>The documentation for this class was generated from the following files:<ul>
362 <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>
363 <hr><address style="align: right;"><small>Generated on Fri Apr 30 13:23:32 2004 for InspIRCd by
364 <a href="http://www.doxygen.org/index.html">
365 <img src="doxygen.png" alt="doxygen" align="middle" border=0 
366 width=110 height=53></a>1.3-rc3 </small></address>
367 </body>
368 </html>