]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - docs/man/ConfigReader.3
Added ability to update the helpop file on rehash (Bug #69)
[user/henk/code/inspircd.git] / docs / man / ConfigReader.3
1 .TH "ConfigReader" 3 "30 Apr 2004" "InspIRCd" \" -*- nroff -*-
2 .ad l
3 .nh
4 .SH NAME
5 ConfigReader \- Allows reading of values from configuration files This class allows a module to read from either the main configuration file (inspircd.conf) or from a module-specified configuration file. 
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 "\fBConfigReader\fP ()"
20 .br
21 .RI "\fIDefault constructor.\fP"
22 .ti -1c
23 .RI "\fBConfigReader\fP (std::string filename)"
24 .br
25 .RI "\fIOverloaded constructor.\fP"
26 .ti -1c
27 .RI "\fB~ConfigReader\fP ()"
28 .br
29 .RI "\fIDefault destructor.\fP"
30 .ti -1c
31 .RI "std::string \fBReadValue\fP (std::string tag, std::string name, int index)"
32 .br
33 .RI "\fIRetrieves a value from the config file.\fP"
34 .ti -1c
35 .RI "int \fBEnumerate\fP (std::string tag)"
36 .br
37 .RI "\fICounts the number of times a given tag appears in the config file.\fP"
38 .ti -1c
39 .RI "bool \fBVerify\fP ()"
40 .br
41 .RI "\fIReturns true if a config file is valid.\fP"
42 .ti -1c
43 .RI "int \fBEnumerateValues\fP (std::string tag, int index)"
44 .br
45 .RI "\fIReturns the number of items within a tag.\fP"
46 .in -1c
47 .SS "Protected Attributes"
48
49 .in +1c
50 .ti -1c
51 .RI "std::stringstream * \fBcache\fP"
52 .br
53 .RI "\fIThe contents of the configuration file This protected member should never be accessed by a module (and cannot be accessed unless the core is changed).\fP"
54 .ti -1c
55 .RI "bool \fBerror\fP"
56 .br
57 .RI "\fIUsed to store errors.\fP"
58 .in -1c
59 .SH "Detailed Description"
60 .PP 
61 Allows reading of values from configuration files This class allows a module to read from either the main configuration file (inspircd.conf) or from a module-specified configuration file.
62
63 It may either be instantiated with one parameter or none. Constructing the class using one parameter allows you to specify a path to your own configuration file, otherwise, inspircd.conf is read. 
64 .PP
65 Definition at line 518 of file modules.h.
66 .SH "Constructor & Destructor Documentation"
67 .PP 
68 .SS "ConfigReader::ConfigReader ()"
69 .PP
70 Default constructor.This constructor initialises the ConfigReader class to read the inspircd.conf file as specified when running ./configure.Definition at line 343 of file modules.cpp.
71 .PP
72 References cache, and error.
73 .PP
74 .nf
75 344 {
76 345         this->cache = new std::stringstream(std::stringstream::in | std::stringstream::out);
77 346         this->error = LoadConf(CONFIG_FILE,this->cache);
78 347 }
79 .fi
80 .SS "ConfigReader::ConfigReader (std::string filename)"
81 .PP
82 Overloaded constructor.This constructor initialises the ConfigReader class to read a user-specified config fileDefinition at line 357 of file modules.cpp.
83 .PP
84 References cache, and error.
85 .PP
86 .nf
87 358 {
88 359         this->cache = new std::stringstream(std::stringstream::in | std::stringstream::out);
89 360         this->error = LoadConf(filename.c_str(),this->cache);
90 361 };
91 .fi
92 .SS "ConfigReader::~ConfigReader ()"
93 .PP
94 Default destructor.This method destroys the ConfigReader class.Definition at line 350 of file modules.cpp.
95 .PP
96 References cache.
97 .PP
98 .nf
99 351 {
100 352         if (this->cache)
101 353                 delete this->cache;
102 354 }
103 .fi
104 .SH "Member Function Documentation"
105 .PP 
106 .SS "int ConfigReader::Enumerate (std::string tag)"
107 .PP
108 Counts the number of times a given tag appears in the config file.This method counts the number of times a tag appears in a config file, for use where there are several tags of the same kind, e.g. with opers and connect types. It can be used with the index value of \fBConfigReader::ReadValue\fP to loop through all copies of a multiple instance tag.Definition at line 375 of file modules.cpp.
109 .PP
110 .nf
111 376 {
112 377         return EnumConf(cache,tag.c_str());
113 378 }
114 .fi
115 .SS "int ConfigReader::EnumerateValues (std::string tag, int index)"
116 .PP
117 Returns the number of items within a tag.For example if the tag was <test tag='blah' data='foo'> then this function would return 2. Spaces and newlines both qualify as valid seperators between values.Definition at line 380 of file modules.cpp.
118 .PP
119 .nf
120 381 {
121 382         return EnumValues(cache, tag.c_str(), index);
122 383 }
123 .fi
124 .SS "std::string ConfigReader::ReadValue (std::string tag, std::string name, int index)"
125 .PP
126 Retrieves a value from the config file.This method retrieves a value from the config file. Where multiple copies of the tag exist in the config file, index indicates which of the values to retrieve.Definition at line 363 of file modules.cpp.
127 .PP
128 .nf
129 364 {
130 365         char val[MAXBUF];
131 366         char t[MAXBUF];
132 367         char n[MAXBUF];
133 368         strncpy(t,tag.c_str(),MAXBUF);
134 369         strncpy(n,name.c_str(),MAXBUF);
135 370         ReadConf(cache,t,n,index,val);
136 371         return std::string(val);
137 372 }
138 .fi
139 .SS "bool ConfigReader::Verify ()"
140 .PP
141 Returns true if a config file is valid.This method is partially implemented and will only return false if the config file does not exist or could not be opened.Definition at line 385 of file modules.cpp.
142 .PP
143 References error.
144 .PP
145 .nf
146 386 {
147 387         return this->error;
148 388 }
149 .fi
150 .SH "Member Data Documentation"
151 .PP 
152 .SS "std::stringstream* ConfigReader::cache\fC [protected]\fP"
153 .PP
154 The contents of the configuration file This protected member should never be accessed by a module (and cannot be accessed unless the core is changed).It will contain a pointer to the configuration file data with unneeded data (such as comments) stripped from it.Definition at line 526 of file modules.h.
155 .PP
156 Referenced by ConfigReader(), and ~ConfigReader().
157 .SS "bool ConfigReader::error\fC [protected]\fP"
158 .PP
159 Used to store errors.Definition at line 529 of file modules.h.
160 .PP
161 Referenced by ConfigReader(), and Verify().
162
163 .SH "Author"
164 .PP 
165 Generated automatically by Doxygen for InspIRCd from the source code.