NSConfigFile::TConfigFile Class Reference

This class represents parser for configuration file. More...

#include <ConfigFile.h>

Inheritance diagram for NSConfigFile::TConfigFile:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TConfigFile (void)
 Default constructor.
BOOL LoadConfigFile (const TString &filename)
 Parse specified config file with given syntax.
BOOL SaveConfigFile (const TString &filename)
 Save actual configuration into file with specified name.
BOOL LoadConfigFileFromVFS (const TString &filename)
 Parse specified config file with given syntax loaded from VFS.
DWORD GetSectionCount (void) const
 Return number of sections in loaded file.
const TConfigFileSectionGetSection (const TString &name) const
 Return section determined by its name.
const TConfigFileSectionGetSection (const DWORD &index) const
 Return section determined by its index.
const char * GetValueDirect (const TString &sectionName, const TString &name, const char *alternative) const
 This method provides quick way to get value from specified section.
const char * GetValueFromSetOrAlt (const TString &sectionName, const TString &name, const char **opts, const DWORD &optsCount, const char *alternative) const
 This method provides quick way to get value from specified section.
DWORD GetValueFromSetOrAlt (const TString &sectionName, const TString &name, const char **opts, const DWORD &optsCount, const DWORD &alternative) const
 This method provides quick way to get value from specified section.

Detailed Description

This class represents parser for configuration file.

Warning:
Class do not use VFS !!!
Configuration file has this syntax:
[SECTION 1]
"name" = "value"	;comment to end of line or EOF if this is last line in file
"name" = "value"
"name" = "value"	;comment
[SECTION 2]
"name" = "value"
"name" = "value"
"name" = "value"
.
.
.

Definition at line 185 of file ConfigFile.h.


Constructor & Destructor Documentation

NSConfigFile::TConfigFile::TConfigFile void   )  [inline]
 

Default constructor.

Definition at line 228 of file ConfigFile.h.


Member Function Documentation

const TConfigFileSection * TConfigFile::GetSection const DWORD index  )  const
 

Return section determined by its index.

Index must be valid!!!.

Parameters:
index [in] index of given section

Definition at line 580 of file ConfigFile.cpp.

const TConfigFileSection * TConfigFile::GetSection const TString name  )  const
 

Return section determined by its name.

If section with given name doesnt exists NULL is returned.

Parameters:
name [in] name of given section

Definition at line 562 of file ConfigFile.cpp.

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

Referenced by GetValueDirect(), GetValueFromSetOrAlt(), and NSMeshes::TDeclarationManager::Initialize().

Here is the call graph for this function:

DWORD NSConfigFile::TConfigFile::GetSectionCount void   )  const [inline]
 

Return number of sections in loaded file.

Definition at line 234 of file ConfigFile.h.

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

Here is the call graph for this function:

const char * TConfigFile::GetValueDirect const TString sectionName,
const TString name,
const char *  alternative
const
 

This method provides quick way to get value from specified section.

You provide name of section and property name and method returns value.

If property or section are not found then ALTERNATIVE is returned.

Parameters:
sectionName [in] name of section where property with given name should be searched
name [in] name of wanted property
alternative [in] value which is returned if wanted property was not found

Definition at line 594 of file ConfigFile.cpp.

References GetSection(), and NSConfigFile::TConfigFileSection::GetValueAlt().

Here is the call graph for this function:

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

This method provides quick way to get value from specified section.

You provide name of section and property name and method returns value. Returned value is zero-based index of given option stored in array (or ALTERNATIVE)

If property or section are not found then ALTERNATIVE is returned.

Method also check if found value belongs to specified set of possible options. If not then alternative is returned.

Parameters:
sectionName [in] name of section where property with given name should be searched
name [in] name of wanted property
opts [in] set of possible options
optsCount [in] number of items in array OPTS
alternative [in] value which is returned if wanted property was not found

Definition at line 628 of file ConfigFile.cpp.

References GetSection(), and NSConfigFile::TConfigFileSection::GetValueFromSetOrAlt().

Here is the call graph for this function:

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

This method provides quick way to get value from specified section.

You provide name of section and property name and method returns value.

If property or section are not found then ALTERNATIVE is returned.

Method also check if found value belongs to specified set of possible options. If not then alternative is returned. Array of options must be terminated by NULL!!!

Parameters:
sectionName [in] name of section where property with given name should be searched
name [in] name of wanted property
opts [in] set of possible options
optsCount [in] number of items in array OPTS
alternative [in] value which is returned if wanted property was not found

Definition at line 663 of file ConfigFile.cpp.

References GetSection(), and NSConfigFile::TConfigFileSection::GetValueFromSetOrAlt().

Here is the call graph for this function:

BOOL TConfigFile::LoadConfigFile const TString filename  ) 
 

Parse specified config file with given syntax.

Parameters:
filename [in] name of file with config file

Definition at line 335 of file ConfigFile.cpp.

References TArrayPtrs< T, size, step >::ClearDeallocOff(), DBGNL, DBGTEXT, DBGTEXTF, FALSE, TString::GetString(), and TFile::Open().

Referenced by TGlobalsSystem::Initialize().

Here is the call graph for this function:

BOOL TConfigFile::LoadConfigFileFromVFS const TString filename  ) 
 

Parse specified config file with given syntax loaded from VFS.

Warning:
This method requires VFS.
Parameters:
filename [in] name of file with config file - file is from VFS

Definition at line 690 of file ConfigFile.cpp.

References TArrayPtrs< T, size, step >::ClearDeallocOff(), DBGNL, DBGTEXT, DBGTEXTF, FALSE, NSFileSystem::TFSFileSystem::GetFile(), TGlobalsSystem::GetFileSystem(), TString::GetString(), and NSFileSystem::TVirtualFileAutoPtr< T >::IsNULL().

Here is the call graph for this function:

BOOL TConfigFile::SaveConfigFile const TString filename  ) 
 

Save actual configuration into file with specified name.

Parameters:
filename [in] name of output file

Definition at line 384 of file ConfigFile.cpp.

References FALSE, and TFile::Open().

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:39 2007 for Joy4D by  doxygen 1.4.6-NO