.TH "ConfigReader" 3 "30 Apr 2004" "InspIRCd" \" -*- nroff -*- .ad l .nh .SH NAME 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. .PP .SH SYNOPSIS .br .PP \fC#include \fP .PP Inherits \fBclassbase\fP. .PP .SS "Public Member Functions" .in +1c .ti -1c .RI "\fBConfigReader\fP ()" .br .RI "\fIDefault constructor.\fP" .ti -1c .RI "\fBConfigReader\fP (std::string filename)" .br .RI "\fIOverloaded constructor.\fP" .ti -1c .RI "\fB~ConfigReader\fP ()" .br .RI "\fIDefault destructor.\fP" .ti -1c .RI "std::string \fBReadValue\fP (std::string tag, std::string name, int index)" .br .RI "\fIRetrieves a value from the config file.\fP" .ti -1c .RI "int \fBEnumerate\fP (std::string tag)" .br .RI "\fICounts the number of times a given tag appears in the config file.\fP" .ti -1c .RI "bool \fBVerify\fP ()" .br .RI "\fIReturns true if a config file is valid.\fP" .ti -1c .RI "int \fBEnumerateValues\fP (std::string tag, int index)" .br .RI "\fIReturns the number of items within a tag.\fP" .in -1c .SS "Protected Attributes" .in +1c .ti -1c .RI "std::stringstream * \fBcache\fP" .br .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" .ti -1c .RI "bool \fBerror\fP" .br .RI "\fIUsed to store errors.\fP" .in -1c .SH "Detailed Description" .PP 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. 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. .PP Definition at line 518 of file modules.h. .SH "Constructor & Destructor Documentation" .PP .SS "ConfigReader::ConfigReader ()" .PP 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. .PP References cache, and error. .PP .nf 344 { 345 this->cache = new std::stringstream(std::stringstream::in | std::stringstream::out); 346 this->error = LoadConf(CONFIG_FILE,this->cache); 347 } .fi .SS "ConfigReader::ConfigReader (std::string filename)" .PP Overloaded constructor.This constructor initialises the ConfigReader class to read a user-specified config fileDefinition at line 357 of file modules.cpp. .PP References cache, and error. .PP .nf 358 { 359 this->cache = new std::stringstream(std::stringstream::in | std::stringstream::out); 360 this->error = LoadConf(filename.c_str(),this->cache); 361 }; .fi .SS "ConfigReader::~ConfigReader ()" .PP Default destructor.This method destroys the ConfigReader class.Definition at line 350 of file modules.cpp. .PP References cache. .PP .nf 351 { 352 if (this->cache) 353 delete this->cache; 354 } .fi .SH "Member Function Documentation" .PP .SS "int ConfigReader::Enumerate (std::string tag)" .PP 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. .PP .nf 376 { 377 return EnumConf(cache,tag.c_str()); 378 } .fi .SS "int ConfigReader::EnumerateValues (std::string tag, int index)" .PP Returns the number of items within a tag.For example if the tag was then this function would return 2. Spaces and newlines both qualify as valid seperators between values.Definition at line 380 of file modules.cpp. .PP .nf 381 { 382 return EnumValues(cache, tag.c_str(), index); 383 } .fi .SS "std::string ConfigReader::ReadValue (std::string tag, std::string name, int index)" .PP 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. .PP .nf 364 { 365 char val[MAXBUF]; 366 char t[MAXBUF]; 367 char n[MAXBUF]; 368 strncpy(t,tag.c_str(),MAXBUF); 369 strncpy(n,name.c_str(),MAXBUF); 370 ReadConf(cache,t,n,index,val); 371 return std::string(val); 372 } .fi .SS "bool ConfigReader::Verify ()" .PP 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. .PP References error. .PP .nf 386 { 387 return this->error; 388 } .fi .SH "Member Data Documentation" .PP .SS "std::stringstream* ConfigReader::cache\fC [protected]\fP" .PP 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. .PP Referenced by ConfigReader(), and ~ConfigReader(). .SS "bool ConfigReader::error\fC [protected]\fP" .PP Used to store errors.Definition at line 529 of file modules.h. .PP Referenced by ConfigReader(), and Verify(). .SH "Author" .PP Generated automatically by Doxygen for InspIRCd from the source code.