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">
6 <!-- Generated by Doxygen 1.3.3 -->
7 <div class="qindex"><a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="namespaces.html">Namespace List</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></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>
11 <code>#include <<a class="el" href="modules_8h-source.html">modules.h</a>></code>
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="">
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="">
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>
23 <tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr>
24 <tr><td class="memItemLeft" nowrap align=right valign=top> </td><td class="memItemRight" valign=bottom><a class="el" href="classFileReader.html#a0">FileReader</a> ()</td></tr>
26 <tr><td class="mdescLeft"> </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> </td><td class="memItemRight" valign=bottom><a class="el" href="classFileReader.html#a1">FileReader</a> (std::string filename)</td></tr>
29 <tr><td class="mdescLeft"> </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> </td><td class="memItemRight" valign=bottom><a class="el" href="classFileReader.html#a2">~FileReader</a> ()</td></tr>
32 <tr><td class="mdescLeft"> </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 </td><td class="memItemRight" valign=bottom><a class="el" href="classFileReader.html#a3">LoadFile</a> (std::string filename)</td></tr>
35 <tr><td class="mdescLeft"> </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 </td><td class="memItemRight" valign=bottom><a class="el" href="classFileReader.html#a4">Exists</a> ()</td></tr>
38 <tr><td class="mdescLeft"> </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 </td><td class="memItemRight" valign=bottom><a class="el" href="classFileReader.html#a5">GetLine</a> (int x)</td></tr>
41 <tr><td class="mdescLeft"> </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 </td><td class="memItemRight" valign=bottom><a class="el" href="classFileReader.html#a6">FileSize</a> ()</td></tr>
44 <tr><td class="mdescLeft"> </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> </td><td class="memItemRight" valign=bottom><a class="el" href="classFileReader.html#r0">fc</a></td></tr>
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.
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.
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 & Destructor Documentation</h2>
57 <a name="a0" doxytag="FileReader::FileReader"></a><p>
58 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
61 <table cellpadding="0" cellspacing="0" border="0">
63 <td class="md" nowrap valign="top"> FileReader::FileReader </td>
64 <td class="md" valign="top">( </td>
65 <td class="mdname1" valign="top" nowrap> </td>
66 <td class="md" valign="top"> ) </td>
67 <td class="md" nowrap></td>
74 <table cellspacing=5 cellpadding=0 border=0>
84 This method does not load any file into memory, you must use the LoadFile method after constructing the class this way.
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>.
88 <div class="fragment"><pre>01024 {
93 <a name="a1" doxytag="FileReader::FileReader"></a><p>
94 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
97 <table cellpadding="0" cellspacing="0" border="0">
99 <td class="md" nowrap valign="top"> FileReader::FileReader </td>
100 <td class="md" valign="top">( </td>
101 <td class="md" nowrap valign="top">std::string </td>
102 <td class="mdname1" valign="top" nowrap> <em>filename</em> </td>
103 <td class="md" valign="top"> ) </td>
104 <td class="md" nowrap></td>
111 <table cellspacing=5 cellpadding=0 border=0>
119 Secondary constructor.
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.
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>.
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>.
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-><a class="code" href="classFileReader.html#r0">fc</a> = c;
135 <a name="a2" doxytag="FileReader::~FileReader"></a><p>
136 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
139 <table cellpadding="0" cellspacing="0" border="0">
141 <td class="md" nowrap valign="top"> FileReader::~<a class="el" href="classFileReader.html">FileReader</a> </td>
142 <td class="md" valign="top">( </td>
143 <td class="mdname1" valign="top" nowrap> </td>
144 <td class="md" valign="top"> ) </td>
145 <td class="md" nowrap></td>
152 <table cellspacing=5 cellpadding=0 border=0>
162 This deletes the memory allocated to the file.
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>.
166 <div class="fragment"><pre>01036 {
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">
176 <table cellpadding="0" cellspacing="0" border="0">
178 <td class="md" nowrap valign="top"> bool FileReader::Exists </td>
179 <td class="md" valign="top">( </td>
180 <td class="mdname1" valign="top" nowrap> </td>
181 <td class="md" valign="top"> ) </td>
182 <td class="md" nowrap></td>
189 <table cellspacing=5 cellpadding=0 border=0>
197 Returns true if the file exists This function will return false if the file could not be opened.
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>.
203 References <a class="el" href="modules_8h-source.html#l01238">fc</a>.
205 <div class="fragment"><pre>01040 {
206 01041 <span class="keywordflow">if</span> (<a class="code" href="classFileReader.html#r0">fc</a>.size() == 0)
208 01043 <span class="keywordflow">return</span>(<span class="keyword">false</span>);
210 01045 <span class="keywordflow">else</span>
212 01047 <span class="keywordflow">return</span>(<span class="keyword">true</span>);
218 <a name="a6" doxytag="FileReader::FileSize"></a><p>
219 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
222 <table cellpadding="0" cellspacing="0" border="0">
224 <td class="md" nowrap valign="top"> int FileReader::FileSize </td>
225 <td class="md" valign="top">( </td>
226 <td class="mdname1" valign="top" nowrap> </td>
227 <td class="md" valign="top"> ) </td>
228 <td class="md" nowrap></td>
235 <table cellspacing=5 cellpadding=0 border=0>
243 Returns the size of the file in lines.
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.
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>.
249 References <a class="el" href="modules_8h-source.html#l01238">fc</a>.
251 <div class="fragment"><pre>01059 {
252 01060 <span class="keywordflow">return</span> <a class="code" href="classFileReader.html#r0">fc</a>.size();
257 <a name="a5" doxytag="FileReader::GetLine"></a><p>
258 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
261 <table cellpadding="0" cellspacing="0" border="0">
263 <td class="md" nowrap valign="top"> std::string FileReader::GetLine </td>
264 <td class="md" valign="top">( </td>
265 <td class="md" nowrap valign="top">int </td>
266 <td class="mdname1" valign="top" nowrap> <em>x</em> </td>
267 <td class="md" valign="top"> ) </td>
268 <td class="md" nowrap></td>
275 <table cellspacing=5 cellpadding=0 border=0>
283 Retrieve one line from the file.
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.
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>.
289 References <a class="el" href="modules_8h-source.html#l01238">fc</a>.
291 <div class="fragment"><pre>01052 {
292 01053 <span class="keywordflow">if</span> ((x<0) || (x><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];
299 <a name="a3" doxytag="FileReader::LoadFile"></a><p>
300 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
303 <table cellpadding="0" cellspacing="0" border="0">
305 <td class="md" nowrap valign="top"> void FileReader::LoadFile </td>
306 <td class="md" valign="top">( </td>
307 <td class="md" nowrap valign="top">std::string </td>
308 <td class="mdname1" valign="top" nowrap> <em>filename</em> </td>
309 <td class="md" valign="top"> ) </td>
310 <td class="md" nowrap></td>
317 <table cellspacing=5 cellpadding=0 border=0>
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.
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>.
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>.
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-><a class="code" href="classFileReader.html#r0">fc</a> = c;
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">
346 <table cellpadding="0" cellspacing="0" border="0">
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>
353 <table cellspacing=5 cellpadding=0 border=0>
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>.
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>
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>