]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - docs/module-doc/classFileReader.html
b44d63b9be678360c5d357d006b50193c58c96d4
[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="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#l00402">402</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#l00276">276</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
79 <p>
80 <div class="fragment"><pre>00277 {
81 00278 }
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#l00269">269</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#l00404">fc</a>, and <a class="el" href="modules_8h-source.html#l00029">file_cache</a>.
118 <p>
119 <div class="fragment"><pre>00270 {
120 00271         <a class="code" href="modules_8h.html#a10">file_cache</a> c;
121 00272         readfile(c,filename.c_str());
122 00273         this-&gt;<a class="code" href="classFileReader.html#o0">fc</a> = c;
123 00274 }
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#l00288">288</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
157 <p>
158 <div class="fragment"><pre>00289 {
159 00290 }
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#l00292">292</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#l00404">fc</a>.
196 <p>
197 <div class="fragment"><pre>00293 {
198 00294         <span class="keywordflow">if</span> (<a class="code" href="classFileReader.html#o0">fc</a>.size() == 0)
199 00295         {
200 00296                 <span class="keywordflow">return</span>(false);
201 00297         }
202 00298         <span class="keywordflow">else</span>
203 00299         {
204 00300                 <span class="keywordflow">return</span>(true);
205 00301         }
206 00302 }
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#l00311">311</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#l00404">fc</a>.
242 <p>
243 <div class="fragment"><pre>00312 {
244 00313         <span class="keywordflow">return</span> <a class="code" href="classFileReader.html#o0">fc</a>.size();
245 00314 }
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#l00304">304</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#l00404">fc</a>.
280 <p>
281 <div class="fragment"><pre>00305 {
282 00306         <span class="keywordflow">if</span> ((x&lt;0) || (x&gt;<a class="code" href="classFileReader.html#o0">fc</a>.size()))
283 00307                 <span class="keywordflow">return</span> <span class="stringliteral">""</span>;
284 00308         <span class="keywordflow">return</span> <a class="code" href="classFileReader.html#o0">fc</a>[x];
285 00309 }
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#l00280">280</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#l00404">fc</a>, and <a class="el" href="modules_8h-source.html#l00029">file_cache</a>.
322 <p>
323 <div class="fragment"><pre>00281 {
324 00282         <a class="code" href="modules_8h.html#a10">file_cache</a> c;
325 00283         readfile(c,filename.c_str());
326 00284         this-&gt;<a class="code" href="classFileReader.html#o0">fc</a> = c;
327 00285 }
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#l00404">404</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#l00292">Exists()</a>, <a class="el" href="modules_8cpp-source.html#l00269">FileReader()</a>, <a class="el" href="modules_8cpp-source.html#l00311">FileSize()</a>, <a class="el" href="modules_8cpp-source.html#l00304">GetLine()</a>, and <a class="el" href="modules_8cpp-source.html#l00280">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 Sat Apr 3 16:36:14 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>