AnCH Framework 0.1
Another C++ Hack Framework
Loading...
Searching...
No Matches
anch::ini::Section Class Reference

INI file section. More...

#include <section.hpp>

Collaboration diagram for anch::ini::Section:

Public Member Functions

 Section ()
 Section (const Section &section)
 Section (Section &&section)
virtual ~Section ()
const std::map< std::string, Section > & getSections () const
const std::map< std::string, std::string > & getValues () const
template<typename T>
std::optional< T > getValue (const std::string &key) const
template<typename T>
getValue (const std::string &key, const T &defaultValue) const
Sectionsection (const std::string &key)
SectionputValue (const std::string &key, const std::string &value)
std::string debug () const
Sectionoperator= (const Section &other)

Static Public Member Functions

static std::optional< std::string > getValue (const std::string &path, const Section &section)

Detailed Description

INI file section.

INI file section description

Author
Vincent Lachenal
Since
0.1

Constructor & Destructor Documentation

◆ Section() [1/3]

anch::ini::Section::Section ( )

Section default constructor

◆ Section() [2/3]

anch::ini::Section::Section ( const Section & section)

Section copy constructor

Parameters
sectionthe Section to copy
Here is the call graph for this function:

◆ Section() [3/3]

anch::ini::Section::Section ( Section && section)

Section move constructor

Parameters
sectionthe Section to move
Here is the call graph for this function:

◆ ~Section()

virtual anch::ini::Section::~Section ( )
virtual

Section destructor

Member Function Documentation

◆ debug()

std::string anch::ini::Section::debug ( ) const

Print section for debug

Returns
the section as string

◆ getSections()

const std::map< std::string, Section > & anch::ini::Section::getSections ( ) const

Subsections getter

Returns
the sections

◆ getValue() [1/3]

template<typename T>
std::optional< T > anch::ini::Section::getValue ( const std::string & key) const

Get value and cast it into T

Parameters
keythe value's key
Returns
empty optional value when not found, the value otherwise
Exceptions

ref std::bad_cast exception on cast error

◆ getValue() [2/3]

template<typename T>
T anch::ini::Section::getValue ( const std::string & key,
const T & defaultValue ) const

Get value and cast it into T

Parameters
keythe value's key
defaultValuedefault value when not found
Returns
default value when not found, the value otherwise
Exceptions

ref std::bad_cast exception on cast error

◆ getValue() [3/3]

std::optional< std::string > anch::ini::Section::getValue ( const std::string & path,
const Section & section )
static

Get value from path.
Path is composed by (sub)sections delimited by '.' and key as last token.

Parameters
paththe key's path to search
sectionthe current section
Returns
the std::string value when found, empty otherwise
Here is the call graph for this function:

◆ getValues()

const std::map< std::string, std::string > & anch::ini::Section::getValues ( ) const

Values getter

Returns
the values

◆ operator=()

Section & anch::ini::Section::operator= ( const Section & other)

Simple assignment operator

Parameters
otherthe Section to copy
Returns
this
Here is the call graph for this function:

◆ putValue()

Section & anch::ini::Section::putValue ( const std::string & key,
const std::string & value )

Put value referenced by key into current section.
It will override existiing value.

Parameters
keythe key
valuethe value
Returns
this
Here is the call graph for this function:

◆ section()

Section & anch::ini::Section::section ( const std::string & key)

Create new Section or return already exists Section

Parameters
keythe section name
Returns
the Section
Here is the call graph for this function:

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