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">
6 <!-- Generated by Doxygen 1.3-rc2 -->
8 <a class="qindex" href="main.html">Main Page</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> </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>
12 <code>#include <<a class="el" href="modules_8h-source.html">modules.h</a>></code>
14 <a href="classFileReader-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0>
16 <tr><td colspan=2><br><h2>Public Methods</h2></td></tr>
17 <tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classFileReader.html#a0">FileReader</a> ()</td></tr>
18 <tr><td> </td><td><font size=-1><em>Default constructor.</em> <a href="#a0"></a><em></em></font><br><br></td></tr>
19 <tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classFileReader.html#a1">FileReader</a> (string filename)</td></tr>
20 <tr><td> </td><td><font size=-1><em>Secondary constructor.</em> <a href="#a1"></a><em></em></font><br><br></td></tr>
21 <tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classFileReader.html#a2">~FileReader</a> ()</td></tr>
22 <tr><td> </td><td><font size=-1><em>Default destructor.</em> <a href="#a2"></a><em></em></font><br><br></td></tr>
23 <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classFileReader.html#a3">LoadFile</a> (string filename)</td></tr>
24 <tr><td> </td><td><font size=-1><em>Used to load a file.</em> <a href="#a3"></a><em></em></font><br><br></td></tr>
25 <tr><td nowrap align=right valign=top>string </td><td valign=bottom><a class="el" href="classFileReader.html#a4">GetLine</a> (int x)</td></tr>
26 <tr><td> </td><td><font size=-1><em>Retrieve one line from the file.</em> <a href="#a4"></a><em></em></font><br><br></td></tr>
27 <tr><td nowrap align=right valign=top>int </td><td valign=bottom><a class="el" href="classFileReader.html#a5">FileSize</a> ()</td></tr>
28 <tr><td> </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>
29 <tr><td colspan=2><br><h2>Private Attributes</h2></td></tr>
30 <tr><td nowrap align=right valign=top><a class="el" href="modules_8h.html#a1">file_cache</a> </td><td valign=bottom><a class="el" href="classFileReader.html#o0">fc</a></td></tr>
32 <hr><a name="_details"></a><h2>Detailed Description</h2>
33 Caches a text file into memory and can be used to retrieve lines from it.
35 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.
39 Definition at line <a class="el" href="modules_8h-source.html#l00277">277</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.<hr><h2>Constructor & Destructor Documentation</h2>
40 <a name="a0" doxytag="FileReader::FileReader"></a><p>
41 <table width="100%" cellpadding="2" cellspacing="0" border="0">
44 <table cellpadding="0" cellspacing="0" border="0">
46 <td class="md" nowrap valign="top"> FileReader::FileReader </td>
47 <td class="md" valign="top">( </td>
48 <td class="mdname1" valign="top" nowrap> </td>
49 <td class="md" valign="top">) </td>
50 <td class="md" nowrap></td>
57 <table cellspacing=5 cellpadding=0 border=0>
67 This method does not load any file into memory, you must use the LoadFile method after constructing the class this way.
69 Definition at line <a class="el" href="modules_8cpp-source.html#l00205">205</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
71 <div class="fragment"><pre>00206 {
76 <a name="a1" doxytag="FileReader::FileReader"></a><p>
77 <table width="100%" cellpadding="2" cellspacing="0" border="0">
80 <table cellpadding="0" cellspacing="0" border="0">
82 <td class="md" nowrap valign="top"> FileReader::FileReader </td>
83 <td class="md" valign="top">( </td>
84 <td class="md" nowrap valign="top">string </td>
85 <td class="mdname1" valign="top" nowrap> <em>filename</em> </td>
86 <td class="md" valign="top">) </td>
87 <td class="md" nowrap></td>
94 <table cellspacing=5 cellpadding=0 border=0>
102 Secondary constructor.
104 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.
106 Definition at line <a class="el" href="modules_8cpp-source.html#l00198">198</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
108 References <a class="el" href="modules_8h-source.html#l00279">fc</a>, and <a class="el" href="modules_8h-source.html#l00044">file_cache</a>.
110 <div class="fragment"><pre>00199 {
111 00200 <a class="code" href="modules_8h.html#a1">file_cache</a> c;
112 00201 readfile(c,filename.c_str());
113 00202 this-><a class="code" href="classFileReader.html#o0">fc</a> = c;
118 <a name="a2" doxytag="FileReader::~FileReader"></a><p>
119 <table width="100%" cellpadding="2" cellspacing="0" border="0">
122 <table cellpadding="0" cellspacing="0" border="0">
124 <td class="md" nowrap valign="top"> FileReader::~FileReader </td>
125 <td class="md" valign="top">( </td>
126 <td class="mdname1" valign="top" nowrap> </td>
127 <td class="md" valign="top">) </td>
128 <td class="md" nowrap></td>
135 <table cellspacing=5 cellpadding=0 border=0>
145 This deletes the memory allocated to the file.
147 Definition at line <a class="el" href="modules_8cpp-source.html#l00216">216</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
149 <div class="fragment"><pre>00217 {
154 <hr><h2>Member Function Documentation</h2>
155 <a name="a5" doxytag="FileReader::FileSize"></a><p>
156 <table width="100%" cellpadding="2" cellspacing="0" border="0">
159 <table cellpadding="0" cellspacing="0" border="0">
161 <td class="md" nowrap valign="top"> int FileReader::FileSize </td>
162 <td class="md" valign="top">( </td>
163 <td class="mdname1" valign="top" nowrap> </td>
164 <td class="md" valign="top">) </td>
165 <td class="md" nowrap></td>
172 <table cellspacing=5 cellpadding=0 border=0>
180 Returns the size of the file in lines.
182 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.
184 Definition at line <a class="el" href="modules_8cpp-source.html#l00227">227</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
186 References <a class="el" href="modules_8h-source.html#l00279">fc</a>.
188 <div class="fragment"><pre>00228 {
189 00229 <span class="keywordflow">return</span> <a class="code" href="classFileReader.html#o0">fc</a>.size();
194 <a name="a4" doxytag="FileReader::GetLine"></a><p>
195 <table width="100%" cellpadding="2" cellspacing="0" border="0">
198 <table cellpadding="0" cellspacing="0" border="0">
200 <td class="md" nowrap valign="top"> string FileReader::GetLine </td>
201 <td class="md" valign="top">( </td>
202 <td class="md" nowrap valign="top">int </td>
203 <td class="mdname1" valign="top" nowrap> <em>x</em> </td>
204 <td class="md" valign="top">) </td>
205 <td class="md" nowrap></td>
212 <table cellspacing=5 cellpadding=0 border=0>
220 Retrieve one line from the file.
222 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.
224 Definition at line <a class="el" href="modules_8cpp-source.html#l00220">220</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
226 References <a class="el" href="modules_8h-source.html#l00279">fc</a>.
228 <div class="fragment"><pre>00221 {
229 00222 <span class="keywordflow">if</span> ((x<0) || (x><a class="code" href="classFileReader.html#o0">fc</a>.size()))
230 00223 <span class="keywordflow">return</span> <span class="stringliteral">""</span>;
231 00224 <span class="keywordflow">return</span> <a class="code" href="classFileReader.html#o0">fc</a>[x];
236 <a name="a3" doxytag="FileReader::LoadFile"></a><p>
237 <table width="100%" cellpadding="2" cellspacing="0" border="0">
240 <table cellpadding="0" cellspacing="0" border="0">
242 <td class="md" nowrap valign="top"> void FileReader::LoadFile </td>
243 <td class="md" valign="top">( </td>
244 <td class="md" nowrap valign="top">string </td>
245 <td class="mdname1" valign="top" nowrap> <em>filename</em> </td>
246 <td class="md" valign="top">) </td>
247 <td class="md" nowrap></td>
254 <table cellspacing=5 cellpadding=0 border=0>
264 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.
266 Definition at line <a class="el" href="modules_8cpp-source.html#l00209">209</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
268 References <a class="el" href="modules_8h-source.html#l00279">fc</a>, and <a class="el" href="modules_8h-source.html#l00044">file_cache</a>.
270 <div class="fragment"><pre>00210 {
271 00211 <a class="code" href="modules_8h.html#a1">file_cache</a> c;
272 00212 readfile(c,filename.c_str());
273 00213 this-><a class="code" href="classFileReader.html#o0">fc</a> = c;
278 <hr><h2>Member Data Documentation</h2>
279 <a name="o0" doxytag="FileReader::fc"></a><p>
280 <table width="100%" cellpadding="2" cellspacing="0" border="0">
283 <table cellpadding="0" cellspacing="0" border="0">
285 <td class="md" nowrap valign="top"> <a class="el" href="modules_8h.html#a1">file_cache</a> FileReader::fc<code> [private]</code>
290 <table cellspacing=5 cellpadding=0 border=0>
300 Definition at line <a class="el" href="modules_8h-source.html#l00279">279</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
302 Referenced by <a class="el" href="modules_8cpp-source.html#l00198">FileReader()</a>, <a class="el" href="modules_8cpp-source.html#l00227">FileSize()</a>, <a class="el" href="modules_8cpp-source.html#l00220">GetLine()</a>, and <a class="el" href="modules_8cpp-source.html#l00209">LoadFile()</a>. </td>
305 <hr>The documentation for this class was generated from the following files:<ul>
306 <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>
307 <hr><address style="align: right;"><small>Generated on Thu Jan 23 20:28:59 2003 for InspIRCd by
308 <a href="http://www.doxygen.org/index.html">
309 <img src="doxygen.png" alt="doxygen" align="middle" border=0
310 width=110 height=53></a>1.3-rc2 </small></address>