vcConfig Class Reference

#include <vcConfig.h>

Collaboration diagram for vcConfig:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 vcConfig ()
 ~vcConfig ()
 vcConfig (const vcConfig &)
bool loadFile (string)
bool saveFile (string)
void set (string, string)
void set (string, bool)
void set (string, int)
string getString (string)
bool getBool (string)
int getInt (string)
string toString ()
void fromString (string)
void clear ()
int size ()
bool isSet (string)
bool areSet (string[], int)
void operator= (vcConfig)

Static Public Member Functions

static string getVersion ()

Private Member Functions

void setReal (string, string)

Private Attributes

map< string, string > items
map< string, string >::iterator it


Detailed Description

Very simple config file handler.

Uses basic KEY=value Skips blank lines and lines starting with #


Constructor & Destructor Documentation

vcConfig::vcConfig (  ) 

vcConfig::~vcConfig (  ) 

vcConfig::vcConfig ( const vcConfig _config  ) 

Copy constructor.

Parameters:
_config Another vcConfig object.


Member Function Documentation

bool vcConfig::loadFile ( string  file  ) 

Attempts to load a file containing configuration options.

Parameters:
file The file name to load.
Returns:
True on successfull load. Note, this doesn't mean any configuration options were set, just that the file was opened and read successfully. If it isn't a configuration file, or is empty it isn't going to return false.

bool vcConfig::saveFile ( string  file  ) 

Attempts to save the current configuration to a file. Be aware that this is a complete overwrite.

Parameters:
file The name of the file to save into.
Returns:
True if the write succeeded.
Todo:
This should be more gentle, searching for pairs and replacing them inline.

void vcConfig::set ( string  index,
string  value 
)

Sets a configuration value.

Parameters:
index The configuration name.
value The configuration value.

void vcConfig::set ( string  index,
bool  value 
)

Sets a configuration value.

Parameters:
index The configuration name.
value The configuration value.

void vcConfig::set ( string  index,
int  value 
)

Sets a configuration value.

Parameters:
index The configuration name.
value The configuration value.

string vcConfig::getString ( string  index  ) 

Returns the string value of a configuration item.

Parameters:
index The configuration name.
Returns:
The string value of that configuration. Empty string if it isn't found.

bool vcConfig::getBool ( string  index  ) 

Returns the string value of a configuration item.

Parameters:
index The configuration name.
Returns:
True if the configuration item is a boolean, and is true. Otherwise false.

Todo:
This should throw exception.

Todo:
This should throw exception.

int vcConfig::getInt ( string  index  ) 

Returns the string value of a configuration item.

Parameters:
index The configuration name.
Returns:
The value of the integer, or -1 if not found

Todo:
This should throw exception.

string vcConfig::toString (  ) 

Dumps the configuration to a string. Good for debugging.

Returns:
A string representing the current configuration state.

void vcConfig::fromString ( string   ) 

void vcConfig::clear (  ) 

Clears out all the config information.

int vcConfig::size (  ) 

The size of the config.

Returns:
The number of configuration items stored.

bool vcConfig::isSet ( string  index  ) 

Check if an index is set. May still be empty.

Parameters:
index The index to look for.
Returns:
True if the index is find.

bool vcConfig::areSet ( string  indicies[],
int  size 
)

Checks that every index in the passed array has a set value. May still be empty, but they are still there.

Parameters:
indicies An array of indicies to check.
size The size of the array.
Returns:
True if all indicies are found.

string vcConfig::getVersion (  )  [static]

Get the version of the library. Don't know why you'd actually want this.

Returns:
The version number.

void vcConfig::operator= ( vcConfig  right  ) 

Assignment operator overload.

Parameters:
right The vcConfig to copy in.

void vcConfig::setReal ( string  index,
string  value 
) [private]

Everything is stored as a string, this set's it for real.

Parameters:
index The configuration name.
value The configuration value.


Member Data Documentation

map<string,string> vcConfig::items [private]

map<string,string>::iterator vcConfig::it [private]


The documentation for this class was generated from the following files:

Generated on Thu Apr 24 17:31:52 2008 for libvcconfig by  doxygen 1.5.5