Anklang 0.3.0-460-gc4ef46ba
ASE — Anklang Sound Engine (C++)

« « « Anklang Documentation
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
Ase::IniFile Class Reference

Class to parse INI configuration file sections and values. More...

#include "inifile.hh"

Public Member Functions

 IniFile (const String &name, const String &inidata)
 Load INI file from immediate data.
 
 IniFile (Blob blob)
 Load INI file from Blob.
 
 IniFile (const IniFile &source)
 Copy constructor.
 
IniFileoperator= (const IniFile &source)
 Assignment operator.
 
bool has_sections () const
 Checks if IniFile is non-empty.
 
StringS sections () const
 List all sections.
 
bool has_section (const String &section) const
 Check presence of a section.
 
StringS attributes (const String &section) const
 List all attributes available in section.
 
bool has_attribute (const String &section, const String &key) const
 Return if section contains key.
 
bool has_raw_value (const String &dotpath, String *valuep=NULL) const
 Check and possibly retrieve raw value if present.
 
String raw_value (const String &dotpath) const
 Retrieve raw (uncooked) value of section.attribute[locale].
 
StringS raw_values () const
 List all section.attribute=value pairs.
 
String value_as_string (const String &dotpath) const
 Retrieve value of section.attribute[locale].
 
bool has_value (const String &dotpath, String *valuep=NULL) const
 Check and possibly retrieve value if present.
 

Static Public Member Functions

static String cook_string (const String &input_string)
 Unquote contents of input_string
 

Detailed Description

Class to parse INI configuration file sections and values.

This class parses configuration files, commonly known as INI files. The files contain "[Section]" markers and "attribute=value" definitions. Comment lines are preceeded by a hash "#" sign. For a detailed reference, see: http://wikipedia.org/wiki/INI_file
To write INI files, refer to the IniWriter class. Localization of attributes is supported with the "attribute[locale]=value" syntax, in accordance with the desktop file spec: http://freedesktop.org/Standards/desktop-entry-spec
Example:

[Section]
key = value # definition of Section.key = "value"
name = "quoted string with \n newlines and spaces"

Definition at line 11 of file inifile.hh.

Constructor & Destructor Documentation

◆ IniFile() [1/3]

Ase::IniFile::IniFile ( const String name,
const String inidata 
)
explicit

Load INI file from immediate data.

Definition at line 321 of file inifile.cc.

References std::map::empty(), and Ase::string_to_cquote().

◆ IniFile() [2/3]

Ase::IniFile::IniFile ( Blob  blob)
explicit

Load INI file from Blob.

Definition at line 328 of file inifile.cc.

References std::map::empty(), Ase::Blob::name(), Ase::Blob::string(), and Ase::string_to_cquote().

◆ IniFile() [3/3]

Ase::IniFile::IniFile ( const IniFile source)
explicit

Copy constructor.

Definition at line 336 of file inifile.cc.

Member Function Documentation

◆ attributes()

StringS Ase::IniFile::attributes ( const String section) const

List all attributes available in section.

Definition at line 381 of file inifile.cc.

References std::map::end(), std::map::find(), and std::vector::push_back().

◆ cook_string()

String Ase::IniFile::cook_string ( const String input_string)
static

Unquote contents of input_string

Definition at line 444 of file inifile.cc.

References std::string::c_str(), and Ase::string_from_cquote().

Referenced by has_value(), and value_as_string().

◆ has_attribute()

bool Ase::IniFile::has_attribute ( const String section,
const String key 
) const

Return if section contains key.

Definition at line 392 of file inifile.cc.

References std::string::data(), std::map::end(), std::map::find(), memcmp(), and std::string::size().

◆ has_raw_value()

bool Ase::IniFile::has_raw_value ( const String dotpath,
String valuep = NULL 
) const

Check and possibly retrieve raw value if present.

Definition at line 414 of file inifile.cc.

References std::string::c_str(), memcmp(), std::string::size(), std::vector::size(), strrchr(), and std::string::substr().

Referenced by has_value(), and raw_value().

◆ has_section()

bool Ase::IniFile::has_section ( const String section) const

Check presence of a section.

Definition at line 365 of file inifile.cc.

References std::map::end(), and std::map::find().

◆ has_sections()

bool Ase::IniFile::has_sections ( ) const

Checks if IniFile is non-empty.

Definition at line 349 of file inifile.cc.

References std::map::empty().

◆ has_value()

bool Ase::IniFile::has_value ( const String dotpath,
String valuep = NULL 
) const

Check and possibly retrieve value if present.

Definition at line 483 of file inifile.cc.

References cook_string(), and has_raw_value().

◆ operator=()

IniFile & Ase::IniFile::operator= ( const IniFile source)

Assignment operator.

Definition at line 342 of file inifile.cc.

◆ raw_value()

String Ase::IniFile::raw_value ( const String dotpath) const

Retrieve raw (uncooked) value of section.attribute[locale].

Definition at line 436 of file inifile.cc.

References has_raw_value().

Referenced by value_as_string().

◆ raw_values()

StringS Ase::IniFile::raw_values ( ) const

List all section.attribute=value pairs.

Definition at line 404 of file inifile.cc.

References std::vector::push_back().

◆ sections()

StringS Ase::IniFile::sections ( ) const

List all sections.

Definition at line 372 of file inifile.cc.

References std::vector::push_back().

◆ value_as_string()

String Ase::IniFile::value_as_string ( const String dotpath) const

Retrieve value of section.attribute[locale].

Definition at line 492 of file inifile.cc.

References cook_string(), and raw_value().


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