xoreos  0.0.5
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Common::ConfigFile Class Reference

This class allows reading/writing INI style config files. More...

#include <configfile.h>

Inheritance diagram for Common::ConfigFile:
Inheritance graph
[legend]
Collaboration diagram for Common::ConfigFile:
Collaboration graph
[legend]

Public Types

typedef PtrList< ConfigDomainDomainList
 

Public Member Functions

 ConfigFile ()
 
 ~ConfigFile ()
 
void clear ()
 Reset everything stored in this config file. More...
 
void load (SeekableReadStream &stream)
 
void save (WriteStream &stream) const
 
bool hasDomain (const UString &name) const
 
const DomainListgetDomains () const
 
ConfigDomaingetDomain (const UString &name)
 
const ConfigDomaingetDomain (const UString &name) const
 
ConfigDomainaddDomain (const UString &name)
 
bool removeDomain (const UString &name)
 
bool renameDomain (const UString &oldName, const UString &newName)
 

Static Public Member Functions

static bool isValidName (const UString &name)
 Check whether the given string is a valid section or key name. More...
 

Private Types

typedef std::map< UString, ConfigDomain *, UString::ilessDomainMap
 

Private Member Functions

void parseConfigLine (const UString &line, UString &domainName, UString &key, UString &value, UString &comment, int lineNumber)
 
void addDomainKey (ConfigDomain &domain, const UString &key, const UString &value, const UString &comment, int lineNumber)
 
void addDomain (ConfigDomain *domain, int lineNumber)
 

Private Attributes

DomainList _domainList
 List of domains in order. More...
 
DomainMap _domainMap
 Domains indexed by name. More...
 
UString _prologue
 Comments on top of the file. More...
 
UString _epilogue
 Comments at the bottom of the file. More...
 

Detailed Description

This class allows reading/writing INI style config files.

It is used by the ConfigManager for storage, but can also be used by other code if it needs to read/write custom INI files.

Lines starting with a '#' are ignored (i.e. treated as comments). Some effort is made to preserve comments, though.

Definition at line 113 of file configfile.h.

Member Typedef Documentation

◆ DomainList

Definition at line 115 of file configfile.h.

◆ DomainMap

Definition at line 147 of file configfile.h.

Constructor & Destructor Documentation

◆ ConfigFile()

Common::ConfigFile::ConfigFile ( )

Definition at line 257 of file configfile.cpp.

◆ ~ConfigFile()

Common::ConfigFile::~ConfigFile ( )

Definition at line 260 of file configfile.cpp.

Member Function Documentation

◆ addDomain() [1/2]

ConfigDomain * Common::ConfigFile::addDomain ( const UString name)

Definition at line 575 of file configfile.cpp.

References _domainList, _domainMap, and getDomain().

Referenced by load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addDomain() [2/2]

void Common::ConfigFile::addDomain ( ConfigDomain domain,
int  lineNumber 
)
private

Definition at line 407 of file configfile.cpp.

References _domainList, _domainMap, Common::ConfigDomain::_name, Common::UString::c_str(), and hasDomain().

Here is the call graph for this function:

◆ addDomainKey()

void Common::ConfigFile::addDomainKey ( ConfigDomain domain,
const UString key,
const UString value,
const UString comment,
int  lineNumber 
)
private

Definition at line 380 of file configfile.cpp.

References Common::ConfigDomain::_keys, Common::ConfigDomain::_lines, Common::ConfigDomain::_name, Common::UString::c_str(), Common::ConfigDomain::Line::comment, Common::UString::empty(), and Common::ConfigDomain::Line::key.

Referenced by load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

void Common::ConfigFile::clear ( )

Reset everything stored in this config file.

Definition at line 275 of file configfile.cpp.

References _domainList, _domainMap, _epilogue, _prologue, Common::PtrList< T, Deallocator >::clear(), and Common::UString::clear().

Here is the call graph for this function:

◆ getDomain() [1/2]

ConfigDomain * Common::ConfigFile::getDomain ( const UString name)

Definition at line 559 of file configfile.cpp.

References _domainMap.

Referenced by addDomain(), Engines::Jade::AreaLayout::currentRoom(), and Engines::Jade::AreaLayout::updateCamera().

Here is the caller graph for this function:

◆ getDomain() [2/2]

const ConfigDomain * Common::ConfigFile::getDomain ( const UString name) const

Definition at line 567 of file configfile.cpp.

References _domainMap.

◆ getDomains()

const ConfigFile::DomainList & Common::ConfigFile::getDomains ( ) const

Definition at line 555 of file configfile.cpp.

References _domainList.

◆ hasDomain()

bool Common::ConfigFile::hasDomain ( const UString name) const

Definition at line 551 of file configfile.cpp.

References _domainMap.

Referenced by addDomain().

Here is the caller graph for this function:

◆ isValidName()

bool Common::ConfigFile::isValidName ( const UString name)
static

Check whether the given string is a valid section or key name.

For that, it must only consist of letters, numbers, dashes and underscores. In particular, "#", "=", "[", "]" are not valid!

Definition at line 263 of file configfile.cpp.

References Common::UString::begin(), Common::UString::end(), and Common::UString::isASCII().

Referenced by load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load()

void Common::ConfigFile::load ( SeekableReadStream stream)

◆ parseConfigLine()

void Common::ConfigFile::parseConfigLine ( const UString line,
UString domainName,
UString key,
UString value,
UString comment,
int  lineNumber 
)
private

Definition at line 421 of file configfile.cpp.

References Common::UString::begin(), Common::UString::empty(), Common::UString::end(), and Common::UString::trim().

Referenced by load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeDomain()

bool Common::ConfigFile::removeDomain ( const UString name)

Definition at line 590 of file configfile.cpp.

References _domainList, _domainMap, and Common::PtrList< T, Deallocator >::remove().

Here is the call graph for this function:

◆ renameDomain()

bool Common::ConfigFile::renameDomain ( const UString oldName,
const UString newName 
)

Definition at line 603 of file configfile.cpp.

References _domainMap, and Common::ConfigDomain::_name.

◆ save()

void Common::ConfigFile::save ( WriteStream stream) const

Member Data Documentation

◆ _domainList

DomainList Common::ConfigFile::_domainList
private

List of domains in order.

Definition at line 149 of file configfile.h.

Referenced by addDomain(), clear(), getDomains(), removeDomain(), and save().

◆ _domainMap

DomainMap Common::ConfigFile::_domainMap
private

Domains indexed by name.

Definition at line 150 of file configfile.h.

Referenced by addDomain(), clear(), getDomain(), hasDomain(), removeDomain(), and renameDomain().

◆ _epilogue

UString Common::ConfigFile::_epilogue
private

Comments at the bottom of the file.

Definition at line 153 of file configfile.h.

Referenced by clear(), load(), and save().

◆ _prologue

UString Common::ConfigFile::_prologue
private

Comments on top of the file.

Definition at line 152 of file configfile.h.

Referenced by clear(), load(), and save().


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