]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - docs/man/man3/FileReader.3
Re-added the dot graphs again
[user/henk/code/inspircd.git] / docs / man / man3 / FileReader.3
1 .TH "FileReader" 3 "13 May 2005" "InspIRCd" \" -*- nroff -*-
2 .ad l
3 .nh
4 .SH NAME
5 FileReader \- Caches a text file into memory and can be used to retrieve lines from it.  
6
7 .PP
8 .SH SYNOPSIS
9 .br
10 .PP
11 \fC#include <modules.h>\fP
12 .PP
13 Inherits \fBclassbase\fP.
14 .PP
15 .SS "Public Member Functions"
16
17 .in +1c
18 .ti -1c
19 .RI "\fBFileReader\fP ()"
20 .br
21 .RI "\fIDefault constructor. \fP"
22 .ti -1c
23 .RI "\fBFileReader\fP (std::string filename)"
24 .br
25 .RI "\fISecondary constructor. \fP"
26 .ti -1c
27 .RI "\fB~FileReader\fP ()"
28 .br
29 .RI "\fIDefault destructor. \fP"
30 .ti -1c
31 .RI "void \fBLoadFile\fP (std::string filename)"
32 .br
33 .RI "\fIUsed to load a file. \fP"
34 .ti -1c
35 .RI "bool \fBExists\fP ()"
36 .br
37 .RI "\fIReturns true if the file exists This function will return false if the file could not be opened. \fP"
38 .ti -1c
39 .RI "std::string \fBGetLine\fP (int x)"
40 .br
41 .RI "\fIRetrieve one line from the file. \fP"
42 .ti -1c
43 .RI "int \fBFileSize\fP ()"
44 .br
45 .RI "\fIReturns the size of the file in lines. \fP"
46 .in -1c
47 .SS "Private Attributes"
48
49 .in +1c
50 .ti -1c
51 .RI "\fBfile_cache\fP \fBfc\fP"
52 .br
53 .in -1c
54 .SH "Detailed Description"
55 .PP 
56 Caches a text file into memory and can be used to retrieve lines from it. 
57
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. 
59 .PP
60 Definition at line 1236 of file modules.h.
61 .SH "Constructor & Destructor Documentation"
62 .PP 
63 .SS "FileReader::FileReader ()"
64 .PP
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 1023 of file modules.cpp.
66 .PP
67 .nf
68 1024 {
69 1025 }
70 .fi
71 .SS "FileReader::FileReader (std::string filename)"
72 .PP
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 1016 of file modules.cpp.
74 .PP
75 References fc, and file_cache.
76 .PP
77 .nf
78 1017 {
79 1018         file_cache c;
80 1019         readfile(c,filename.c_str());
81 1020         this->fc = c;
82 1021 }
83 .fi
84 .SS "FileReader::~\fBFileReader\fP ()"
85 .PP
86 Default destructor. This deletes the memory allocated to the file.Definition at line 1035 of file modules.cpp.
87 .PP
88 .nf
89 1036 {
90 1037 }
91 .fi
92 .SH "Member Function Documentation"
93 .PP 
94 .SS "bool FileReader::Exists ()"
95 .PP
96 Returns true if the file exists This function will return false if the file could not be opened. Definition at line 1039 of file modules.cpp.
97 .PP
98 References fc.
99 .PP
100 .nf
101 1040 {
102 1041         if (fc.size() == 0)
103 1042         {
104 1043                 return(false);
105 1044         }
106 1045         else
107 1046         {
108 1047                 return(true);
109 1048         }
110 1049 }
111 .fi
112 .SS "int FileReader::FileSize ()"
113 .PP
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 1058 of file modules.cpp.
115 .PP
116 References fc.
117 .PP
118 .nf
119 1059 {
120 1060         return fc.size();
121 1061 }
122 .fi
123 .SS "std::string FileReader::GetLine (int x)"
124 .PP
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 1051 of file modules.cpp.
126 .PP
127 References fc.
128 .PP
129 .nf
130 1052 {
131 1053         if ((x<0) || (x>fc.size()))
132 1054                 return '';
133 1055         return fc[x];
134 1056 }
135 .fi
136 .SS "void FileReader::LoadFile (std::string filename)"
137 .PP
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 1027 of file modules.cpp.
139 .PP
140 References fc, and file_cache.
141 .PP
142 .nf
143 1028 {
144 1029         file_cache c;
145 1030         readfile(c,filename.c_str());
146 1031         this->fc = c;
147 1032 }
148 .fi
149 .SH "Member Data Documentation"
150 .PP 
151 .SS "\fBfile_cache\fP \fBFileReader::fc\fP\fC [private]\fP"
152 .PP
153 Definition at line 1238 of file modules.h.
154 .PP
155 Referenced by Exists(), FileReader(), FileSize(), GetLine(), and LoadFile().
156
157 .SH "Author"
158 .PP 
159 Generated automatically by Doxygen for InspIRCd from the source code.