Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

ConfigReader Class Reference

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. More...

#include <modules.h>

Inheritance diagram for ConfigReader:

Inheritance graph
[legend]
Collaboration diagram for ConfigReader:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ConfigReader ()
 Default constructor.

 ConfigReader (std::string filename)
 Overloaded constructor.

 ~ConfigReader ()
 Default destructor.

std::string ReadValue (std::string tag, std::string name, int index)
 Retrieves a value from the config file.

int Enumerate (std::string tag)
 Counts the number of times a given tag appears in the config file.

bool Verify ()
 Returns true if a config file is valid.


Protected Attributes

std::string fname
 The filename of the configuration file, as set by the constructor.


Detailed Description

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.

Definition at line 448 of file modules.h.


Constructor & Destructor Documentation

ConfigReader::ConfigReader  
 

Default constructor.

This constructor initialises the ConfigReader class to read the inspircd.conf file as specified when running ./configure.

Definition at line 296 of file modules.cpp.

References fname.

00297 {
00298         fname = CONFIG_FILE;
00299 }

ConfigReader::ConfigReader std::string    filename
 

Overloaded constructor.

This constructor initialises the ConfigReader class to read a user-specified config file

Definition at line 307 of file modules.cpp.

00307 : fname(filename) { };

ConfigReader::~ConfigReader  
 

Default destructor.

This method destroys the ConfigReader class.

Definition at line 302 of file modules.cpp.

00303 {
00304 }


Member Function Documentation

int ConfigReader::Enumerate std::string    tag
 

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 ConfigReader::ReadValue to loop through all copies of a multiple instance tag.

Definition at line 317 of file modules.cpp.

References fname.

00318 {
00319         return EnumConf(fname.c_str(),tag.c_str());
00320 }

std::string ConfigReader::ReadValue std::string    tag,
std::string    name,
int    index
 

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 309 of file modules.cpp.

References fname.

00310 {
00311         char val[MAXBUF];
00312         ReadConf(fname.c_str(),tag.c_str(),name.c_str(),index,val);
00313         return val;
00314 }

bool ConfigReader::Verify  
 

Returns true if a config file is valid.

This method is unimplemented and will always return true.

Definition at line 323 of file modules.cpp.

00324 {
00325         return true;
00326 }


Member Data Documentation

std::string ConfigReader::fname [protected]
 

The filename of the configuration file, as set by the constructor.

Definition at line 453 of file modules.h.

Referenced by ConfigReader(), Enumerate(), and ReadValue().


The documentation for this class was generated from the following files:
Generated on Tue Apr 6 21:13:50 2004 for InspIRCd by doxygen1.3-rc3