1 .TH "ConfigReader" 3 "30 Apr 2004" "InspIRCd" \" -*- nroff -*-
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.
11 \fC#include <modules.h>\fP
13 Inherits \fBclassbase\fP.
15 .SS "Public Member Functions"
19 .RI "\fBConfigReader\fP ()"
21 .RI "\fIDefault constructor.\fP"
23 .RI "\fBConfigReader\fP (std::string filename)"
25 .RI "\fIOverloaded constructor.\fP"
27 .RI "\fB~ConfigReader\fP ()"
29 .RI "\fIDefault destructor.\fP"
31 .RI "std::string \fBReadValue\fP (std::string tag, std::string name, int index)"
33 .RI "\fIRetrieves a value from the config file.\fP"
35 .RI "int \fBEnumerate\fP (std::string tag)"
37 .RI "\fICounts the number of times a given tag appears in the config file.\fP"
39 .RI "bool \fBVerify\fP ()"
41 .RI "\fIReturns true if a config file is valid.\fP"
43 .RI "int \fBEnumerateValues\fP (std::string tag, int index)"
45 .RI "\fIReturns the number of items within a tag.\fP"
47 .SS "Protected Attributes"
51 .RI "std::stringstream * \fBcache\fP"
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"
55 .RI "bool \fBerror\fP"
57 .RI "\fIUsed to store errors.\fP"
59 .SH "Detailed Description"
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.
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.
65 Definition at line 518 of file modules.h.
66 .SH "Constructor & Destructor Documentation"
68 .SS "ConfigReader::ConfigReader ()"
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.
72 References cache, and error.
76 345 this->cache = new std::stringstream(std::stringstream::in | std::stringstream::out);
77 346 this->error = LoadConf(CONFIG_FILE,this->cache);
80 .SS "ConfigReader::ConfigReader (std::string filename)"
82 Overloaded constructor.This constructor initialises the ConfigReader class to read a user-specified config fileDefinition at line 357 of file modules.cpp.
84 References cache, and error.
88 359 this->cache = new std::stringstream(std::stringstream::in | std::stringstream::out);
89 360 this->error = LoadConf(filename.c_str(),this->cache);
92 .SS "ConfigReader::~ConfigReader ()"
94 Default destructor.This method destroys the ConfigReader class.Definition at line 350 of file modules.cpp.
101 353 delete this->cache;
104 .SH "Member Function Documentation"
106 .SS "int ConfigReader::Enumerate (std::string tag)"
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.
112 377 return EnumConf(cache,tag.c_str());
115 .SS "int ConfigReader::EnumerateValues (std::string tag, int index)"
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.
121 382 return EnumValues(cache, tag.c_str(), index);
124 .SS "std::string ConfigReader::ReadValue (std::string tag, std::string name, int index)"
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.
130 365 char val[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);
139 .SS "bool ConfigReader::Verify ()"
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.
147 387 return this->error;
150 .SH "Member Data Documentation"
152 .SS "std::stringstream* ConfigReader::cache\fC [protected]\fP"
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.
156 Referenced by ConfigReader(), and ~ConfigReader().
157 .SS "bool ConfigReader::error\fC [protected]\fP"
159 Used to store errors.Definition at line 529 of file modules.h.
161 Referenced by ConfigReader(), and Verify().
165 Generated automatically by Doxygen for InspIRCd from the source code.