ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

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

#include <ini-file.h>

Collaboration diagram for Common::INIFile:

List of all members.

Classes

struct  KeyValue
struct  Section
 A section in a ini file. More...

Public Types

typedef List< KeyValueSectionKeyList
typedef List< SectionSectionList

Public Member Functions

 INIFile ()
 ~INIFile ()
void clear ()
 Reset everything stored in this ini file.
bool loadFromFile (const String &filename)
bool loadFromSaveFile (const String &filename)
bool loadFromStream (SeekableReadStream &stream)
bool saveToFile (const String &filename)
bool saveToSaveFile (const String &filename)
bool saveToStream (WriteStream &stream)
bool hasSection (const String &section) const
void addSection (const String &section)
void removeSection (const String &section)
void renameSection (const String &oldName, const String &newName)
bool hasKey (const String &key, const String &section) const
bool getKey (const String &key, const String &section, String &value) const
void setKey (const String &key, const String &section, const String &value)
void removeKey (const String &key, const String &section)
const SectionList getSections () const
const SectionKeyList getKeys (const String &section) const
void listKeyValues (StringMap &kv)

Static Public Member Functions

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

Private Member Functions

SectiongetSection (const String &section)
const SectiongetSection (const String &section) const

Private Attributes

SectionList _sections

Detailed Description

This class allows reading/writing INI style config files.

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

This class makes no attempts to provide fast access to key/value pairs. In particular, it stores all sections and k/v pairs in lists, not in dictionaries/maps. This makes it very easy to read/write the data from/to files, but of course is not appropriate for fast access. The main reason is that this class is indeed geared toward doing precisely that!

Definition at line 48 of file ini-file.h.


Member Typedef Documentation

Definition at line 56 of file ini-file.h.

Definition at line 77 of file ini-file.h.


Constructor & Destructor Documentation

Common::INIFile::INIFile (  ) 

Definition at line 38 of file ini-file.cpp.

Common::INIFile::~INIFile (  ) 

Definition at line 41 of file ini-file.cpp.


Member Function Documentation

void Common::INIFile::addSection ( const String section  ) 

Definition at line 229 of file ini-file.cpp.

void Common::INIFile::clear (  ) 

Reset everything stored in this ini file.

Definition at line 44 of file ini-file.cpp.

bool Common::INIFile::getKey ( const String key,
const String section,
String value 
) const

Definition at line 296 of file ini-file.cpp.

const INIFile::SectionKeyList Common::INIFile::getKeys ( const String section  )  const

Definition at line 332 of file ini-file.cpp.

INIFile::Section * Common::INIFile::getSection ( const String section  )  [private]

Definition at line 338 of file ini-file.cpp.

const INIFile::Section * Common::INIFile::getSection ( const String section  )  const [private]

Definition at line 347 of file ini-file.cpp.

const SectionList Common::INIFile::getSections (  )  const [inline]

Definition at line 113 of file ini-file.h.

bool Common::INIFile::hasKey ( const String key,
const String section 
) const

Definition at line 277 of file ini-file.cpp.

bool Common::INIFile::hasSection ( const String section  )  const

Definition at line 249 of file ini-file.cpp.

bool Common::INIFile::isValidName ( const String 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, white space and "#", "=", "[", "]" are not valid!

Definition at line 31 of file ini-file.cpp.

void Common::INIFile::listKeyValues ( StringMap kv  ) 
bool Common::INIFile::loadFromFile ( const String filename  ) 

Definition at line 48 of file ini-file.cpp.

bool Common::INIFile::loadFromSaveFile ( const String filename  ) 

Definition at line 56 of file ini-file.cpp.

bool Common::INIFile::loadFromStream ( SeekableReadStream stream  ) 

Definition at line 70 of file ini-file.cpp.

void Common::INIFile::removeKey ( const String key,
const String section 
)

Definition at line 287 of file ini-file.cpp.

void Common::INIFile::removeSection ( const String section  ) 

Definition at line 239 of file ini-file.cpp.

void Common::INIFile::renameSection ( const String oldName,
const String newName 
)

Definition at line 255 of file ini-file.cpp.

bool Common::INIFile::saveToFile ( const String filename  ) 

Definition at line 176 of file ini-file.cpp.

bool Common::INIFile::saveToSaveFile ( const String filename  ) 

Definition at line 184 of file ini-file.cpp.

bool Common::INIFile::saveToStream ( WriteStream stream  ) 

Definition at line 198 of file ini-file.cpp.

void Common::INIFile::setKey ( const String key,
const String section,
const String value 
)

Definition at line 310 of file ini-file.cpp.


Member Data Documentation

Definition at line 119 of file ini-file.h.


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


Generated on Sat Sep 21 2019 05:03:23 for ResidualVM by doxygen 1.7.1
curved edge   curved edge