nsnake
Classic snake game for the terminal
Public Types | Public Member Functions | Public Attributes | List of all members
INI::Level Struct Reference

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

#include <INI.hpp>

Collaboration diagram for INI::Level:
Collaboration graph
[legend]

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. More...
 
void addKey (std::string name, std::string value)
 Creates a new key #name with #value. More...
 

Public Attributes

Levelparent
 The parent Level of this one. More...
 
size_t depth
 Counter of how many nested levels this one is.
 
ValueMap values
 All the key values inside this Level. More...
 
SectionMap sections
 All the Levels inside this Level. More...
 
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 Function Documentation

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.

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.

Member Data Documentation

Level* INI::Level::parent

The parent Level of this one.

NULL for the topmost.

Definition at line 87 of file INI.hpp.

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.

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: