SPH
Public Member Functions | Friends | List of all members
ConfigNode Class Reference

Represents a single node in the hierarchy written into config file. More...

#include <Config.h>

Public Member Functions

template<typename Type >
void set (const std::string &name, const Type &value)
 Adds a new value into the node. More...
 
template<typename Type >
Type get (const std::string &name)
 Returns a value stored in the node. More...
 
template<typename Type >
Optional< Type > tryGet (const std::string &name)
 Tries to return a value stored in the node. More...
 
bool contains (const std::string &name)
 Checks if the node contains an entry of given name. More...
 
Size size () const
 Returns the number of entries stored in the node. More...
 
SharedPtr< ConfigNodeaddChild (const std::string &name)
 Adds a new child node to this node. More...
 
SharedPtr< ConfigNodegetChild (const std::string &name)
 Returns a child node. More...
 
void enumerateChildren (Function< void(std::string name, ConfigNode &node)> func)
 Calls the provided functor for each child node. More...
 

Friends

class Config
 

Detailed Description

Represents a single node in the hierarchy written into config file.

Each node can store an arbitrary number of entries (as key-value pairs) and also a number of child nodes. Values are internally stored as strings, so it is necessary to specify the type of the value to read it.

Definition at line 198 of file Config.h.

Member Function Documentation

◆ addChild()

SharedPtr< ConfigNode > ConfigNode::addChild ( const std::string &  name)

Adds a new child node to this node.

Definition at line 21 of file Config.cpp.

◆ contains()

bool ConfigNode::contains ( const std::string &  name)
inline

Checks if the node contains an entry of given name.

Definition at line 243 of file Config.h.

◆ enumerateChildren()

void ConfigNode::enumerateChildren ( Function< void(std::string name, ConfigNode &node)>  func)

Calls the provided functor for each child node.

Definition at line 36 of file Config.cpp.

◆ get()

template<typename Type >
Type ConfigNode::get ( const std::string &  name)
inline

Returns a value stored in the node.

Exceptions
ConfigExceptionif the value does not exist or cannot be deserialized.

Definition at line 220 of file Config.h.

◆ getChild()

SharedPtr< ConfigNode > ConfigNode::getChild ( const std::string &  name)

Returns a child node.

Exceptions
ConfigExceptionif no such node exists.

Definition at line 25 of file Config.cpp.

◆ set()

template<typename Type >
void ConfigNode::set ( const std::string &  name,
const Type &  value 
)
inline

Adds a new value into the node.

Definition at line 211 of file Config.h.

◆ size()

Size ConfigNode::size ( ) const

Returns the number of entries stored in the node.

Definition at line 32 of file Config.cpp.

◆ tryGet()

template<typename Type >
Optional<Type> ConfigNode::tryGet ( const std::string &  name)
inline

Tries to return a value stored in the node.

If the value does not exist or cannot be deserialized, the function returns NOTHING.

Definition at line 232 of file Config.h.

Friends And Related Function Documentation

◆ Config

friend class Config
friend

Definition at line 199 of file Config.h.


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