ConfigObj Class Reference

#include <inipat.h>

List of all members.

Public Member Functions

 ConfigObj (const char *N, unsigned int L)
 ConfigObj (const ConfigObj &Other)
 ConfigObj (const ConfigObj *Other)
ConfigObjoperator= (const ConfigObj &Other)
bool IsMyName (const char *N) const
ConfigIterator GetConfig (const char *N, unsigned int Index=0)
ConfigIterator GetConfig (const char *N, const char *Param, const char *ValueOfParam)
TagIterator GetTag (const char *N, unsigned int Index=0)
TagInfoGetTag (unsigned int Index)
ConfigObjGetConfig (unsigned int Index)
unsigned int GetLineNo ()
TagIterator TagsBegin ()
TagIterator TagsEnd ()
ConfigIterator ConfigBegin ()
ConfigIterator ConfigEnd ()
ConfigRevIterator ConfigRbegin ()
ConfigRevIterator ConfigRend ()
TagIterator FindFirstTag (const char *ParamName)
ConfigIterator FindFirstConfig (const char *ConfigName)
ConfigIterator FindNextConfig (ConfigIterator &First)
ConfigIterator FindNextConfig (ConfigIterator &First, const char *TwinTag)
void Reverse ()
 Reverses order of subconfigs in this collection.
void Absorb (ConfigObj *Other)
 moves all tags and configs from *Other to *this, but does not deletes *Other
void Absorb (ConfigIterator Other)
void Load (char *filename)
ConfigStreamLoad (ConfigStream &Input)
ostream & Write (ostream &oStream, short TabShift=0)
unsigned int CountParams (const char *Name=NULL)
unsigned int CountConfigs (const char *Name=NULL)
void Merge (const char *Name=NULL)
void DropTwins (const char *Name, const char *TagName)
bool empty () const
void Drop (TagInfo *Param)
void Drop (ConfigObj *C)
void Drop (TagIterator &it)
void Drop (ConfigIterator &ci)
void DropAll ()
TagInfooperator[] (unsigned int i)
bool operator== (char *N)

Friends

class TypeTagIs
class NameIs


Detailed Description

class to store collection (vector) of TagInfo objects (actually just the pointers)

ConfigObj also can be a collection (another vector) of the other ConfigObj pointers instances which were incapsulated in this one in configuration file. Pointers are easier to manipulate with the collection, copy, move, or Drop them. Also stores the stream line number where this configuration markup <blahblah> has been opened


Member Function Documentation

void ConfigObj::Absorb ( ConfigIterator  Other  )  [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

unsigned int ConfigObj::CountConfigs ( const char *  Name = NULL  ) 

count the incapsulated config objects

Parameters:
Name is the incapsulated object name we want count up, caseinsensitive if not specified, or ==NULL then returned just the number of all config objects incapsulated in this config object.

unsigned int ConfigObj::CountParams ( const char *  Name = NULL  ) 

count the tags, which have the specified text at beginning

Parameters:
Name is the text at the begin of the tags to be counted up. If not specified or ==NULL, then returned just the number of all tags at this config object independent on their names

void ConfigObj::Drop ( ConfigIterator ci  )  [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void ConfigObj::Drop ( TagIterator it  )  [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void ConfigObj::Drop ( ConfigObj C  ) 

deletes the included Config object

void ConfigObj::Drop ( TagInfo Param  ) 

deletes single parameter from array of tags

deletes single parameter from array of tags most often is the parameter after have been used to configurate object variable or the property

Parameters:
Param the pointer to used tag parameter

void ConfigObj::DropTwins ( const char *  Name,
const char *  TagName 
)

search and delete the config objects with equal markup name and equal tag

Assume we have read the configuration details from a number of some other files and now we do need to drop some of configuration objects with the same markup name and the same tag property, to enshure the objects of given markup and tag values are unique in the collection. Only the first object with the same MarkupName and Tag=value pair will survive If you need the last Twin object to survived call Reverse() before and Reverse() again after DropTwins

Parameters:
Name the markup name of searched twin subconfigs
TagName the beginning of the tag which should have unique values (tag=value) in our collection

bool ConfigObj::empty (  )  const [inline]

just means if no params and no subconfigs

ConfigIterator ConfigObj::FindFirstConfig ( const char *  ConfigName  ) 

Finds the Config Collection which had tag <ConfigName> in the configuration file

Parameters:
ConfigName 
Returns:
Iterator object of Config. If the Config object not found, returns iterator end()
Attention:
caller should check the return iterator (*result!=NULL)

TagIterator ConfigObj::FindFirstTag ( const char *  ParamName  ) 

returns first tag iterator with given ParamName

actually does the same as GetTag(ParamName,0); later tags should be iterated by iterator cycle

Parameters:
ParamName At least some characters of the searched Tag,
Returns:
iterator object for the tag, of iterator end() if found not
Attention:
caller should check the return value if(*result)!=NULL)

ConfigIterator ConfigObj::FindNextConfig ( ConfigIterator First,
const char *  TwinTag 
)

Finds next config object with the same Name as the *First has, and the same value of TwinTag

Parameters:
First the iterator of the starting object
TwinTag string of the beginning of the tag, which should have the same value as the *First has
Returns:
the iterator of the object or iterator end() if nothing found
Attention:
the caller should check the returned result *result!=NULL before use it further if the First is the iterator from other config collection, then behaveour is unpredictable

ConfigIterator ConfigObj::FindNextConfig ( ConfigIterator First  ) 

Finds next config object with the same Name as the *First has

Parameters:
First 
Returns:
the iterator of the object or iterator end() if nothing found
Attention:
the caller should check the returned result *result!=NULL before use it further

ConfigObj* ConfigObj::GetConfig ( unsigned int  Index  )  [inline]

Deprecated:
All browsing is preferred in iterators

ConfigIterator ConfigObj::GetConfig ( const char *  N,
const char *  Param,
const char *  ValueOfParam 
)

get config object wich has specific parameter, with specific value

you should be shure the Value is unique among all Config objects of Type

Parameters:
Type this object was opened with <Type> mark in the config file
Param and had the Param=Value line in it's scope
Value the text of the tag after =
Returns:
the iterator of the found object or end() iterator if nothing found
Attention:
the caller should check if (*return != NULL) before use the returned value

ConfigIterator ConfigObj::GetConfig ( const char *  N,
unsigned int  Index = 0 
)

Finds the Config object which had been opened with <N> mark and after repeated sequented Index times

Parameters:
N name of the mark
Index sequental index
Returns:
the iterator of the found object or end() iterator if nothing found
Attention:
the caller should check if (*return != NULL) before use the returned value

TagIterator ConfigObj::GetTag ( const char *  N,
unsigned int  Index = 0 
)

returns Index-th tag wich begins with the text N

Parameters:
N some characters of the searched tag
Index sequental (counted) number of the tag, matching the N
Returns:
the N-th tag iterator, that matches the N, or end() iterator if nothing found
Attention:
caller should check returned iterator content against NULL

bool ConfigObj::IsMyName ( const char *  N  )  const

Compares the text with the config object name

Name of the config object is the text which was found between but the <sharp brackets>=""> themselves are excluded from name

Parameters:
N pointer to text to be compared with ConfigObj Name
Returns:
true if the text pointed with N is the same as Name of this ConfigObj
Parameters:
N the text of the opening markup
Returns:
true if this is the object which opened with <N> markup

ConfigStream & ConfigObj::Load ( ConfigStream Input  ) 

recursive read of included objects

this function is used to read the incapsulated config sections recursively until the markup </Name> will met

Parameters:
Input stream, where to read the config from
Returns:
the same stream

void ConfigObj::Load ( char *  filename  ) 

open the config stream and read the tags and objects of top level

Parameters:
filename is the string of config file name
Attention:
To enshure the config file with the specified name is exists and has markups consistent check it with ValidateINI function before call this Load

void ConfigObj::Merge ( const char *  Name = NULL  ) 

merges the config objects at the same incapsulation level

Assume we have read the configuration details from a number of some other files where are the properties of the one collection are scattered and eventually we want to gather all theese properties in the single config collection before we pass it to the program class instance to be configured

Parameters:
Name is the markup name of the scattered collection

ostream & ConfigObj::Write ( ostream &  oStream,
short  TabShift = 0 
)

write the all configuration forest.

Is usefull for learn, test and debug purposes. After load and manipulations to see the results in some output stream

Parameters:
oStream stream where to output the configurations
TabShift is the indent of the recursively incapsulated objects. Just leave this parameter default, all incapsulated objects were indented automatically


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

doxygen