Anklang C++ API 0.0.0
Loading...
Searching...
No Matches
IniFile

#include "inifile.hh"

Public Member Functions

StringSattributes (const String &section) const
boolhas_attribute (const String &section, const String &key) const
boolhas_raw_value (const String &dotpath, String *valuep=NULL) const
boolhas_section (const String &section) const
boolhas_sections () const
boolhas_value (const String &dotpath, String *valuep=NULL) const
IniFile (Blob blob)
IniFile (const IniFile &source)
IniFile (const String &name, const String &inidata)
IniFile &operator= (const IniFile &source)
Stringraw_value (const String &dotpath) const
StringSraw_values () const
StringSsections () const
Stringvalue_as_string (const String &dotpath) const

Static Public Member Functions

static Stringcook_string (const String &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"

Constructor & Destructor Documentation

IniFile() [1/3]

IniFile ( const String & name,
const String & inidata
)
explicit

Load INI file from immediate `data`.

IniFile() [2/3]

IniFile ( Blob blob)
explicit

Load INI file from Blob.

IniFile() [3/3]

IniFile ( const IniFile & source)
explicit

Copy constructor.

Member Function Documentation

operator=()

IniFile & operator= ( const IniFile & source)

Assignment operator.

has_sections()

bool has_sections ( ) const

Checks if IniFile is non-empty.

sections()

StringS sections ( ) const

List all sections.

has_section()

bool has_section ( const String & section) const

Check presence of a section.

attributes()

StringS attributes ( const String & section) const

List all attributes available in `section`.

has_attribute()

bool has_attribute ( const String & section,
const String & key
) const

Return if `section` contains `key`.

has_raw_value()

bool has_raw_value ( const String & dotpath,
String * valuep = NULL
) const

Check and possibly retrieve raw value if present.

raw_value()

String raw_value ( const String & dotpath) const

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

raw_values()

StringS raw_values ( ) const

List all section.attribute=value pairs.

value_as_string()

String value_as_string ( const String & dotpath) const

Retrieve value of section.attribute[locale].

has_value()

bool has_value ( const String & dotpath,
String * valuep = NULL
) const

Check and possibly retrieve value if present.

cook_string()

String cook_string ( const String & input_string)
static

Unquote contents of `input_string`.