1 .TH "FileReader" 3 "30 Apr 2004" "InspIRCd" \" -*- nroff -*-
5 FileReader \- Caches a text file into memory and can be used to retrieve lines from it.
11 \fC#include <modules.h>\fP
13 Inherits \fBclassbase\fP.
15 .SS "Public Member Functions"
19 .RI "\fBFileReader\fP ()"
21 .RI "\fIDefault constructor.\fP"
23 .RI "\fBFileReader\fP (std::string filename)"
25 .RI "\fISecondary constructor.\fP"
27 .RI "\fB~FileReader\fP ()"
29 .RI "\fIDefault destructor.\fP"
31 .RI "void \fBLoadFile\fP (std::string filename)"
33 .RI "\fIUsed to load a file.\fP"
35 .RI "bool \fBExists\fP ()"
37 .RI "\fIReturns true if the file exists This function will return false if the file could not be opened.\fP"
39 .RI "std::string \fBGetLine\fP (int x)"
41 .RI "\fIRetrieve one line from the file.\fP"
43 .RI "int \fBFileSize\fP ()"
45 .RI "\fIReturns the size of the file in lines.\fP"
47 .SS "Private Attributes"
51 .RI "\fBfile_cache\fP \fBfc\fP"
54 .SH "Detailed Description"
56 Caches a text file into memory and can be used to retrieve lines from it.
58 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.
60 Definition at line 578 of file modules.h.
61 .SH "Constructor & Destructor Documentation"
63 .SS "FileReader::FileReader ()"
65 Default constructor.This method does not load any file into memory, you must use the LoadFile method after constructing the class this way.Definition at line 398 of file modules.cpp.
71 .SS "FileReader::FileReader (std::string filename)"
73 Secondary constructor.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, \fBFileReader::FileSize\fP returns 0.Definition at line 391 of file modules.cpp.
75 References fc, and file_cache.
80 394 readfile(c,filename.c_str());
84 .SS "FileReader::~FileReader ()"
86 Default destructor.This deletes the memory allocated to the file.Definition at line 410 of file modules.cpp.
92 .SH "Member Function Documentation"
94 .SS "bool FileReader::Exists ()"
96 Returns true if the file exists This function will return false if the file could not be opened.Definition at line 414 of file modules.cpp.
102 416 if (fc.size() == 0)
112 .SS "int FileReader::FileSize ()"
114 Returns the size of the file in lines.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.Definition at line 433 of file modules.cpp.
120 435 return fc.size();
123 .SS "std::string FileReader::GetLine (int x)"
125 Retrieve one line from the file.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.Definition at line 426 of file modules.cpp.
131 428 if ((x<0) || (x>fc.size()))
136 .SS "void FileReader::LoadFile (std::string filename)"
138 Used to load a file.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, \fBFileReader::FileSize\fP returns 0.Definition at line 402 of file modules.cpp.
140 References fc, and file_cache.
145 405 readfile(c,filename.c_str());
149 .SH "Member Data Documentation"
151 .SS "\fBfile_cache\fP FileReader::fc\fC [private]\fP"
153 Definition at line 580 of file modules.h.
155 Referenced by Exists(), FileReader(), FileSize(), GetLine(), and LoadFile().
159 Generated automatically by Doxygen for InspIRCd from the source code.