]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - docs/module-doc/classFileReader.html
Documentation update, 09/02/03
[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="doxygen.css" rel="stylesheet" type="text/css">
5 </head><body>
6 <!-- Generated by Doxygen 1.3-rc2 -->
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 <p>Inheritance diagram for FileReader:
15 <p><center><img src="classFileReader.png" usemap="#FileReader_map" border="0" alt=""></center>
16 <map name="FileReader_map">
17 <area href="classclassbase.html" alt="classbase" shape="rect" coords="0,0,74,24">
18 </map>
19 <a href="classFileReader-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0>
20 <tr><td></td></tr>
21 <tr><td colspan=2><br><h2>Public Methods</h2></td></tr>
22 <tr><td nowrap align=right valign=top>&nbsp;</td><td valign=bottom><a class="el" href="classFileReader.html#a0">FileReader</a> ()</td></tr>
23 <tr><td>&nbsp;</td><td><font size=-1><em>Default constructor.</em> <a href="#a0"></a><em></em></font><br><br></td></tr>
24 <tr><td nowrap align=right valign=top>&nbsp;</td><td valign=bottom><a class="el" href="classFileReader.html#a1">FileReader</a> (string filename)</td></tr>
25 <tr><td>&nbsp;</td><td><font size=-1><em>Secondary constructor.</em> <a href="#a1"></a><em></em></font><br><br></td></tr>
26 <tr><td nowrap align=right valign=top>&nbsp;</td><td valign=bottom><a class="el" href="classFileReader.html#a2">~FileReader</a> ()</td></tr>
27 <tr><td>&nbsp;</td><td><font size=-1><em>Default destructor.</em> <a href="#a2"></a><em></em></font><br><br></td></tr>
28 <tr><td nowrap align=right valign=top>void&nbsp;</td><td valign=bottom><a class="el" href="classFileReader.html#a3">LoadFile</a> (string filename)</td></tr>
29 <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>
30 <tr><td nowrap align=right valign=top>string&nbsp;</td><td valign=bottom><a class="el" href="classFileReader.html#a4">GetLine</a> (int x)</td></tr>
31 <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>
32 <tr><td nowrap align=right valign=top>int&nbsp;</td><td valign=bottom><a class="el" href="classFileReader.html#a5">FileSize</a> ()</td></tr>
33 <tr><td>&nbsp;</td><td><font size=-1><em>Returns the size of the file in lines.</em> <a href="#a5"></a><em></em></font><br><br></td></tr>
34 <tr><td colspan=2><br><h2>Private Attributes</h2></td></tr>
35 <tr><td nowrap align=right valign=top><a class="el" href="modules_8h.html#a6">file_cache</a>&nbsp;</td><td valign=bottom><a class="el" href="classFileReader.html#o0">fc</a></td></tr>
36 </table>
37 <hr><a name="_details"></a><h2>Detailed Description</h2>
38 Caches a text file into memory and can be used to retrieve lines from it.
39 <p>
40 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. 
41 <p>
42
43 <p>
44 Definition at line <a class="el" href="modules_8h-source.html#l00263">263</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.<hr><h2>Constructor &amp; Destructor Documentation</h2>
45 <a name="a0" doxytag="FileReader::FileReader"></a><p>
46 <table width="100%" cellpadding="2" cellspacing="0" border="0">
47   <tr>
48     <td class="md">
49       <table cellpadding="0" cellspacing="0" border="0">
50         <tr>
51           <td class="md" nowrap valign="top"> FileReader::FileReader </td>
52           <td class="md" valign="top">(&nbsp;</td>
53           <td class="mdname1" valign="top" nowrap>&nbsp;          </td>
54           <td class="md" valign="top">)&nbsp;</td>
55           <td class="md" nowrap></td>
56         </tr>
57
58       </table>
59     </td>
60   </tr>
61 </table>
62 <table cellspacing=5 cellpadding=0 border=0>
63   <tr>
64     <td>
65       &nbsp;
66     </td>
67     <td>
68
69 <p>
70 Default constructor.
71 <p>
72 This method does not load any file into memory, you must use the LoadFile method after constructing the class this way.
73 <p>
74 Definition at line <a class="el" href="modules_8cpp-source.html#l00192">192</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
75 <p>
76 <div class="fragment"><pre>00193 {
77 00194 }
78 </pre></div>    </td>
79   </tr>
80 </table>
81 <a name="a1" doxytag="FileReader::FileReader"></a><p>
82 <table width="100%" cellpadding="2" cellspacing="0" border="0">
83   <tr>
84     <td class="md">
85       <table cellpadding="0" cellspacing="0" border="0">
86         <tr>
87           <td class="md" nowrap valign="top"> FileReader::FileReader </td>
88           <td class="md" valign="top">(&nbsp;</td>
89           <td class="md" nowrap valign="top">string&nbsp;</td>
90           <td class="mdname1" valign="top" nowrap>&nbsp; <em>filename</em>          </td>
91           <td class="md" valign="top">)&nbsp;</td>
92           <td class="md" nowrap></td>
93         </tr>
94
95       </table>
96     </td>
97   </tr>
98 </table>
99 <table cellspacing=5 cellpadding=0 border=0>
100   <tr>
101     <td>
102       &nbsp;
103     </td>
104     <td>
105
106 <p>
107 Secondary constructor.
108 <p>
109 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#a5">FileReader::FileSize</a> returns 0.
110 <p>
111 Definition at line <a class="el" href="modules_8cpp-source.html#l00185">185</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
112 <p>
113 References <a class="el" href="modules_8h-source.html#l00265">fc</a>, and <a class="el" href="modules_8h-source.html#l00024">file_cache</a>.
114 <p>
115 <div class="fragment"><pre>00186 {
116 00187         <a class="code" href="modules_8h.html#a6">file_cache</a> c;
117 00188         readfile(c,filename.c_str());
118 00189         this-&gt;<a class="code" href="classFileReader.html#o0">fc</a> = c;
119 00190 }
120 </pre></div>    </td>
121   </tr>
122 </table>
123 <a name="a2" doxytag="FileReader::~FileReader"></a><p>
124 <table width="100%" cellpadding="2" cellspacing="0" border="0">
125   <tr>
126     <td class="md">
127       <table cellpadding="0" cellspacing="0" border="0">
128         <tr>
129           <td class="md" nowrap valign="top"> FileReader::~FileReader </td>
130           <td class="md" valign="top">(&nbsp;</td>
131           <td class="mdname1" valign="top" nowrap>&nbsp;          </td>
132           <td class="md" valign="top">)&nbsp;</td>
133           <td class="md" nowrap></td>
134         </tr>
135
136       </table>
137     </td>
138   </tr>
139 </table>
140 <table cellspacing=5 cellpadding=0 border=0>
141   <tr>
142     <td>
143       &nbsp;
144     </td>
145     <td>
146
147 <p>
148 Default destructor.
149 <p>
150 This deletes the memory allocated to the file.
151 <p>
152 Definition at line <a class="el" href="modules_8cpp-source.html#l00203">203</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
153 <p>
154 <div class="fragment"><pre>00204 {
155 00205 }
156 </pre></div>    </td>
157   </tr>
158 </table>
159 <hr><h2>Member Function Documentation</h2>
160 <a name="a5" doxytag="FileReader::FileSize"></a><p>
161 <table width="100%" cellpadding="2" cellspacing="0" border="0">
162   <tr>
163     <td class="md">
164       <table cellpadding="0" cellspacing="0" border="0">
165         <tr>
166           <td class="md" nowrap valign="top"> int FileReader::FileSize </td>
167           <td class="md" valign="top">(&nbsp;</td>
168           <td class="mdname1" valign="top" nowrap>&nbsp;          </td>
169           <td class="md" valign="top">)&nbsp;</td>
170           <td class="md" nowrap></td>
171         </tr>
172
173       </table>
174     </td>
175   </tr>
176 </table>
177 <table cellspacing=5 cellpadding=0 border=0>
178   <tr>
179     <td>
180       &nbsp;
181     </td>
182     <td>
183
184 <p>
185 Returns the size of the file in lines.
186 <p>
187 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.
188 <p>
189 Definition at line <a class="el" href="modules_8cpp-source.html#l00214">214</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
190 <p>
191 References <a class="el" href="modules_8h-source.html#l00265">fc</a>.
192 <p>
193 <div class="fragment"><pre>00215 {
194 00216         <span class="keywordflow">return</span> <a class="code" href="classFileReader.html#o0">fc</a>.size();
195 00217 }
196 </pre></div>    </td>
197   </tr>
198 </table>
199 <a name="a4" doxytag="FileReader::GetLine"></a><p>
200 <table width="100%" cellpadding="2" cellspacing="0" border="0">
201   <tr>
202     <td class="md">
203       <table cellpadding="0" cellspacing="0" border="0">
204         <tr>
205           <td class="md" nowrap valign="top"> string FileReader::GetLine </td>
206           <td class="md" valign="top">(&nbsp;</td>
207           <td class="md" nowrap valign="top">int&nbsp;</td>
208           <td class="mdname1" valign="top" nowrap>&nbsp; <em>x</em>          </td>
209           <td class="md" valign="top">)&nbsp;</td>
210           <td class="md" nowrap></td>
211         </tr>
212
213       </table>
214     </td>
215   </tr>
216 </table>
217 <table cellspacing=5 cellpadding=0 border=0>
218   <tr>
219     <td>
220       &nbsp;
221     </td>
222     <td>
223
224 <p>
225 Retrieve one line from the file.
226 <p>
227 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.
228 <p>
229 Definition at line <a class="el" href="modules_8cpp-source.html#l00207">207</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
230 <p>
231 References <a class="el" href="modules_8h-source.html#l00265">fc</a>.
232 <p>
233 <div class="fragment"><pre>00208 {
234 00209         <span class="keywordflow">if</span> ((x&lt;0) || (x&gt;<a class="code" href="classFileReader.html#o0">fc</a>.size()))
235 00210                 <span class="keywordflow">return</span> <span class="stringliteral">""</span>;
236 00211         <span class="keywordflow">return</span> <a class="code" href="classFileReader.html#o0">fc</a>[x];
237 00212 }
238 </pre></div>    </td>
239   </tr>
240 </table>
241 <a name="a3" doxytag="FileReader::LoadFile"></a><p>
242 <table width="100%" cellpadding="2" cellspacing="0" border="0">
243   <tr>
244     <td class="md">
245       <table cellpadding="0" cellspacing="0" border="0">
246         <tr>
247           <td class="md" nowrap valign="top"> void FileReader::LoadFile </td>
248           <td class="md" valign="top">(&nbsp;</td>
249           <td class="md" nowrap valign="top">string&nbsp;</td>
250           <td class="mdname1" valign="top" nowrap>&nbsp; <em>filename</em>          </td>
251           <td class="md" valign="top">)&nbsp;</td>
252           <td class="md" nowrap></td>
253         </tr>
254
255       </table>
256     </td>
257   </tr>
258 </table>
259 <table cellspacing=5 cellpadding=0 border=0>
260   <tr>
261     <td>
262       &nbsp;
263     </td>
264     <td>
265
266 <p>
267 Used to load a file.
268 <p>
269 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#a5">FileReader::FileSize</a> returns 0.
270 <p>
271 Definition at line <a class="el" href="modules_8cpp-source.html#l00196">196</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
272 <p>
273 References <a class="el" href="modules_8h-source.html#l00265">fc</a>, and <a class="el" href="modules_8h-source.html#l00024">file_cache</a>.
274 <p>
275 <div class="fragment"><pre>00197 {
276 00198         <a class="code" href="modules_8h.html#a6">file_cache</a> c;
277 00199         readfile(c,filename.c_str());
278 00200         this-&gt;<a class="code" href="classFileReader.html#o0">fc</a> = c;
279 00201 }
280 </pre></div>    </td>
281   </tr>
282 </table>
283 <hr><h2>Member Data Documentation</h2>
284 <a name="o0" doxytag="FileReader::fc"></a><p>
285 <table width="100%" cellpadding="2" cellspacing="0" border="0">
286   <tr>
287     <td class="md">
288       <table cellpadding="0" cellspacing="0" border="0">
289         <tr>
290           <td class="md" nowrap valign="top"> <a class="el" href="modules_8h.html#a6">file_cache</a> FileReader::fc<code> [private]</code>
291       </table>
292     </td>
293   </tr>
294 </table>
295 <table cellspacing=5 cellpadding=0 border=0>
296   <tr>
297     <td>
298       &nbsp;
299     </td>
300     <td>
301
302 <p>
303
304 <p>
305 Definition at line <a class="el" href="modules_8h-source.html#l00265">265</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
306 <p>
307 Referenced by <a class="el" href="modules_8cpp-source.html#l00185">FileReader()</a>, <a class="el" href="modules_8cpp-source.html#l00214">FileSize()</a>, <a class="el" href="modules_8cpp-source.html#l00207">GetLine()</a>, and <a class="el" href="modules_8cpp-source.html#l00196">LoadFile()</a>.    </td>
308   </tr>
309 </table>
310 <hr>The documentation for this class was generated from the following files:<ul>
311 <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>
312 <hr><address style="align: right;"><small>Generated on Sun Feb 9 12:48:18 2003 for InspIRCd by
313 <a href="http://www.doxygen.org/index.html">
314 <img src="doxygen.png" alt="doxygen" align="middle" border=0 
315 width=110 height=53></a>1.3-rc2 </small></address>
316 </body>
317 </html>