NSConfigFile::TConfigFileSection Class Reference

This class represents one section from config file. More...

#include <ConfigFile.h>

Inheritance diagram for NSConfigFile::TConfigFileSection:

Inheritance graph
[legend]
Collaboration diagram for NSConfigFile::TConfigFileSection:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TConfigFileSection (const TString &sectionName)
 Constructor.
 ~TConfigFileSection (void)
 Destructor.
BOOL WriteToFile (TFile &file)
 Writes this section into file.
void Add (const TString &name, const TString &value)
 Adds new pair (name,value) to this section.
void Add (TConfigFileItem *item)
 Adds new pair (name,value) to this section.
const TStringGetValue (const TString &name) const
 Return value for specified item.
const char * GetValueAlt (const TString &name, const char *alternative) const
 Return value for specified item.
const char * GetValueFromSetOrAlt (const TString &name, const char **opts, const DWORD &optsCount, const char *alternative) const
 This method return value for specified property but also check if spcified value is in set of possible values.
DWORD GetValueFromSetOrAlt (const TString &name, const char **opts, const DWORD &optsCount, const DWORD &alternative) const
 This method return value for specified property but also check if specified value is in set of possible values.
void Remove (const TString &name)
 Remove specified item from section.
BOOL ExistsItem (const TString &name) const
 Determines whether specified item exists in this section.
BOOL GetValueINT (const TString &name, int &value) const
 Method converts value from specified item in this section to integer and store it in second parameter.
BOOL GetValueDWORD (const TString &name, DWORD &value) const
 Method converts value from specified item in this section to DWORD and store it in second parameter.
BOOL GetValueBOOL (const TString &name, BOOL &value) const
 Method converts value from specified item in this section to BOOL and store it in second parameter.
const TStringGetSectionName (void) const
 Return name of this section.
DWORD GetSize (void) const
 Returns number of items in this section.
const TStringGetName (const DWORD &index) const
 Returns name of item on specified index.
const TStringGetValue (const DWORD &index) const
 Returns value of item on specified index.

Detailed Description

This class represents one section from config file.

Section begin with [SECTION_NAME] and continue until next section or end of file.

Each item in section is in format "name_of_item" = "value_of_item" (quotation marks are required!!!).

Definition at line 76 of file ConfigFile.h.


Constructor & Destructor Documentation

NSConfigFile::TConfigFileSection::TConfigFileSection const TString sectionName  )  [inline]
 

Constructor.

Parameters:
sectionName [in] name of created section

Definition at line 117 of file ConfigFile.h.

NSConfigFile::TConfigFileSection::~TConfigFileSection void   )  [inline]
 

Destructor.

Definition at line 124 of file ConfigFile.h.


Member Function Documentation

void TConfigFileSection::Add TConfigFileItem item  ) 
 

Adds new pair (name,value) to this section.

Parameters:
item [in] item to add

Definition at line 64 of file ConfigFile.cpp.

References TArrayPtrs< T, size, step >::AddItem().

Here is the call graph for this function:

void TConfigFileSection::Add const TString name,
const TString value
 

Adds new pair (name,value) to this section.

Parameters:
name [in] name of added item
value [in] value of added item

Definition at line 54 of file ConfigFile.cpp.

References TArrayPtrs< T, size, step >::AddItem().

Here is the call graph for this function:

BOOL TConfigFileSection::ExistsItem const TString name  )  const
 

Determines whether specified item exists in this section.

Parameters:
name [in] name of specified item

Definition at line 222 of file ConfigFile.cpp.

References TArrayPtrs< T, size, step >::GetSize(), and TRUE.

Here is the call graph for this function:

const TString & NSConfigFile::TConfigFileSection::GetName const DWORD index  )  const [inline]
 

Returns name of item on specified index.

Index must be valid!!!

Parameters:
index [in] index of specified item

Definition at line 146 of file ConfigFile.h.

Referenced by NSMeshes::TDeclarationManager::Initialize().

const TString & NSConfigFile::TConfigFileSection::GetSectionName void   )  const [inline]
 

Return name of this section.

Definition at line 130 of file ConfigFile.h.

DWORD NSConfigFile::TConfigFileSection::GetSize void   )  const [inline]
 

Returns number of items in this section.

Definition at line 137 of file ConfigFile.h.

References TArrayPtrs< T, size, step >::GetSize().

Referenced by NSMeshes::TDeclarationManager::Initialize().

Here is the call graph for this function:

const TString & NSConfigFile::TConfigFileSection::GetValue const DWORD index  )  const [inline]
 

Returns value of item on specified index.

Index must be valid!!!

Parameters:
index [in] index of specified item

Definition at line 155 of file ConfigFile.h.

const TString * TConfigFileSection::GetValue const TString name  )  const
 

Return value for specified item.

Item is determined by its name. If given name doesnt exists then NULL is returned.

Parameters:
name [in] name of specified item

Definition at line 74 of file ConfigFile.cpp.

References TArrayPtrs< T, size, step >::GetSize().

Referenced by GetValueBOOL(), GetValueDWORD(), GetValueINT(), and NSMeshes::TDeclarationManager::Initialize().

Here is the call graph for this function:

const char * TConfigFileSection::GetValueAlt const TString name,
const char *  alternative
const
 

Return value for specified item.

Item is determined by its name. If given name doesnt exists then alternative is returned.

This method can be useful for explicit specifiyng result for missing values in configuration file.

Parameters:
name [in] name of specified item
alternative [in] alternative value returned if value with NAME was not found

Definition at line 100 of file ConfigFile.cpp.

References TArrayPtrs< T, size, step >::GetSize().

Referenced by NSConfigFile::TConfigFile::GetValueDirect().

Here is the call graph for this function:

BOOL TConfigFileSection::GetValueBOOL const TString name,
BOOL value
const
 

Method converts value from specified item in this section to BOOL and store it in second parameter.

Note:
Value "0" is converted to FALSE, others integral values are converted to TRUE. String is first converted to integer.

If there is no such item with name NAME or value is not valid BOOL then FALSE is returned and value VALUE won't be changed.

Parameters:
name [in] name of item in section
value [out] value stored in section Parameter won't be changed if method returns FALSE.

Definition at line 311 of file ConfigFile.cpp.

References FALSE, GetValue(), TString::ToInt(), and TRUE.

Here is the call graph for this function:

BOOL TConfigFileSection::GetValueDWORD const TString name,
DWORD value
const
 

Method converts value from specified item in this section to DWORD and store it in second parameter.

Note:
If there is no such item with name NAME or value is not valid DWORD then FALSE is returned and value VALUE won't be changed.
Parameters:
name [in] name of item in section
value [out] value stored in section Parameter won't be changed if method returns FALSE.

Definition at line 274 of file ConfigFile.cpp.

References FALSE, GetValue(), TString::ToInt(), and TRUE.

Here is the call graph for this function:

DWORD TConfigFileSection::GetValueFromSetOrAlt const TString name,
const char **  opts,
const DWORD optsCount,
const DWORD alternative
const
 

This method return value for specified property but also check if specified value is in set of possible values.

If not then alternative is returned.

This method returns number which specified zero-based index of alternative in array.

Parameters:
name [in] name of specified property
opts [in] set of possible options
optsCount [in] number of strings in array OPTS
alternative [in] alternative value returned if value with NAME was not found or if found value is not cointained inside set of possible values

Definition at line 169 of file ConfigFile.cpp.

References DBGASSERT, and TArrayPtrs< T, size, step >::GetSize().

Here is the call graph for this function:

const char * TConfigFileSection::GetValueFromSetOrAlt const TString name,
const char **  opts,
const DWORD optsCount,
const char *  alternative
const
 

This method return value for specified property but also check if spcified value is in set of possible values.

If not then alternative is returned.

Parameters:
name [in] name of specified property
opts [in] set of possible options
optsCount [in] number of strings in array OPTS
alternative [in] alternative value returned if value with NAME was not found or if found value is not cointained inside set of possible values

Definition at line 127 of file ConfigFile.cpp.

References DBGASSERT, and TArrayPtrs< T, size, step >::GetSize().

Referenced by NSConfigFile::TConfigFile::GetValueFromSetOrAlt().

Here is the call graph for this function:

BOOL TConfigFileSection::GetValueINT const TString name,
int &  value
const
 

Method converts value from specified item in this section to integer and store it in second parameter.

Note:
If there is no such item with name NAME or value is not valid integer then FALSE is returned and value VALUE won't be changed.
Parameters:
name [in] name of item in section
value [out] value stored in section Parameter won't be changed if method returns FALSE.

Definition at line 248 of file ConfigFile.cpp.

References FALSE, GetValue(), TString::ToInt(), and TRUE.

Here is the call graph for this function:

void TConfigFileSection::Remove const TString name  ) 
 

Remove specified item from section.

Parameters:
name [in] name of specified item

Definition at line 203 of file ConfigFile.cpp.

References TArrayPtrs< T, size, step >::GetSize(), and TArrayPtrs< T, size, step >::RemoveItemFast().

Here is the call graph for this function:

BOOL TConfigFileSection::WriteToFile TFile file  ) 
 

Writes this section into file.

After last item in section must followed '
'.

Parameters:
file [in] output file prepared for writing

Definition at line 24 of file ConfigFile.cpp.

References TArrayPtrs< T, size, step >::Count(), FALSE, TFile::PutChar(), and TFile::Write().

Here is the call graph for this function:


The documentation for this class was generated from the following files:
Generated on Wed Nov 28 22:44:28 2007 for Joy4D by  doxygen 1.4.6-NO