nsnake
Classic snake game for the terminal
Loading...
Searching...
No Matches
INI::Level Struct Reference

Contains a "scope" of the INI file. More...

#include <INI.hpp>

Collaboration diagram for INI::Level:

Public Types

typedef std::map< std::string, std::string > ValueMap
 
typedef std::map< std::string, LevelSectionMap
 
typedef std::list< ValueMap::const_iterator > Values
 
typedef std::list< SectionMap::const_iterator > Sections
 

Public Member Functions

 Level ()
 Create the topmost Level.
 
 Level (Level *p)
 Create a level with parent #p.
 
const std::string & operator[] (const std::string &name)
 Access a key within this Level.
 
Leveloperator() (const std::string &name)
 Access another Level within this Level.
 
void addGroup (std::string name)
 Creates a new child group with #name.
 
void addKey (std::string name, std::string value)
 Creates a new key #name with #value.
 

Public Attributes

Levelparent
 The parent Level of this one.
 
size_t depth
 Counter of how many nested levels this one is.
 
ValueMap values
 All the key values inside this Level.
 
SectionMap sections
 All the Levels inside this Level.
 
Values ordered_values
 All values in the original order of the INI file.
 
Sections ordered_sections
 All Sections in the original order of the INI file.
 

Detailed Description

Contains a "scope" of the INI file.

Suppose an INI file like this:

key=value
[group]
key=value
[[group2]]
key=value
[[[group3]]
key=value

We have four Levels, group, group2 and group3 and the top level, which contains all other levels.

You access keys with the [] operator and child groups with the () operator. So, for the example above:

parser.top()("group")("group2")("group3")["key"] == "value"

Definition at line 71 of file INI.hpp.

Member Typedef Documentation

◆ SectionMap

std::map<std::string, Level> INI::Level::SectionMap

Definition at line 93 of file INI.hpp.

◆ Sections

std::list<SectionMap::const_iterator> INI::Level::Sections

Definition at line 95 of file INI.hpp.

◆ ValueMap

std::map<std::string, std::string> INI::Level::ValueMap

Definition at line 92 of file INI.hpp.

◆ Values

std::list<ValueMap::const_iterator> INI::Level::Values

Definition at line 94 of file INI.hpp.

Constructor & Destructor Documentation

◆ Level() [1/2]

INI::Level::Level ( )
inline

Create the topmost Level.

Definition at line 74 of file INI.hpp.

◆ Level() [2/2]

INI::Level::Level ( Level * p)
inline

Create a level with parent #p.

Definition at line 80 of file INI.hpp.

Member Function Documentation

◆ addGroup()

void INI::Level::addGroup ( std::string name)

Creates a new child group with #name.

Note
If it already exists, do nothing.
Inside this method we trim name of spaces and tabs.

Definition at line 4 of file INI.cpp.

◆ addKey()

void INI::Level::addKey ( std::string name,
std::string value )

Creates a new key #name with #value.

Note
If the key already exists will overwrite it's value.
Inside this method we trim name and value of spaces and tabs.

Definition at line 27 of file INI.cpp.

◆ operator()()

Level & INI::Level::operator() ( const std::string & name)
inline

Access another Level within this Level.

Definition at line 135 of file INI.hpp.

◆ operator[]()

const std::string & INI::Level::operator[] ( const std::string & name)
inline

Access a key within this Level.

Definition at line 129 of file INI.hpp.

Member Data Documentation

◆ depth

size_t INI::Level::depth

Counter of how many nested levels this one is.

Definition at line 90 of file INI.hpp.

◆ ordered_sections

Sections INI::Level::ordered_sections

All Sections in the original order of the INI file.

Definition at line 126 of file INI.hpp.

◆ ordered_values

Values INI::Level::ordered_values

All values in the original order of the INI file.

Definition at line 123 of file INI.hpp.

◆ parent

Level* INI::Level::parent

The parent Level of this one.

NULL for the topmost.

Definition at line 87 of file INI.hpp.

◆ sections

SectionMap INI::Level::sections

All the Levels inside this Level.

So for an INI like this:

[group]
[group2]
key=value

This would return "value":

level.sections["group2"].values["key"]

Definition at line 120 of file INI.hpp.

◆ values

ValueMap INI::Level::values

All the key values inside this Level.

So for an INI like this:

[group]
key=value

This would return "value":

level.values["key"]

Definition at line 107 of file INI.hpp.


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