mbo::CIniData Class Reference

Storage/Retrieval of Initialisation data. More...

#include <MboIniData.h>

Collaboration diagram for mbo::CIniData:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 CIniData (const MboString &strFilename, const MboString &strSectionPrefix="")
virtual ~CIniData ()
virtual const MboStringGetFilename () const
virtual MboString GetIniDirectory () const
virtual const MboStringGetSectionPrefix () const
bool GetSectionNames (const MboString &strSectionPrefix, CStrList &vstrSectionNames) const
bool GetSectionNames (CStrList &vstrSectionNames) const
bool SectionExists (const MboString &strSection) const
virtual bool GetKeyNames (const MboString &strSection, CStrList &vstrKeyNames) const
virtual bool KeyNameExists (const MboString &strSection, const MboString &strKeyname) const
virtual bool ReadString (const MboString &strSection, const MboString &strKeyname, MboString &strValue, const MboString &strDefault="", bool bWriteDefault=false, bool bParseEnvVars=false) const
virtual MboString GetString (const MboString &strSection, const MboString &strKeyname, const MboString &strDefault="", bool bWriteDefault=false, bool bParseEnvVars=false) const
virtual bool ReadInt (const MboString &strSection, const MboString &strKeyname, int &nValue, int nDefault=0, bool bWriteDefault=false, int nMinimum=INT_MIN, int nMaximum=INT_MAX) const
virtual int GetInt (const MboString &strSection, const MboString &strKeyname, int nDefault=0, bool bWriteDefault=false, int nMinimum=INT_MIN, int nMaximum=INT_MAX) const
virtual bool ReadLong (const MboString &strSection, const MboString &strKeyname, long &lValue, long lDefault=0, bool bWriteDefault=false, long lMinimum=LONG_MIN, long lMaximum=LONG_MAX) const
virtual long GetLong (const MboString &strSection, const MboString &strKeyname, long lDefault=0L, bool bWriteDefault=false, long lMinimum=LONG_MIN, long lMaximum=LONG_MAX) const
virtual bool ReadFloat (const MboString &strSection, const MboString &strKeyname, float &fValue, float fDefault=0.0f, bool bWriteDefault=false, float fMinimum=-FLT_MAX, float fMaximum=FLT_MAX) const
virtual float GetFloat (const MboString &strSection, const MboString &strKeyname, float fDefault=0.0f, bool bWriteDefault=false, float fMinimum=-FLT_MAX, float fMaximum=FLT_MAX) const
virtual bool ReadDouble (const MboString &strSection, const MboString &strKeyname, double &fValue, double fDefault=0.0, bool bWriteDefault=false, double fMinimum=-DBL_MAX, double fMaximum=DBL_MAX) const
virtual double GetDouble (const MboString &strSection, const MboString &strKeyname, double fDefault=0.0, bool bWriteDefault=false, double fMinimum=-DBL_MAX, double fMaximum=DBL_MAX) const
virtual bool ReadBool (const MboString &strSection, const MboString &strKeyname, bool &bValue, bool bDefault=false, bool bWriteDefault=false) const
virtual bool GetBool (const MboString &strSection, const MboString &strKeyname, bool bDefault=false, bool bWriteDefault=false) const
virtual bool ReadColor (const MboString &strSection, const MboString &strKeyname, COLORREF &colValue, COLORREF colDefault=RGB(0, 0, 0), bool bWriteDefault=false) const
virtual COLORREF GetColor (const MboString &strSection, const MboString &strKeyname, COLORREF colDefault=RGB(0, 0, 0), bool bWriteDefault=false) const
virtual bool ReadMap (const MboString &strSection, CStrMapStr &msstrValue, const CStrMapStr &msstrDefault=CStrMapStr(), bool bWriteDefault=false, bool bWriteEmpty=false, bool bRetrieveAll=false) const
virtual CStrMapStr GetMap (const MboString &strSection, const CStrMapStr &msstrDefault=CStrMapStr(), bool bWriteDefault=false, bool bWriteEmpty=false, bool bRetrieveAll=false) const
virtual bool ReadSectionList (const MboString &strSection, CIniSectionList &vsstrValue, const CIniSectionList &vsstrDefault=CIniSectionList(), bool bWriteDefault=false, bool bWriteEmpty=false, bool bRetrieveAll=false) const
virtual bool EmptySection (const MboString &strSection, bool bKeepComments=true)
virtual bool ClearSection (const MboString &strSection)
virtual bool DeleteKey (const MboString &strSection, const MboString &strKeyname)
virtual bool RenameKey (const MboString &strSection, const MboString &strKeynameOld, const MboString &strKeynameNew)
virtual bool WriteString (const MboString &strSection, const MboString &strKeyname, const MboString &strValue)
virtual bool WriteInt (const MboString &strSection, const MboString &strKeyname, int nValue)
virtual bool WriteLong (const MboString &strSection, const MboString &strKeyname, long lValue)
virtual bool WriteFloat (const MboString &strSection, const MboString &strKeyname, float fValue)
virtual bool WriteDouble (const MboString &strSection, const MboString &strKeyname, double fValue)
virtual bool WriteBool (const MboString &strSection, const MboString &strKeyname, bool bValue)
virtual bool WriteColor (const MboString &strSection, const MboString &strKeyname, COLORREF colValue)
virtual bool WriteMap (const MboString &strSection, CStrMapStr msstrValue, bool bWriteEmpty=false, bool bKeepComments=true)
virtual bool WriteSectionList (const MboString &strSection, CIniSectionList vsstrValue, bool bWriteEmpty=false, bool bKeepComments=true)
virtual bool ReplaceSectionList (const MboString &strSection, const CIniSectionList &vsstrValue, bool bWriteEmpty=false)
bool IsValidKey (const MboString &strKeyName, bool bAcceptComment=false) const
mbo::CLock IniDataGetLock () const

Static Public Member Functions

static MboString GetIniString (const MboString &strFilename, const MboString &strSection, const MboString &strKeyname, const MboString &strDefault="", bool bWriteDefault=false, bool bParseEnvVars=false)
static int GetIniInt (const MboString &strFilename, const MboString &strSection, const MboString &strKeyname, int nDefault=0, bool bWriteDefault=false, int nMinimum=INT_MIN, int nMaximum=INT_MAX)
static long GetIniLong (const MboString &strFilename, const MboString &strSection, const MboString &strKeyname, long lDefault=0L, bool bWriteDefault=false, long lMinimum=LONG_MIN, long lMaximum=LONG_MAX)
static float GetIniFloat (const MboString &strFilename, const MboString &strSection, const MboString &strKeyname, float fDefault=0.0f, bool bWriteDefault=false, float fMinimum=-FLT_MAX, float fMaximum=FLT_MAX)
static double GetIniDouble (const MboString &strFilename, const MboString &strSection, const MboString &strKeyname, double fDefault=0.0, bool bWriteDefault=false, double fMinimum=-DBL_MAX, double fMaximum=DBL_MAX)
static bool GetIniBool (const MboString &strFilename, const MboString &strSection, const MboString &strKeyname, bool bDefault=false, bool bWriteDefault=false)
static COLORREF GetIniColor (const MboString &strFilename, const MboString &strSection, const MboString &strKeyname, COLORREF colDefault=RGB(0, 0, 0), bool bWriteDefault=false)
static CStrMapStr GetIniMap (const MboString &strFilename, const MboString &strSection, const CStrMapStr &msstrDefault=CStrMapStr(), bool bWriteDefault=false, bool bWriteEmpty=false)

Protected Types

typedef mbo::quaternion< bool,
MboString, MboString,
MboString
TIniValue
typedef std::list< TIniValueTIniData
typedef std::pair< MboString,
TIniData
TIniSection
typedef std::list< TIniSectionTIniCache

Protected Member Functions

virtual bool ReadFile ()
virtual bool IniDataFlush (bool bModified=false) const
bool IsEmptyIniValue (const TIniValue &val) const
TIniCache::iterator GetSection (const MboString &strSection)
TIniCache::const_iterator GetSection (const MboString &strSection) const
TIniCache::iterator GetSectionOrCreate (const MboString &strSection)
TIniValueGetValuePtr (const TIniCache::iterator &itSection, const MboString &strKeyName)
const TIniValueGetValuePtr (const TIniCache::const_iterator &itSection, const MboString &strKeyName) const
TIniValueGetValuePtr (const MboString &strSection, const MboString &strKeyName)
const TIniValueGetValuePtr (const MboString &strSection, const MboString &strKeyName) const
TIniData::iterator FindFirstEmpty (TIniCache::iterator &itSection)
TIniData::iterator AddValue (TIniCache::iterator &itSection, TIniData::iterator itValue, const MboString &strKeyName, const MboString &strValue)
TIniData::iterator AddValue (TIniCache::iterator &itSection, const MboString &strKeyName, const MboString &strValue)
TIniData::iterator AddValue (const MboString &strSection, const MboString &strKeyName, const MboString &strValue)

Classes

class  CIniMutex
 extended mutex that enables auto-flushing


Detailed Description

Storage/Retrieval of Initialisation data.

Features:

Definition at line 274 of file MboIniData.h.


Member Typedef Documentation

typedef mbo::quaternion<bool, MboString, MboString, MboString> mbo::CIniData::TIniValue [protected]

Definition at line 1220 of file MboIniData.h.

typedef std::list<TIniValue> mbo::CIniData::TIniData [protected]

Definition at line 1221 of file MboIniData.h.

typedef std::pair<MboString, TIniData> mbo::CIniData::TIniSection [protected]

Definition at line 1222 of file MboIniData.h.

typedef std::list<TIniSection> mbo::CIniData::TIniCache [protected]

Definition at line 1223 of file MboIniData.h.


Constructor & Destructor Documentation

mbo::CIniData::CIniData ( const MboString strFilename,
const MboString strSectionPrefix = "" 
) [explicit]

Construct an interface that uses the ini file strFilename.

If that file does not exist it will be created in the WINDOWS (WINNT) directory. All actions are atomic. With the exeption that some functions first clear sections with an atomic function and then write some data into the new section.

When strSectionPrefix is given each Section that will be read or written will be prepended by that prefix.

Parameters:
strFilename Name of ini file to open or create.
strSectionPrefix Section prefix to use for all section names.
Note:
If not explicitly stated the methods use strSectionPrefix to prefix all section names given as input parameters. Also the section prefix is automatically removed from returned section names.

virtual mbo::CIniData::~CIniData (  )  [virtual]

The destructor does not do anything with the file. As all actions are performed directly.


Member Function Documentation

virtual const MboString& mbo::CIniData::GetFilename (  )  const [virtual]

Read access to the name of the file used internally.

Returns:
filename

virtual MboString mbo::CIniData::GetIniDirectory (  )  const [virtual]

Returns:
path to file

virtual const MboString& mbo::CIniData::GetSectionPrefix (  )  const [virtual]

Read access to the section prefix applied to all functions.

Returns:
section prefix

bool mbo::CIniData::GetSectionNames ( const MboString strSectionPrefix,
CStrList vstrSectionNames 
) const

Retrieve all sectionnames starting with strSection The returned Names will not contain the global SectionPrefix but the local strSectionPrefix.

Parameters:
strSectionPrefix Additional section prefix to search for.
Return values:
vstrSectionNames Retrieves all found (matched) sections. The list will be cleared first.
Returns:
whether or not any (matched) section was found.

bool mbo::CIniData::GetSectionNames ( CStrList vstrSectionNames  )  const

Retrieve all sectionnames starting with strSection The returned Names will not contain the global SectionPrefix.

Return values:
vstrSectionNames Retrieves all found (matched) sections. The list will be cleared first.
Returns:
whether or not any (matched) section was found.

bool mbo::CIniData::SectionExists ( const MboString strSection  )  const

Check if a specific section exists

Parameters:
strSection Name of section to search
Returns:
whether or not section exists.

virtual bool mbo::CIniData::GetKeyNames ( const MboString strSection,
CStrList vstrKeyNames 
) const [virtual]

Retrieves all keynames in section strSection.

Parameters:
strSection Name of section to search.
Return values:
vstrKeyNames Keynames contained in specified section.
Returns:
Whether or not at least one key was found.

virtual bool mbo::CIniData::KeyNameExists ( const MboString strSection,
const MboString strKeyname 
) const [virtual]

Check whether or not a specific KeyName exists in section strSection.

Parameters:
strSection Name of section to search.
strKeyname Name of key to search.
Returns:
Whether or not key exists in given section.

virtual bool mbo::CIniData::ReadString ( const MboString strSection,
const MboString strKeyname,
MboString strValue,
const MboString strDefault = "",
bool  bWriteDefault = false,
bool  bParseEnvVars = false 
) const [virtual]

Read a string value from strSection with name strKeyname. When there is no such value stored in the file the default value strDefault is used. The function returns whether or not the returned value was read from file.

If bParseEnvVars is true then the result will be paresed for environment variables recursively.

See also:
MboString::ParseEnvVars
Parameters:
strSection Name of section to search.
strKeyname Name of key to search.
Return values:
strValue Value for key if found or default.
Parameters:
strDefault Default value to use if key not present.
bWriteDefault Whether or not the default should be written to the ini file if key is not present in ini file.
bParseEnvVars Whether or not environment variables should be parsed. If so "%name%" will be replaced by the value of the environment variable "name".
Returns:
Whether or not returned value was read from ini file.

virtual MboString mbo::CIniData::GetString ( const MboString strSection,
const MboString strKeyname,
const MboString strDefault = "",
bool  bWriteDefault = false,
bool  bParseEnvVars = false 
) const [virtual]

Same as ReadString but here the value (read or default) is returned.

Parameters:
strSection Name of section to search.
strKeyname Name of key to search.
strDefault Default value to use if key not present.
bWriteDefault Whether or not the default should be written to the ini file if key is not present in ini file.
bParseEnvVars Whether or not environment variables should be parsed. If so "%name%" will be replaced by the value of the environment variable "name".
Returns:
Value for key if found or default.

static MboString mbo::CIniData::GetIniString ( const MboString strFilename,
const MboString strSection,
const MboString strKeyname,
const MboString strDefault = "",
bool  bWriteDefault = false,
bool  bParseEnvVars = false 
) [static]

Same as GetString but static from file without the need to first create a CIniData instance. Use this only if you access one single value.

Parameters:
strFilename Name of ini file to read.
strSection Name of section to search.
strKeyname Name of key to search.
strDefault Default value to use if key not present.
bWriteDefault Whether or not the default should be written to the ini file if key is not present in ini file.
bParseEnvVars Whether or not environment variables should be parsed. If so "%name%" will be replaced by the value of the environment variable "name".
Returns:
Value for key if found or default.

virtual bool mbo::CIniData::ReadInt ( const MboString strSection,
const MboString strKeyname,
int &  nValue,
int  nDefault = 0,
bool  bWriteDefault = false,
int  nMinimum = INT_MIN,
int  nMaximum = INT_MAX 
) const [virtual]

Read an integer value from strSection with name strKeyname. When there is no such value stored in the file the default value nDefault is used. The function returns whether or not the returned value was read from file. When the value was read from file and a conversion error occures the returned value is zero (not default). The parameter bWriteDefault can be set true to ensure the ini directive exists after first read attempt in case it could not be found while reading. In that case this read function is no longer a const function.

Parameters:
strSection Name of section to search.
strKeyname Name of key to search.
Return values:
nValue Value for key if found or default.
Parameters:
nDefault Default value to use if key not present.
bWriteDefault Whether or not the default should be written to the ini file if key is not present in ini file.
nMinimum Lower values will be replaced by this minimum.
nMaximum Higher values will be replaced by this maximum.
Returns:
Whether or not returned value was read from ini file.

virtual int mbo::CIniData::GetInt ( const MboString strSection,
const MboString strKeyname,
int  nDefault = 0,
bool  bWriteDefault = false,
int  nMinimum = INT_MIN,
int  nMaximum = INT_MAX 
) const [virtual]

Same as ReadInt but here the value (read or default) is returned.

Parameters:
strSection Name of section to search.
strKeyname Name of key to search.
nDefault Default value to use if key not present.
bWriteDefault Whether or not the default should be written to the ini file if key is not present in ini file.
nMinimum Lower values will be replaced by this minimum.
nMaximum Higher values will be replaced by this maximum.
Returns:
Value for key if found or default.

static int mbo::CIniData::GetIniInt ( const MboString strFilename,
const MboString strSection,
const MboString strKeyname,
int  nDefault = 0,
bool  bWriteDefault = false,
int  nMinimum = INT_MIN,
int  nMaximum = INT_MAX 
) [static]

Same as GetInt but static from file without the need to first create a CIniData instance. Use this only if you access one single value.

Parameters:
strFilename Name of ini file to read.
strSection Name of section to search.
strKeyname Name of key to search.
nDefault Default value to use if key not present.
bWriteDefault Whether or not the default should be written to the ini file if key is not present in ini file.
nMinimum Lower values will be replaced by this minimum.
nMaximum Higher values will be replaced by this maximum.
Returns:
Value for key if found or default.

virtual bool mbo::CIniData::ReadLong ( const MboString strSection,
const MboString strKeyname,
long &  lValue,
long  lDefault = 0,
bool  bWriteDefault = false,
long  lMinimum = LONG_MIN,
long  lMaximum = LONG_MAX 
) const [virtual]

Read a long value from strSection with name strKeyname. When there is no such value stored in the file the default value lDefault is used. The function returns whether or not the returned value was read from file. When the value was read from file and a conversion error occures the returned value is zero (not default). The parameter bWriteDefault can be set true to ensure the ini directive exists after first read attempt in case it could not be found while reading. In that case this read function is no longer a const function.

Parameters:
strSection Name of section to search.
strKeyname Name of key to search.
Return values:
lValue Value for key if found or default.
Parameters:
lDefault Default value to use if key not present.
bWriteDefault Whether or not the default should be written to the ini file if key is not present in ini file.
lMinimum Lower values will be replaced by this minimum.
lMaximum Higher values will be replaced by this maximum.
Returns:
Whether or not returned value was read from ini file.

virtual long mbo::CIniData::GetLong ( const MboString strSection,
const MboString strKeyname,
long  lDefault = 0L,
bool  bWriteDefault = false,
long  lMinimum = LONG_MIN,
long  lMaximum = LONG_MAX 
) const [virtual]

Same as ReadLong but here the value (read or default) is returned.

Parameters:
strSection Name of section to search.
strKeyname Name of key to search.
lDefault Default value to use if key not present.
bWriteDefault Whether or not the default should be written to the ini file if key is not present in ini file.
lMinimum Lower values will be replaced by this minimum.
lMaximum Higher values will be replaced by this maximum.
Returns:
Value for key if found or default.

static long mbo::CIniData::GetIniLong ( const MboString strFilename,
const MboString strSection,
const MboString strKeyname,
long  lDefault = 0L,
bool  bWriteDefault = false,
long  lMinimum = LONG_MIN,
long  lMaximum = LONG_MAX 
) [static]

Same as GetIni but static from file without the need to first create a CIniData instance. Use this only if you access one single value.

Parameters:
strFilename Name of ini file to read.
strSection Name of section to search.
strKeyname Name of key to search.
lDefault Default value to use if key not present.
bWriteDefault Whether or not the default should be written to the ini file if key is not present in ini file.
lMinimum Lower values will be replaced by this minimum.
lMaximum Higher values will be replaced by this maximum.
Returns:
Value for key if found or default.

virtual bool mbo::CIniData::ReadFloat ( const MboString strSection,
const MboString strKeyname,
float &  fValue,
float  fDefault = 0.0f,
bool  bWriteDefault = false,
float  fMinimum = -FLT_MAX,
float  fMaximum = FLT_MAX 
) const [virtual]

Read a float value from strSection with name strKeyname. When there is no such value stored in the file the default value fDefault is used. The function returns whether or not the returned value was read from file. When the value was read from file and a conversion error occures the returned value is zero (not default). The parameter bWriteDefault can be set true to ensure the ini directive exists after first read attempt in case it could not be found while reading. In that case this read function is no longer a const function.

Parameters:
strSection Name of section to search.
strKeyname Name of key to search.
Return values:
fValue Value for key if found or default.
Parameters:
fDefault Default value to use if key not present.
bWriteDefault Whether or not the default should be written to the ini file if key is not present in ini file.
fMinimum Lower values will be replaced by this minimum.
fMaximum Higher values will be replaced by this maximum.
Returns:
Whether or not returned value was read from ini file.

virtual float mbo::CIniData::GetFloat ( const MboString strSection,
const MboString strKeyname,
float  fDefault = 0.0f,
bool  bWriteDefault = false,
float  fMinimum = -FLT_MAX,
float  fMaximum = FLT_MAX 
) const [virtual]

Same as ReadFloat but here the value (read or default) is returned.

Parameters:
strSection Name of section to search.
strKeyname Name of key to search.
fDefault Default value to use if key not present.
bWriteDefault Whether or not the default should be written to the ini file if key is not present in ini file.
fMinimum Lower values will be replaced by this minimum.
fMaximum Higher values will be replaced by this maximum.
Returns:
Value for key if found or default.

static float mbo::CIniData::GetIniFloat ( const MboString strFilename,
const MboString strSection,
const MboString strKeyname,
float  fDefault = 0.0f,
bool  bWriteDefault = false,
float  fMinimum = -FLT_MAX,
float  fMaximum = FLT_MAX 
) [static]

Same as GetFloat but static from file without the need to first create a CIniData instance. Use this only if you access one single value.

Parameters:
strFilename Name of ini file to read.
strSection Name of section to search.
strKeyname Name of key to search.
fDefault Default value to use if key not present.
bWriteDefault Whether or not the default should be written to the ini file if key is not present in ini file.
fMinimum Lower values will be replaced by this minimum.
fMaximum Higher values will be replaced by this maximum.
Returns:
Value for key if found or default.

virtual bool mbo::CIniData::ReadDouble ( const MboString strSection,
const MboString strKeyname,
double &  fValue,
double  fDefault = 0.0,
bool  bWriteDefault = false,
double  fMinimum = -DBL_MAX,
double  fMaximum = DBL_MAX 
) const [virtual]

Read a double value from strSection with name strKeyname. When there is no such value stored in the file the default value fDefault is used. The function returns whether or not the returned value was read from file. When the value was read from file and a conversion error occures the returned value is zero (not default). The parameter bWriteDefault can be set true to ensure the ini directive exists after first read attempt in case it could not be found while reading. In that case this read function is no longer a const function.

Parameters:
strSection Name of section to search.
strKeyname Name of key to search.
Return values:
fValue Value for key if found or default.
Parameters:
fDefault Default value to use if key not present.
bWriteDefault Whether or not the default should be written to the ini file if key is not present in ini file.
fMinimum Lower values will be replaced by this minimum.
fMaximum Higher values will be replaced by this maximum.
Returns:
Whether or not returned value was read from ini file.

virtual double mbo::CIniData::GetDouble ( const MboString strSection,
const MboString strKeyname,
double  fDefault = 0.0,
bool  bWriteDefault = false,
double  fMinimum = -DBL_MAX,
double  fMaximum = DBL_MAX 
) const [virtual]

Same as ReadDouble but here the value (read or default) is returned.

Parameters:
strSection Name of section to search.
strKeyname Name of key to search.
fDefault Default value to use if key not present.
bWriteDefault Whether or not the default should be written to the ini file if key is not present in ini file.
fMinimum Lower values will be replaced by this minimum.
fMaximum Higher values will be replaced by this maximum.
Returns:
Value for key if found or default.

static double mbo::CIniData::GetIniDouble ( const MboString strFilename,
const MboString strSection,
const MboString strKeyname,
double  fDefault = 0.0,
bool  bWriteDefault = false,
double  fMinimum = -DBL_MAX,
double  fMaximum = DBL_MAX 
) [static]

Same as GetDouble but static from file without the need to first create a CIniData instance. Use this only if you access one single value.

Parameters:
strFilename Name of ini file to read.
strSection Name of section to search.
strKeyname Name of key to search.
fDefault Default value to use if key not present.
bWriteDefault Whether or not the default should be written to the ini file if key is not present in ini file.
fMinimum Lower values will be replaced by this minimum.
fMaximum Higher values will be replaced by this maximum.
Returns:
Value for key if found or default.

virtual bool mbo::CIniData::ReadBool ( const MboString strSection,
const MboString strKeyname,
bool &  bValue,
bool  bDefault = false,
bool  bWriteDefault = false 
) const [virtual]

Read a boolean value from strSection with name strKeyname. When there is no such value stored in the file the default value bDefault is used. The function returns whether or not the returned value was read from file. When the value was read from file and a conversion error occures the returned value is zero (not default). The parameter bWriteDefault can be set true to ensure the ini directive exists after first read attempt in case it could not be found while reading. In that case this read function is no longer a const function.

Parameters:
strSection Name of section to search.
strKeyname Name of key to search.
Return values:
bValue Value for key if found or default.
Parameters:
bDefault Default value to use if key not present.
bWriteDefault Whether or not the default should be written to the ini file if key is not present in ini file.
Returns:
Whether or not returned value was read from ini file.

virtual bool mbo::CIniData::GetBool ( const MboString strSection,
const MboString strKeyname,
bool  bDefault = false,
bool  bWriteDefault = false 
) const [virtual]

Same as ReadBool but here the value (read or default) is returned.

Parameters:
strSection Name of section to search.
strKeyname Name of key to search.
bDefault Default value to use if key not present.
bWriteDefault Whether or not the default should be written to the ini file if key is not present in ini file.
Returns:
Value for key if found or default.

static bool mbo::CIniData::GetIniBool ( const MboString strFilename,
const MboString strSection,
const MboString strKeyname,
bool  bDefault = false,
bool  bWriteDefault = false 
) [static]

Same as GetBool but static from file without the need to first create a CIniData instance. Use this only if you access one single value.

Parameters:
strFilename Name of ini file to read.
strSection Name of section to search.
strKeyname Name of key to search.
bDefault Default value to use if key not present.
bWriteDefault Whether or not the default should be written to the ini file if key is not present in ini file.
Returns:
Value for key if found or default.

virtual bool mbo::CIniData::ReadColor ( const MboString strSection,
const MboString strKeyname,
COLORREF &  colValue,
COLORREF  colDefault = RGB(0, 0, 0),
bool  bWriteDefault = false 
) const [virtual]

Read a COLORREF value from strSection with name strKeyname. When there is no such value stored in the file the default value colDefault is used. The function returns whether or not the returned value was read from file. When the value was read from file and a conversion error occures for any color component that value is set to zero. The parameter bWriteDefault can be set true to ensure the ini directive exists after first read attempt in case it could not be found while reading. In that case this read function is no longer a const function.

Parameters:
strSection Name of section to search.
strKeyname Name of key to search.
Return values:
colValue Value for key if found or default.
Parameters:
colDefault Default value to use if key not present.
bWriteDefault Whether or not the default should be written to the ini file if key is not present in ini file.
Returns:
Whether or not returned value was read from ini file.

virtual COLORREF mbo::CIniData::GetColor ( const MboString strSection,
const MboString strKeyname,
COLORREF  colDefault = RGB(0, 0, 0),
bool  bWriteDefault = false 
) const [virtual]

Same as ReadColor but here the value (read or default) is returned.

Parameters:
strSection Name of section to search.
strKeyname Name of key to search.
colDefault Default value to use if key not present.
bWriteDefault Whether or not the default should be written to the ini file if key is not present in ini file.
Returns:
Value for key if found or default.

static COLORREF mbo::CIniData::GetIniColor ( const MboString strFilename,
const MboString strSection,
const MboString strKeyname,
COLORREF  colDefault = RGB(0, 0, 0),
bool  bWriteDefault = false 
) [static]

Same as GetColor but static from file without the need to first create a CIniData instance. Use this only if you access one single value.

Parameters:
strFilename Name of ini file to read.
strSection Name of section to search.
strKeyname Name of key to search.
colDefault Default value to use if key not present.
bWriteDefault Whether or not the default should be written to the ini file if key is not present in ini file.
Returns:
Value for key if found or default.

virtual bool mbo::CIniData::ReadMap ( const MboString strSection,
CStrMapStr msstrValue,
const CStrMapStr msstrDefault = CStrMapStr(),
bool  bWriteDefault = false,
bool  bWriteEmpty = false,
bool  bRetrieveAll = false 
) const [virtual]

Read a string map from strSection. When there is no such section stored in the file the default value msstrDefault is used. The function returns whether or not the map contains elements. The parameter bWriteDefault can be set true to ensure the ini directive exists after first read attempt in case it could not be found while reading. In that case this read function is no longer a const function.

This method requires that both key and values are string types and will return those pairs in a map (key - > value).

The return data will contain the default overwritten with the actual contents.

Parameters:
strSection Name of section to search.
Return values:
msstrValue Section Map if found or default.
Parameters:
msstrDefault Default value to use if key not present.
bWriteDefault Whether or not the default should be written to the ini file if section is not present in the ini file.
bWriteEmpty If the section is not present in the ini file this parameter determines wether or not empty values result in writing "key=" lines to the ini file.
bRetrieveAll Return comments and empty lines
Returns:
Whether or not returned data was read from ini file.

virtual CStrMapStr mbo::CIniData::GetMap ( const MboString strSection,
const CStrMapStr msstrDefault = CStrMapStr(),
bool  bWriteDefault = false,
bool  bWriteEmpty = false,
bool  bRetrieveAll = false 
) const [virtual]

Same as ReadMap but here the value (read or default) is returned.

Parameters:
strSection Name of section to search.
msstrDefault Default value to use if section not present.
bWriteDefault Whether or not the default should be written to the ini file if section is not present in the ini file.
bWriteEmpty If the section is not present in the ini file this parameter determines wether or not empty values result in writing "key=" lines to the ini file.
bRetrieveAll Return comments and empty lines
Returns:
String map read from ini file or default.
Note:
This method uses the copy constructor for the return value. This is slower compared to the ReadMap method which returns the result by reference. Hence it is defined deprecated.

static CStrMapStr mbo::CIniData::GetIniMap ( const MboString strFilename,
const MboString strSection,
const CStrMapStr msstrDefault = CStrMapStr(),
bool  bWriteDefault = false,
bool  bWriteEmpty = false 
) [static]

Same as GetMap but static from file without the need to first create a CIniData instance. Use this only if you access one single value.

Parameters:
strFilename Name of ini file to read.
strSection Name of section to search.
msstrDefault Default value to use if key not present.
bWriteDefault Whether or not the default should be written to the ini file if section is not present in the ini file.
bWriteEmpty If the section is not present in the ini file this parameter determines wether or not empty values result in writing "key=" lines to the ini file.
Returns:
String map read from ini file or default.
Note:
This method uses the copy constructor for the return value. This is slower compared to the ReadMap method which returns the result by reference. Hence it is defined deprecated.

virtual bool mbo::CIniData::ReadSectionList ( const MboString strSection,
CIniSectionList vsstrValue,
const CIniSectionList vsstrDefault = CIniSectionList(),
bool  bWriteDefault = false,
bool  bWriteEmpty = false,
bool  bRetrieveAll = false 
) const [virtual]

Read a CIniSectionList from strSection. When there is no such section in the file the default value msstrDefault is used. The function returns whether or not the map contains elements. The parameter bWriteDefault can be set true to ensure the ini directive exists after first read attempt in case it could not be found while reading. In that case this read function is no longer a const function.

This method requires that both key and values are string types and will return those pairs in a map (key - > value).

In contrast to ReadMap this function will return duplicate entries. It also does not return default entries if the section is not empty.

Parameters:
strSection Name of section to search.
Return values:
vsstrValue SectionList if found or default.
Parameters:
vsstrDefault Default value to use if key not present.
bWriteDefault Whether or not the default should be written to the ini file if section is not present in the ini file.
bWriteEmpty If the section is not present in the ini file this parameter determines wether or not empty values result in writing "key=" lines to the ini file.
bRetrieveAll Return comments and empty lines
Returns:
Whether or not returned data was read from ini file.

virtual bool mbo::CIniData::EmptySection ( const MboString strSection,
bool  bKeepComments = true 
) [virtual]

Empty specified section (delete entries).

Removes all "key=value" lines but not the section header "[name]". It can optionally keep the comments and empty lines.

Parameters:
strSection Name of section to delete.
bKeepComments Whether to keep comments in original section.
Returns:
Whether or not the operation succeeded.
Note:
Also true if section did not exist before call.

virtual bool mbo::CIniData::ClearSection ( const MboString strSection  )  [virtual]

Remove specified section completely.

Removes the section header "[name]" and all "key=value" lines.

Parameters:
strSection Name of section to delete.
Returns:
Whether or not the operation succeeded.
Note:
Also true if section did not exist before call.

virtual bool mbo::CIniData::DeleteKey ( const MboString strSection,
const MboString strKeyname 
) [virtual]

Delete specified key.

Removes the key "key" in section "[section]"

Parameters:
strSection Section to delete from.
strKeyname Name of Key to delete.
Returns:
Whether or not the operation succeeded.
Note:
If the sections becomes empty it is not being removed.

virtual bool mbo::CIniData::RenameKey ( const MboString strSection,
const MboString strKeynameOld,
const MboString strKeynameNew 
) [virtual]

Rename an existing key

Parameters:
strSection Section to delete from.
strKeynameOld old name of Key to rename
strKeynameNew new name of Key to rename
Returns:
Whether or not the operation succeeded. If the old key does not exist no new key will be added and the function returns false.

virtual bool mbo::CIniData::WriteString ( const MboString strSection,
const MboString strKeyname,
const MboString strValue 
) [virtual]

Store a MboString value into a specified section as given key.

Parameters:
strSection Section to write to (will be created if not present).
strKeyname Name of Key to update/create.
strValue Value to write.
Returns:
Whether or not the operation succeeded (value was written).

virtual bool mbo::CIniData::WriteInt ( const MboString strSection,
const MboString strKeyname,
int  nValue 
) [virtual]

Store an int value into a specified section as given key.

Parameters:
strSection Section to write to (will be created if not present).
strKeyname Name of Key to update/create.
nValue Value to write.
Returns:
Whether or not the operation succeeded (value was written).

virtual bool mbo::CIniData::WriteLong ( const MboString strSection,
const MboString strKeyname,
long  lValue 
) [virtual]

Store a long value into a specified section as given key.

Parameters:
strSection Section to write to (will be created if not present).
strKeyname Name of Key to update/create.
lValue Value to write.
Returns:
Whether or not the operation succeeded (value was written).

virtual bool mbo::CIniData::WriteFloat ( const MboString strSection,
const MboString strKeyname,
float  fValue 
) [virtual]

Store a float value into a specified section as given key.

Parameters:
strSection Section to write to (will be created if not present).
strKeyname Name of Key to update/create.
fValue Value to write.
Returns:
Whether or not the operation succeeded (value was written).

virtual bool mbo::CIniData::WriteDouble ( const MboString strSection,
const MboString strKeyname,
double  fValue 
) [virtual]

Store a double value into a specified section as given key.

Parameters:
strSection Section to write to (will be created if not present).
strKeyname Name of Key to update/create.
fValue Value to write.
Returns:
Whether or not the operation succeeded (value was written).

virtual bool mbo::CIniData::WriteBool ( const MboString strSection,
const MboString strKeyname,
bool  bValue 
) [virtual]

Store a boolean value into a specified section as given key.

Parameters:
strSection Section to write to (will be created if not present).
strKeyname Name of Key to update/create.
bValue Value to write.
Returns:
Whether or not the operation succeeded (value was written).

virtual bool mbo::CIniData::WriteColor ( const MboString strSection,
const MboString strKeyname,
COLORREF  colValue 
) [virtual]

Store a COLORREF value into a specified section as given key.

Parameters:
strSection Section to write to (will be created if not present).
strKeyname Name of Key to update/create.
colValue Value to write.
Returns:
Whether or not the operation succeeded (value was written).

virtual bool mbo::CIniData::WriteMap ( const MboString strSection,
CStrMapStr  msstrValue,
bool  bWriteEmpty = false,
bool  bKeepComments = true 
) [virtual]

Store string map msstrValue in section strSection. The optional parameter bWriteEmpty can be set true to force writing empty strings into the file.

Parameters:
strSection Section to write to (will be created if not present).
msstrValue String map to write as section.
bWriteEmpty Wether or not empty values result in writing "key=" lines.
bKeepComments Whether to keep comments in original section.
Returns:
Whether or not the operation succeeded (section was written).

virtual bool mbo::CIniData::WriteSectionList ( const MboString strSection,
CIniSectionList  vsstrValue,
bool  bWriteEmpty = false,
bool  bKeepComments = true 
) [virtual]

Store SectionList vsstrValue in section strSection. The optional parameter bWriteEmpty can be set true to force writing empty strings into the file.

In contrast to WriteMap this function allows to write duplicate entries.

Parameters:
strSection Section to write to (will be created if not present).
vsstrValue Section to write.
bWriteEmpty Wether or not empty values result in writing "key=" lines.
bKeepComments Whether to keep comments in original section.
Returns:
Whether or not the operation succeeded (section was written).

virtual bool mbo::CIniData::ReplaceSectionList ( const MboString strSection,
const CIniSectionList vsstrValue,
bool  bWriteEmpty = false 
) [virtual]

Store SectionList vsstrValue in section strSection. The optional parameter bWriteEmpty can be set true to force writing empty strings into the file.

In contrast to WriteMap this function allows to write duplicate entries. And unlike WriteSectionList it replaces the original contents of the section entirely.

Parameters:
strSection Section to write to (will be created if not present).
vsstrValue Section to write.
bWriteEmpty Wether or not empty values result in writing "key=" lines.
Returns:
Whether or not the operation succeeded (section was written).

bool mbo::CIniData::IsValidKey ( const MboString strKeyName,
bool  bAcceptComment = false 
) const

Verify key

Parameters:
strKeyName key to verify.
bAcceptComment whether comments are ok, if so only empty and invalid lines are not ok.
Returns:
whether key is valid.

mbo::CLock mbo::CIniData::IniDataGetLock (  )  const

Get Lock for instance

virtual bool mbo::CIniData::ReadFile (  )  [protected, virtual]

Clear cache and re-read file

virtual bool mbo::CIniData::IniDataFlush ( bool  bModified = false  )  const [protected, virtual]

Flush data to disk

Parameters:
bModified whether last operation modified contents
Returns:
success

bool mbo::CIniData::IsEmptyIniValue ( const TIniValue val  )  const [protected]

Returns:
whether a TIniValue is empty or not

TIniCache::iterator mbo::CIniData::GetSection ( const MboString strSection  )  [protected]

Parameters:
strSection name of requested section
Returns:
iterator to section or m_tCache.end()

TIniCache::const_iterator mbo::CIniData::GetSection ( const MboString strSection  )  const [protected]

Parameters:
strSection name of requested section
Returns:
const_iterator to section or m_tCache.end()

TIniCache::iterator mbo::CIniData::GetSectionOrCreate ( const MboString strSection  )  [protected]

Parameters:
strSection name of requested section
Returns:
iterator to section
Note:
section will be created at the end if it does not exist yet

TIniValue* mbo::CIniData::GetValuePtr ( const TIniCache::iterator &  itSection,
const MboString strKeyName 
) [protected]

Parameters:
itSection iterator to requested section
strKeyName name of key=value pair
Returns:
pointer to requested TIniValue or NULL

const TIniValue* mbo::CIniData::GetValuePtr ( const TIniCache::const_iterator &  itSection,
const MboString strKeyName 
) const [protected]

Parameters:
itSection iterator to requested section
strKeyName name of key=value pair
Returns:
pointer to requested TIniValue or NULL

TIniValue* mbo::CIniData::GetValuePtr ( const MboString strSection,
const MboString strKeyName 
) [protected]

Parameters:
strSection name of requested section
strKeyName name of key=value pair
Returns:
pointer to requested TIniValue or NULL

const TIniValue* mbo::CIniData::GetValuePtr ( const MboString strSection,
const MboString strKeyName 
) const [protected]

Parameters:
strSection name of requested section
strKeyName name of key=value pair
Returns:
pointer to requested TIniValue or NULL

TIniData::iterator mbo::CIniData::FindFirstEmpty ( TIniCache::iterator &  itSection  )  [protected]

Parameters:
itSection iterator to section
Returns:
iterator to first empty entry (backwards search)

TIniData::iterator mbo::CIniData::AddValue ( TIniCache::iterator &  itSection,
TIniData::iterator  itValue,
const MboString strKeyName,
const MboString strValue 
) [protected]

Add new entry into section at specific position

Parameters:
itSection iterator to requested section
itValue insert position
strKeyName name of key=value pair
strValue value of key=value pair

TIniData::iterator mbo::CIniData::AddValue ( TIniCache::iterator &  itSection,
const MboString strKeyName,
const MboString strValue 
) [protected]

Add new entry into section as last entry prior to empty lines

Parameters:
itSection iterator to requested section
strKeyName name of key=value pair
strValue value of key=value pair

TIniData::iterator mbo::CIniData::AddValue ( const MboString strSection,
const MboString strKeyName,
const MboString strValue 
) [protected]

Add new entry into section as last entry prior to empty lines

Parameters:
strSection name of requested section
strKeyName name of key=value pair
strValue value of key=value pair


The documentation for this class was generated from the following file:
  Hosted on code.google.com  
© Marcus Börger
Generated on Fri Jan 18 21:21:11 2008 for MBO-lib by doxygen 1.5.4