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-rc3 -->
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 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="">
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="">
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>
24 <tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr>
25 <tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classFileReader.html#a0">FileReader</a> ()</td></tr>
26 <tr><td> </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> </td><td valign=bottom><a class="el" href="classFileReader.html#a1">FileReader</a> (std::string filename)</td></tr>
28 <tr><td> </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> </td><td valign=bottom><a class="el" href="classFileReader.html#a2">~FileReader</a> ()</td></tr>
30 <tr><td> </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 </td><td valign=bottom><a class="el" href="classFileReader.html#a3">LoadFile</a> (std::string filename)</td></tr>
32 <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>
33 <tr><td nowrap align=right valign=top>bool </td><td valign=bottom><a class="el" href="classFileReader.html#a4">Exists</a> ()</td></tr>
34 <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>
35 <tr><td nowrap align=right valign=top>std::string </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 </td><td valign=bottom><a class="el" href="classFileReader.html#a6">FileSize</a> ()</td></tr>
37 <tr><td> </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#a9">file_cache</a> </td><td valign=bottom><a class="el" href="classFileReader.html#o0">fc</a></td></tr>
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.
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.
48 Definition at line <a class="el" href="modules_8h-source.html#l00347">347</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.<hr><h2>Constructor & Destructor Documentation</h2>
49 <a name="a0" doxytag="FileReader::FileReader"></a><p>
50 <table width="100%" cellpadding="2" cellspacing="0" border="0">
53 <table cellpadding="0" cellspacing="0" border="0">
55 <td class="md" nowrap valign="top"> FileReader::FileReader </td>
56 <td class="md" valign="top">( </td>
57 <td class="mdname1" valign="top" nowrap> </td>
58 <td class="md" valign="top">) </td>
59 <td class="md" nowrap></td>
66 <table cellspacing=5 cellpadding=0 border=0>
76 This method does not load any file into memory, you must use the LoadFile method after constructing the class this way.
78 Definition at line <a class="el" href="modules_8cpp-source.html#l00265">265</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
80 <div class="fragment"><pre>00266 {
85 <a name="a1" doxytag="FileReader::FileReader"></a><p>
86 <table width="100%" cellpadding="2" cellspacing="0" border="0">
89 <table cellpadding="0" cellspacing="0" border="0">
91 <td class="md" nowrap valign="top"> FileReader::FileReader </td>
92 <td class="md" valign="top">( </td>
93 <td class="md" nowrap valign="top">std::string </td>
94 <td class="mdname1" valign="top" nowrap> <em>filename</em> </td>
95 <td class="md" valign="top">) </td>
96 <td class="md" nowrap></td>
103 <table cellspacing=5 cellpadding=0 border=0>
111 Secondary constructor.
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.
115 Definition at line <a class="el" href="modules_8cpp-source.html#l00258">258</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
117 References <a class="el" href="modules_8h-source.html#l00349">fc</a>, and <a class="el" href="modules_8h-source.html#l00029">file_cache</a>.
119 <div class="fragment"><pre>00259 {
120 00260 <a class="code" href="modules_8h.html#a9">file_cache</a> c;
121 00261 readfile(c,filename.c_str());
122 00262 this-><a class="code" href="classFileReader.html#o0">fc</a> = c;
127 <a name="a2" doxytag="FileReader::~FileReader"></a><p>
128 <table width="100%" cellpadding="2" cellspacing="0" border="0">
131 <table cellpadding="0" cellspacing="0" border="0">
133 <td class="md" nowrap valign="top"> FileReader::~FileReader </td>
134 <td class="md" valign="top">( </td>
135 <td class="mdname1" valign="top" nowrap> </td>
136 <td class="md" valign="top">) </td>
137 <td class="md" nowrap></td>
144 <table cellspacing=5 cellpadding=0 border=0>
154 This deletes the memory allocated to the file.
156 Definition at line <a class="el" href="modules_8cpp-source.html#l00277">277</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
158 <div class="fragment"><pre>00278 {
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">
168 <table cellpadding="0" cellspacing="0" border="0">
170 <td class="md" nowrap valign="top"> bool FileReader::Exists </td>
171 <td class="md" valign="top">( </td>
172 <td class="mdname1" valign="top" nowrap> </td>
173 <td class="md" valign="top">) </td>
174 <td class="md" nowrap></td>
181 <table cellspacing=5 cellpadding=0 border=0>
189 Retrieve one line from the file.
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.
193 Definition at line <a class="el" href="modules_8cpp-source.html#l00281">281</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
195 References <a class="el" href="modules_8h-source.html#l00349">fc</a>.
197 <div class="fragment"><pre>00282 {
198 00283 <span class="keywordflow">if</span> (<a class="code" href="classFileReader.html#o0">fc</a>.size() == 0)
200 00285 <span class="keywordflow">return</span>(false);
202 00287 <span class="keywordflow">else</span>
204 00289 <span class="keywordflow">return</span>(true);
210 <a name="a6" doxytag="FileReader::FileSize"></a><p>
211 <table width="100%" cellpadding="2" cellspacing="0" border="0">
214 <table cellpadding="0" cellspacing="0" border="0">
216 <td class="md" nowrap valign="top"> int FileReader::FileSize </td>
217 <td class="md" valign="top">( </td>
218 <td class="mdname1" valign="top" nowrap> </td>
219 <td class="md" valign="top">) </td>
220 <td class="md" nowrap></td>
227 <table cellspacing=5 cellpadding=0 border=0>
235 Returns the size of the file in lines.
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.
239 Definition at line <a class="el" href="modules_8cpp-source.html#l00300">300</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
241 References <a class="el" href="modules_8h-source.html#l00349">fc</a>.
243 <div class="fragment"><pre>00301 {
244 00302 <span class="keywordflow">return</span> <a class="code" href="classFileReader.html#o0">fc</a>.size();
249 <a name="a5" doxytag="FileReader::GetLine"></a><p>
250 <table width="100%" cellpadding="2" cellspacing="0" border="0">
253 <table cellpadding="0" cellspacing="0" border="0">
255 <td class="md" nowrap valign="top"> std::string FileReader::GetLine </td>
256 <td class="md" valign="top">( </td>
257 <td class="md" nowrap valign="top">int </td>
258 <td class="mdname1" valign="top" nowrap> <em>x</em> </td>
259 <td class="md" valign="top">) </td>
260 <td class="md" nowrap></td>
267 <table cellspacing=5 cellpadding=0 border=0>
277 Definition at line <a class="el" href="modules_8cpp-source.html#l00293">293</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
279 References <a class="el" href="modules_8h-source.html#l00349">fc</a>.
281 <div class="fragment"><pre>00294 {
282 00295 <span class="keywordflow">if</span> ((x<0) || (x><a class="code" href="classFileReader.html#o0">fc</a>.size()))
283 00296 <span class="keywordflow">return</span> <span class="stringliteral">""</span>;
284 00297 <span class="keywordflow">return</span> <a class="code" href="classFileReader.html#o0">fc</a>[x];
289 <a name="a3" doxytag="FileReader::LoadFile"></a><p>
290 <table width="100%" cellpadding="2" cellspacing="0" border="0">
293 <table cellpadding="0" cellspacing="0" border="0">
295 <td class="md" nowrap valign="top"> void FileReader::LoadFile </td>
296 <td class="md" valign="top">( </td>
297 <td class="md" nowrap valign="top">std::string </td>
298 <td class="mdname1" valign="top" nowrap> <em>filename</em> </td>
299 <td class="md" valign="top">) </td>
300 <td class="md" nowrap></td>
307 <table cellspacing=5 cellpadding=0 border=0>
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.
319 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>.
321 References <a class="el" href="modules_8h-source.html#l00349">fc</a>, and <a class="el" href="modules_8h-source.html#l00029">file_cache</a>.
323 <div class="fragment"><pre>00270 {
324 00271 <a class="code" href="modules_8h.html#a9">file_cache</a> c;
325 00272 readfile(c,filename.c_str());
326 00273 this-><a class="code" href="classFileReader.html#o0">fc</a> = c;
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">
336 <table cellpadding="0" cellspacing="0" border="0">
338 <td class="md" nowrap valign="top"> <a class="el" href="modules_8h.html#a9">file_cache</a> FileReader::fc<code> [private]</code>
343 <table cellspacing=5 cellpadding=0 border=0>
353 Definition at line <a class="el" href="modules_8h-source.html#l00349">349</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
355 Referenced by <a class="el" href="modules_8cpp-source.html#l00281">Exists()</a>, <a class="el" href="modules_8cpp-source.html#l00258">FileReader()</a>, <a class="el" href="modules_8cpp-source.html#l00300">FileSize()</a>, <a class="el" href="modules_8cpp-source.html#l00293">GetLine()</a>, and <a class="el" href="modules_8cpp-source.html#l00269">LoadFile()</a>. </td>
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 Fri Apr 2 13:37:39 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>