]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - docs/module-doc/classFileReader.html
Fixed 'fake direction' messages being put out by user->registered = 7 being set too...
[user/henk/code/inspircd.git] / docs / module-doc / classFileReader.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 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.doxygen.css" rel="stylesheet" type="text/css">
5 </head><body>
6 <!-- Generated by Doxygen 1.4.4-20050815 -->
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">Class&nbsp;List</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a></div>
8 <h1>FileReader Class Reference</h1><!-- doxytag: class="FileReader" --><!-- doxytag: inherits="classbase" -->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="11,7,91,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="7,97,87,124" 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#FileReader_28_29">FileReader</a> ()</td></tr>
25
26 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Default constructor.  <a href="#FileReader_28_29"></a><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#FileReader_28std_3A_3Astring_20filename_29">FileReader</a> (<a class="el" href="namespaceirc.html#string">std::string</a> filename)</td></tr>
28
29 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Secondary constructor.  <a href="#FileReader_28std_3A_3Astring_20filename_29"></a><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#_7EFileReader_28_29">~FileReader</a> ()</td></tr>
31
32 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Default destructor.  <a href="#_7EFileReader_28_29"></a><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#LoadFile_28std_3A_3Astring_20filename_29">LoadFile</a> (<a class="el" href="namespaceirc.html#string">std::string</a> filename)</td></tr>
34
35 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Used to load a file.  <a href="#LoadFile_28std_3A_3Astring_20filename_29"></a><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#Exists_28_29">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.  <a href="#Exists_28_29"></a><br></td></tr>
39 <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="namespaceirc.html#string">std::string</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classFileReader.html#GetLine_28int_20x_29">GetLine</a> (int x)</td></tr>
40
41 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Retrieve one line from the file.  <a href="#GetLine_28int_20x_29"></a><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#FileSize_28_29">FileSize</a> ()</td></tr>
43
44 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns the size of the file in lines.  <a href="#FileSize_28_29"></a><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#file_5Fcache">file_cache</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classFileReader.html#fc">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#l01210">1210</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.<hr><h2>Constructor &amp; Destructor Documentation</h2>
57 <a class="anchor" name="FileReader_28_29"></a><!-- doxytag: member="FileReader::FileReader" ref="FileReader_28_29" args="()" --><p>
58 <table class="mdTable" 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       </table>
70     </td>
71   </tr>
72 </table>
73 <table cellspacing="5" cellpadding="0" border="0">
74   <tr>
75     <td>
76       &nbsp;
77     </td>
78     <td>
79
80 <p>
81 Default constructor. 
82 <p>
83 This method does not load any file into memory, you must use the LoadFile method after constructing the class this way.
84 <p>
85 Definition at line <a class="el" href="modules_8cpp-source.html#l00950">950</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.<div class="fragment"><pre class="fragment"><a name="l00951"></a>00951 {
86 <a name="l00952"></a>00952 }
87 </pre></div>
88 <p>
89     </td>
90   </tr>
91 </table>
92 <a class="anchor" name="FileReader_28std_3A_3Astring_20filename_29"></a><!-- doxytag: member="FileReader::FileReader" ref="FileReader_28std_3A_3Astring_20filename_29" args="(std::string filename)" --><p>
93 <table class="mdTable" cellpadding="2" cellspacing="0">
94   <tr>
95     <td class="mdRow">
96       <table cellpadding="0" cellspacing="0" border="0">
97         <tr>
98           <td class="md" nowrap valign="top">FileReader::FileReader           </td>
99           <td class="md" valign="top">(&nbsp;</td>
100           <td class="md" nowrap valign="top"><a class="el" href="namespaceirc.html#string">std::string</a>&nbsp;</td>
101           <td class="mdname1" valign="top" nowrap> <em>filename</em>          </td>
102           <td class="md" valign="top">&nbsp;)&nbsp;</td>
103           <td class="md" nowrap></td>
104         </tr>
105       </table>
106     </td>
107   </tr>
108 </table>
109 <table cellspacing="5" cellpadding="0" border="0">
110   <tr>
111     <td>
112       &nbsp;
113     </td>
114     <td>
115
116 <p>
117 Secondary constructor. 
118 <p>
119 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#FileSize_28_29">FileReader::FileSize</a> returns 0.
120 <p>
121 Definition at line <a class="el" href="modules_8cpp-source.html#l00943">943</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
122 <p>
123 References <a class="el" href="modules_8h-source.html#l01212">fc</a>.<div class="fragment"><pre class="fragment"><a name="l00944"></a>00944 {
124 <a name="l00945"></a>00945         <a class="code" href="modules_8h.html#file_5Fcache">file_cache</a> c;
125 <a name="l00946"></a>00946         readfile(c,filename.c_str());
126 <a name="l00947"></a>00947         this-&gt;<a class="code" href="classFileReader.html#fc">fc</a> = c;
127 <a name="l00948"></a>00948 }
128 </pre></div>
129 <p>
130     </td>
131   </tr>
132 </table>
133 <a class="anchor" name="_7EFileReader_28_29"></a><!-- doxytag: member="FileReader::~FileReader" ref="_7EFileReader_28_29" args="()" --><p>
134 <table class="mdTable" cellpadding="2" cellspacing="0">
135   <tr>
136     <td class="mdRow">
137       <table cellpadding="0" cellspacing="0" border="0">
138         <tr>
139           <td class="md" nowrap valign="top">FileReader::~FileReader           </td>
140           <td class="md" valign="top">(&nbsp;</td>
141           <td class="mdname1" valign="top" nowrap>          </td>
142           <td class="md" valign="top">&nbsp;)&nbsp;</td>
143           <td class="md" nowrap></td>
144         </tr>
145       </table>
146     </td>
147   </tr>
148 </table>
149 <table cellspacing="5" cellpadding="0" border="0">
150   <tr>
151     <td>
152       &nbsp;
153     </td>
154     <td>
155
156 <p>
157 Default destructor. 
158 <p>
159 This deletes the memory allocated to the file.
160 <p>
161 Definition at line <a class="el" href="modules_8cpp-source.html#l00962">962</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.<div class="fragment"><pre class="fragment"><a name="l00963"></a>00963 {
162 <a name="l00964"></a>00964 }
163 </pre></div>
164 <p>
165     </td>
166   </tr>
167 </table>
168 <hr><h2>Member Function Documentation</h2>
169 <a class="anchor" name="Exists_28_29"></a><!-- doxytag: member="FileReader::Exists" ref="Exists_28_29" args="()" --><p>
170 <table class="mdTable" cellpadding="2" cellspacing="0">
171   <tr>
172     <td class="mdRow">
173       <table cellpadding="0" cellspacing="0" border="0">
174         <tr>
175           <td class="md" nowrap valign="top">bool FileReader::Exists           </td>
176           <td class="md" valign="top">(&nbsp;</td>
177           <td class="mdname1" valign="top" nowrap>          </td>
178           <td class="md" valign="top">&nbsp;)&nbsp;</td>
179           <td class="md" nowrap></td>
180         </tr>
181       </table>
182     </td>
183   </tr>
184 </table>
185 <table cellspacing="5" cellpadding="0" border="0">
186   <tr>
187     <td>
188       &nbsp;
189     </td>
190     <td>
191
192 <p>
193 Returns true if the file exists This function will return false if the file could not be opened. 
194 <p>
195
196 <p>
197 Definition at line <a class="el" href="modules_8cpp-source.html#l00966">966</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
198 <p>
199 References <a class="el" href="modules_8h-source.html#l01212">fc</a>.<div class="fragment"><pre class="fragment"><a name="l00967"></a>00967 {
200 <a name="l00968"></a>00968         <span class="keywordflow">if</span> (<a class="code" href="classFileReader.html#fc">fc</a>.size() == 0)
201 <a name="l00969"></a>00969         {
202 <a name="l00970"></a>00970                 <span class="keywordflow">return</span>(<span class="keyword">false</span>);
203 <a name="l00971"></a>00971         }
204 <a name="l00972"></a>00972         <span class="keywordflow">else</span>
205 <a name="l00973"></a>00973         {
206 <a name="l00974"></a>00974                 <span class="keywordflow">return</span>(<span class="keyword">true</span>);
207 <a name="l00975"></a>00975         }
208 <a name="l00976"></a>00976 }
209 </pre></div>
210 <p>
211     </td>
212   </tr>
213 </table>
214 <a class="anchor" name="FileSize_28_29"></a><!-- doxytag: member="FileReader::FileSize" ref="FileSize_28_29" args="()" --><p>
215 <table class="mdTable" cellpadding="2" cellspacing="0">
216   <tr>
217     <td class="mdRow">
218       <table cellpadding="0" cellspacing="0" border="0">
219         <tr>
220           <td class="md" nowrap valign="top">int FileReader::FileSize           </td>
221           <td class="md" valign="top">(&nbsp;</td>
222           <td class="mdname1" valign="top" nowrap>          </td>
223           <td class="md" valign="top">&nbsp;)&nbsp;</td>
224           <td class="md" nowrap></td>
225         </tr>
226       </table>
227     </td>
228   </tr>
229 </table>
230 <table cellspacing="5" cellpadding="0" border="0">
231   <tr>
232     <td>
233       &nbsp;
234     </td>
235     <td>
236
237 <p>
238 Returns the size of the file in lines. 
239 <p>
240 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.
241 <p>
242 Definition at line <a class="el" href="modules_8cpp-source.html#l00985">985</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
243 <p>
244 References <a class="el" href="modules_8h-source.html#l01212">fc</a>.<div class="fragment"><pre class="fragment"><a name="l00986"></a>00986 {
245 <a name="l00987"></a>00987         <span class="keywordflow">return</span> <a class="code" href="classFileReader.html#fc">fc</a>.size();
246 <a name="l00988"></a>00988 }
247 </pre></div>
248 <p>
249     </td>
250   </tr>
251 </table>
252 <a class="anchor" name="GetLine_28int_20x_29"></a><!-- doxytag: member="FileReader::GetLine" ref="GetLine_28int_20x_29" args="(int x)" --><p>
253 <table class="mdTable" cellpadding="2" cellspacing="0">
254   <tr>
255     <td class="mdRow">
256       <table cellpadding="0" cellspacing="0" border="0">
257         <tr>
258           <td class="md" nowrap valign="top"><a class="el" href="namespaceirc.html#string">std::string</a> FileReader::GetLine           </td>
259           <td class="md" valign="top">(&nbsp;</td>
260           <td class="md" nowrap valign="top">int&nbsp;</td>
261           <td class="mdname1" valign="top" nowrap> <em>x</em>          </td>
262           <td class="md" valign="top">&nbsp;)&nbsp;</td>
263           <td class="md" nowrap></td>
264         </tr>
265       </table>
266     </td>
267   </tr>
268 </table>
269 <table cellspacing="5" cellpadding="0" border="0">
270   <tr>
271     <td>
272       &nbsp;
273     </td>
274     <td>
275
276 <p>
277 Retrieve one line from the file. 
278 <p>
279 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.
280 <p>
281 Definition at line <a class="el" href="modules_8cpp-source.html#l00978">978</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
282 <p>
283 References <a class="el" href="modules_8h-source.html#l01212">fc</a>.<div class="fragment"><pre class="fragment"><a name="l00979"></a>00979 {
284 <a name="l00980"></a>00980         <span class="keywordflow">if</span> ((x&lt;0) || ((<span class="keywordtype">unsigned</span>)x&gt;<a class="code" href="classFileReader.html#fc">fc</a>.size()))
285 <a name="l00981"></a>00981                 <span class="keywordflow">return</span> <span class="stringliteral">""</span>;
286 <a name="l00982"></a>00982         <span class="keywordflow">return</span> <a class="code" href="classFileReader.html#fc">fc</a>[x];
287 <a name="l00983"></a>00983 }
288 </pre></div>
289 <p>
290     </td>
291   </tr>
292 </table>
293 <a class="anchor" name="LoadFile_28std_3A_3Astring_20filename_29"></a><!-- doxytag: member="FileReader::LoadFile" ref="LoadFile_28std_3A_3Astring_20filename_29" args="(std::string filename)" --><p>
294 <table class="mdTable" cellpadding="2" cellspacing="0">
295   <tr>
296     <td class="mdRow">
297       <table cellpadding="0" cellspacing="0" border="0">
298         <tr>
299           <td class="md" nowrap valign="top">void FileReader::LoadFile           </td>
300           <td class="md" valign="top">(&nbsp;</td>
301           <td class="md" nowrap valign="top"><a class="el" href="namespaceirc.html#string">std::string</a>&nbsp;</td>
302           <td class="mdname1" valign="top" nowrap> <em>filename</em>          </td>
303           <td class="md" valign="top">&nbsp;)&nbsp;</td>
304           <td class="md" nowrap></td>
305         </tr>
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#FileSize_28_29">FileReader::FileSize</a> returns 0.
321 <p>
322 Definition at line <a class="el" href="modules_8cpp-source.html#l00954">954</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#l01212">fc</a>.<div class="fragment"><pre class="fragment"><a name="l00955"></a>00955 {
325 <a name="l00956"></a>00956         <a class="code" href="modules_8h.html#file_5Fcache">file_cache</a> c;
326 <a name="l00957"></a>00957         readfile(c,filename.c_str());
327 <a name="l00958"></a>00958         this-&gt;<a class="code" href="classFileReader.html#fc">fc</a> = c;
328 <a name="l00959"></a>00959 }
329 </pre></div>
330 <p>
331     </td>
332   </tr>
333 </table>
334 <hr><h2>Member Data Documentation</h2>
335 <a class="anchor" name="fc"></a><!-- doxytag: member="FileReader::fc" ref="fc" args="" --><p>
336 <table class="mdTable" cellpadding="2" cellspacing="0">
337   <tr>
338     <td class="mdRow">
339       <table cellpadding="0" cellspacing="0" border="0">
340         <tr>
341           <td class="md" nowrap valign="top"><a class="el" href="modules_8h.html#file_5Fcache">file_cache</a> <a class="el" href="classFileReader.html#fc">FileReader::fc</a><code> [private]</code>          </td>
342         </tr>
343       </table>
344     </td>
345   </tr>
346 </table>
347 <table cellspacing="5" cellpadding="0" border="0">
348   <tr>
349     <td>
350       &nbsp;
351     </td>
352     <td>
353
354 <p>
355
356 <p>
357 Definition at line <a class="el" href="modules_8h-source.html#l01212">1212</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
358 <p>
359 Referenced by <a class="el" href="modules_8cpp-source.html#l00966">Exists()</a>, <a class="el" href="modules_8cpp-source.html#l00943">FileReader()</a>, <a class="el" href="modules_8cpp-source.html#l00985">FileSize()</a>, <a class="el" href="modules_8cpp-source.html#l00978">GetLine()</a>, and <a class="el" href="modules_8cpp-source.html#l00954">LoadFile()</a>.    </td>
360   </tr>
361 </table>
362 <hr>The documentation for this class was generated from the following files:<ul>
363 <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>
364 <hr size="1"><address style="align: right;"><small>Generated on Sun Nov 27 01:43:25 2005 for InspIRCd by&nbsp;
365 <a href="http://www.doxygen.org/index.html">
366 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.4-20050815 </small></address>
367 </body>
368 </html>