]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - docs/module-doc/classFileReader.html
Re-added the dot graphs again
[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 Inheritance diagram for FileReader:<p><center><img src="classFileReader__inherit__graph.gif" border="0" usemap="#FileReader__inherit__map" alt="Inheritance graph"></center>
14 <map name="FileReader__inherit__map">
15 <area href="classclassbase.html" shape="rect" coords="12,7,92,34" alt="">
16 </map>
17 <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>
18 <map name="FileReader__coll__map">
19 <area href="classclassbase.html" shape="rect" coords="8,98,88,125" alt="">
20 </map>
21 <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>
22 <tr><td></td></tr>
23 <tr><td colspan=2><br><h2>Public Member Functions</h2></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#a0">FileReader</a> ()</td></tr>
25
26 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Default constructor. </em> <a href="#a0"></a><em><br><br></td></tr>
27 <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>
28
29 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Secondary constructor. </em> <a href="#a1"></a><em><br><br></td></tr>
30 <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>
31
32 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Default destructor. </em> <a href="#a2"></a><em><br><br></td></tr>
33 <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>
34
35 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Used to load a file. </em> <a href="#a3"></a><em><br><br></td></tr>
36 <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>
37
38 <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>
39 <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>
40
41 <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>
42 <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>
43
44 <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>
45 <tr><td colspan=2><br><h2>Private Attributes</h2></td></tr>
46 <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>
47
48 </table>
49 <hr><a name="_details"></a><h2>Detailed Description</h2>
50 Caches a text file into memory and can be used to retrieve lines from it. 
51 <p>
52 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. 
53 <p>
54
55 <p>
56 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>
57 <a name="a0" doxytag="FileReader::FileReader"></a><p>
58 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
59   <tr>
60     <td class="mdRow">
61       <table cellpadding="0" cellspacing="0" border="0">
62         <tr>
63           <td class="md" nowrap valign="top"> FileReader::FileReader </td>
64           <td class="md" valign="top">(&nbsp;</td>
65           <td class="mdname1" valign="top" nowrap>          </td>
66           <td class="md" valign="top">&nbsp;)&nbsp;</td>
67           <td class="md" nowrap></td>
68         </tr>
69
70       </table>
71     </td>
72   </tr>
73 </table>
74 <table cellspacing=5 cellpadding=0 border=0>
75   <tr>
76     <td>
77       &nbsp;
78     </td>
79     <td>
80
81 <p>
82 Default constructor. 
83 <p>
84 This method does not load any file into memory, you must use the LoadFile method after constructing the class this way.
85 <p>
86 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>.
87 <p>
88 <div class="fragment"><pre>01024 {
89 01025 }
90 </pre></div>    </td>
91   </tr>
92 </table>
93 <a name="a1" doxytag="FileReader::FileReader"></a><p>
94 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
95   <tr>
96     <td class="mdRow">
97       <table cellpadding="0" cellspacing="0" border="0">
98         <tr>
99           <td class="md" nowrap valign="top"> FileReader::FileReader </td>
100           <td class="md" valign="top">(&nbsp;</td>
101           <td class="md" nowrap valign="top">std::string&nbsp;</td>
102           <td class="mdname1" valign="top" nowrap> <em>filename</em>          </td>
103           <td class="md" valign="top">&nbsp;)&nbsp;</td>
104           <td class="md" nowrap></td>
105         </tr>
106
107       </table>
108     </td>
109   </tr>
110 </table>
111 <table cellspacing=5 cellpadding=0 border=0>
112   <tr>
113     <td>
114       &nbsp;
115     </td>
116     <td>
117
118 <p>
119 Secondary constructor. 
120 <p>
121 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.
122 <p>
123 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>.
124 <p>
125 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>.
126 <p>
127 <div class="fragment"><pre>01017 {
128 01018         <a class="code" href="modules_8h.html#a31">file_cache</a> c;
129 01019         readfile(c,filename.c_str());
130 01020         this-&gt;<a class="code" href="classFileReader.html#r0">fc</a> = c;
131 01021 }
132 </pre></div>    </td>
133   </tr>
134 </table>
135 <a name="a2" doxytag="FileReader::~FileReader"></a><p>
136 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
137   <tr>
138     <td class="mdRow">
139       <table cellpadding="0" cellspacing="0" border="0">
140         <tr>
141           <td class="md" nowrap valign="top"> FileReader::~<a class="el" href="classFileReader.html">FileReader</a> </td>
142           <td class="md" valign="top">(&nbsp;</td>
143           <td class="mdname1" valign="top" nowrap>          </td>
144           <td class="md" valign="top">&nbsp;)&nbsp;</td>
145           <td class="md" nowrap></td>
146         </tr>
147
148       </table>
149     </td>
150   </tr>
151 </table>
152 <table cellspacing=5 cellpadding=0 border=0>
153   <tr>
154     <td>
155       &nbsp;
156     </td>
157     <td>
158
159 <p>
160 Default destructor. 
161 <p>
162 This deletes the memory allocated to the file.
163 <p>
164 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>.
165 <p>
166 <div class="fragment"><pre>01036 {
167 01037 }
168 </pre></div>    </td>
169   </tr>
170 </table>
171 <hr><h2>Member Function Documentation</h2>
172 <a name="a4" doxytag="FileReader::Exists"></a><p>
173 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
174   <tr>
175     <td class="mdRow">
176       <table cellpadding="0" cellspacing="0" border="0">
177         <tr>
178           <td class="md" nowrap valign="top"> bool FileReader::Exists </td>
179           <td class="md" valign="top">(&nbsp;</td>
180           <td class="mdname1" valign="top" nowrap>          </td>
181           <td class="md" valign="top">&nbsp;)&nbsp;</td>
182           <td class="md" nowrap></td>
183         </tr>
184
185       </table>
186     </td>
187   </tr>
188 </table>
189 <table cellspacing=5 cellpadding=0 border=0>
190   <tr>
191     <td>
192       &nbsp;
193     </td>
194     <td>
195
196 <p>
197 Returns true if the file exists This function will return false if the file could not be opened. 
198 <p>
199
200 <p>
201 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>.
202 <p>
203 References <a class="el" href="modules_8h-source.html#l01238">fc</a>.
204 <p>
205 <div class="fragment"><pre>01040 {
206 01041         <span class="keywordflow">if</span> (<a class="code" href="classFileReader.html#r0">fc</a>.size() == 0)
207 01042         {
208 01043                 <span class="keywordflow">return</span>(<span class="keyword">false</span>);
209 01044         }
210 01045         <span class="keywordflow">else</span>
211 01046         {
212 01047                 <span class="keywordflow">return</span>(<span class="keyword">true</span>);
213 01048         }
214 01049 }
215 </pre></div>    </td>
216   </tr>
217 </table>
218 <a name="a6" doxytag="FileReader::FileSize"></a><p>
219 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
220   <tr>
221     <td class="mdRow">
222       <table cellpadding="0" cellspacing="0" border="0">
223         <tr>
224           <td class="md" nowrap valign="top"> int FileReader::FileSize </td>
225           <td class="md" valign="top">(&nbsp;</td>
226           <td class="mdname1" valign="top" nowrap>          </td>
227           <td class="md" valign="top">&nbsp;)&nbsp;</td>
228           <td class="md" nowrap></td>
229         </tr>
230
231       </table>
232     </td>
233   </tr>
234 </table>
235 <table cellspacing=5 cellpadding=0 border=0>
236   <tr>
237     <td>
238       &nbsp;
239     </td>
240     <td>
241
242 <p>
243 Returns the size of the file in lines. 
244 <p>
245 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.
246 <p>
247 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>.
248 <p>
249 References <a class="el" href="modules_8h-source.html#l01238">fc</a>.
250 <p>
251 <div class="fragment"><pre>01059 {
252 01060         <span class="keywordflow">return</span> <a class="code" href="classFileReader.html#r0">fc</a>.size();
253 01061 }
254 </pre></div>    </td>
255   </tr>
256 </table>
257 <a name="a5" doxytag="FileReader::GetLine"></a><p>
258 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
259   <tr>
260     <td class="mdRow">
261       <table cellpadding="0" cellspacing="0" border="0">
262         <tr>
263           <td class="md" nowrap valign="top"> std::string FileReader::GetLine </td>
264           <td class="md" valign="top">(&nbsp;</td>
265           <td class="md" nowrap valign="top">int&nbsp;</td>
266           <td class="mdname1" valign="top" nowrap> <em>x</em>          </td>
267           <td class="md" valign="top">&nbsp;)&nbsp;</td>
268           <td class="md" nowrap></td>
269         </tr>
270
271       </table>
272     </td>
273   </tr>
274 </table>
275 <table cellspacing=5 cellpadding=0 border=0>
276   <tr>
277     <td>
278       &nbsp;
279     </td>
280     <td>
281
282 <p>
283 Retrieve one line from the file. 
284 <p>
285 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.
286 <p>
287 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>.
288 <p>
289 References <a class="el" href="modules_8h-source.html#l01238">fc</a>.
290 <p>
291 <div class="fragment"><pre>01052 {
292 01053         <span class="keywordflow">if</span> ((x&lt;0) || (x&gt;<a class="code" href="classFileReader.html#r0">fc</a>.size()))
293 01054                 <span class="keywordflow">return</span> <span class="stringliteral">""</span>;
294 01055         <span class="keywordflow">return</span> <a class="code" href="classFileReader.html#r0">fc</a>[x];
295 01056 }
296 </pre></div>    </td>
297   </tr>
298 </table>
299 <a name="a3" doxytag="FileReader::LoadFile"></a><p>
300 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
301   <tr>
302     <td class="mdRow">
303       <table cellpadding="0" cellspacing="0" border="0">
304         <tr>
305           <td class="md" nowrap valign="top"> void FileReader::LoadFile </td>
306           <td class="md" valign="top">(&nbsp;</td>
307           <td class="md" nowrap valign="top">std::string&nbsp;</td>
308           <td class="mdname1" valign="top" nowrap> <em>filename</em>          </td>
309           <td class="md" valign="top">&nbsp;)&nbsp;</td>
310           <td class="md" nowrap></td>
311         </tr>
312
313       </table>
314     </td>
315   </tr>
316 </table>
317 <table cellspacing=5 cellpadding=0 border=0>
318   <tr>
319     <td>
320       &nbsp;
321     </td>
322     <td>
323
324 <p>
325 Used to load a file. 
326 <p>
327 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.
328 <p>
329 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>.
330 <p>
331 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>.
332 <p>
333 <div class="fragment"><pre>01028 {
334 01029         <a class="code" href="modules_8h.html#a31">file_cache</a> c;
335 01030         readfile(c,filename.c_str());
336 01031         this-&gt;<a class="code" href="classFileReader.html#r0">fc</a> = c;
337 01032 }
338 </pre></div>    </td>
339   </tr>
340 </table>
341 <hr><h2>Member Data Documentation</h2>
342 <a name="r0" doxytag="FileReader::fc"></a><p>
343 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
344   <tr>
345     <td class="mdRow">
346       <table cellpadding="0" cellspacing="0" border="0">
347         <tr>
348           <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>
349       </table>
350     </td>
351   </tr>
352 </table>
353 <table cellspacing=5 cellpadding=0 border=0>
354   <tr>
355     <td>
356       &nbsp;
357     </td>
358     <td>
359
360 <p>
361
362 <p>
363 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>.
364 <p>
365 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>
366   </tr>
367 </table>
368 <hr>The documentation for this class was generated from the following files:<ul>
369 <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>
370 <hr size="1"><address style="align: right;"><small>Generated on Fri May 13 01:59:43 2005 for InspIRCd by
371 <a href="http://www.doxygen.org/index.html">
372 <img src="doxygen.png" alt="doxygen" align="middle" border=0 > 
373 </a>1.3.3 </small></address>
374 </body>
375 </html>