Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

ConfigReader Class Reference

The class used to read config files in easily. More...

#include <configreader.h>

List of all members.

Public Member Functions

 ConfigReader (bool buffer=false)
 Constructor.
 ConfigReader (PMString fileName, bool buffer=false)
 Constructor.
 ~ConfigReader ()
 Destructor.
void SetBuffered (bool buffer)
 Sets the buffer bool and buffers accordingly.
void SetFileName (PMString fileName)
 Set the filename.
void BufferReader ()
 Buffer the reader.
PMString GetFileName ()
 Return the filename.
PMString GetConfigValue (PMString variable)
 Return a config variable.
std::vector< PMStringListVariables ()
 List all the variables in the reader.

Protected Attributes

bool _buffered
 Is the reader buffered?
PMString _fileName
 The filename.
std::vector< ConfigPair_configPairs
 The ConfigPairs in the reader.


Detailed Description

The main config reader class. Used to read config files of the form VARIABLE HERE = VALUE HERE. Spaces can be used to format however the config designer wishes. Comments can be written using '#' as a delimeter. The class also ignores lines without an '=', but using this as comments is bad practice.


Constructor & Destructor Documentation

ConfigReader::ConfigReader bool  buffer = false  ) 
 

Constructor that just sets the buffer bool, basically does nothing.

Parameters:
buffer Should the reader buffer all the variables or read from the file each time?

ConfigReader::ConfigReader PMString  fileName,
bool  buffer = false
 

Constructor that just sets the buffer bool and the fileName. Buffers the reader if the bool is true.

Parameters:
fileName The config file to read.
buffer Should the readers buffer all the variables or read from the file each time?
Exceptions:
PortageException(eErrorOpeningFile,filename) if the reader is buffered.
PortageException(eFileStreamError,filename) if the reader is buffered.

ConfigReader::~ConfigReader  ) 
 

Empty Destructor.


Member Function Documentation

void ConfigReader::BufferReader  ) 
 

Buffer the reader.

Exceptions:
PortageException(eErrorOpeningFile,filename). 
PortageException(eFileStreamError,filename). 

PMString ConfigReader::GetConfigValue PMString  variable  ) 
 

Get the value of variable. Checks the buffer if it exists, otherwise opens the _fileName and checks in there.

Parameters:
variable The variable to look for in the config file.
Returns:
The value of the variable.
Exceptions:
PortageException(eErrorOpeningFile,filename) if the reader is not buffered.
PortageException(eFileStreamError,_fileName) if the reader is not buffered.
PortageException(eInvalidVariable,variable) if the variable does not exist.

PMString ConfigReader::GetFileName  ) 
 

Get the _fileName.

Returns:
The filename the reader is reading.

std::vector< PMString > ConfigReader::ListVariables  ) 
 

List all the variables in the reader.

Returns:
A vector of all the variables.

void ConfigReader::SetBuffered bool  buffer  ) 
 

Sets the value of _buffered to be buffer. Then buffers or clears the buffer, depending on the appropriate values of the bools.

Parameters:
buffer Should the readers buffer all the variables or read from the file each time?
Exceptions:
PortageException(eErrorOpeningFile,filename) if buffer is true.
PortageException(eFileStreamError,filename) if buffer is true.

void ConfigReader::SetFileName PMString  fileName  ) 
 

Sets the fileName for the reader - buffers if _buffered is true.

Parameters:
fileName The config file to read.
Exceptions:
PortageException(eErrorOpeningFile,filename) if the reader is buffered.
PortageException(eFileStreamError,filename) if the reader is buffered.


The documentation for this class was generated from the following files:
Generated on Wed May 25 15:29:54 2005 for Package Management System for Gentoo Linux by  doxygen 1.4.1