Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
Antares::IniFile Class Referencefinal

Data for an INI file. More...

#include <inifile.h>

Classes

class  Property
 A single entry in an INI file. More...
 
class  Section
 A single section, with all its keys. More...
 

Public Member Functions

Constructor & Destructor
 IniFile ()=default
 Default Constructor.
 
 IniFile (const std::filesystem::path &filename)
 Load an INI file.
 
 ~IniFile ()
 Destructor.
 
Load / Save
void clear ()
 Empty the INI File.
 
bool loaded () const
 Get if the INI file has been loaded/written.
 
bool open (const std::string &filename, bool warnings=true)
 Load an INI file.
 
bool open (const std::filesystem::path &filename, bool warnings=true)
 
bool readStream (std::istream &in_stream)
 
bool save (const AnyString &filename) const
 Save the entire INI into a file.
 
void saveToStream (std::ostream &, uint64_t &) const
 
std::string toString () const
 
const std::string & filename () const
 Get the last filename saved or loaded.
 

Sections

SectionfirstSection = nullptr
 
SectionlastSection = nullptr
 
Sectionadd (Section *s)
 Add an existing section into the INI structure.
 
SectionaddSection (const AnyString &name)
 Create a new section.
 
bool empty () const
 Get if the inifile is empty.
 
Sectionfind (const AnyString &name)
 Try to find a section by its name.
 
const Sectionfind (const AnyString &name) const
 Try to find a section by its name (const)
 
template<class CallbackT >
void each (const CallbackT &callback)
 Iterate through all sections.
 
template<class CallbackT >
void each (const CallbackT &callback) const
 Iterate through all sections (const)
 
template<class CallbackT >
void properties (const CallbackT &callback)
 Iterate through all properties of all sections.
 
template<class CallbackT >
void properties (const CallbackT &callback) const
 Iterate through all properties of all sections (const)
 

Detailed Description

Data for an INI file.

Member Function Documentation

◆ each() [1/2]

template<class CallbackT >
void Antares::IniFile::each ( const CallbackT & callback)

Iterate through all sections.

IniFile ini;
if (ini.open("/tmp/test.ini"))
{
ini.each([&] (IniFile::Section& section)
{
std::cout << section.name << std::endl;
});
}
A single section, with all its keys.
Definition inifile.h:67
Yuni::ShortString256 name
The name of the section.
Definition inifile.h:152
Data for an INI file.
Definition inifile.h:34
void each(const CallbackT &callback)
Iterate through all sections.
Definition inifile.hxx:99
bool open(const std::string &filename, bool warnings=true)
Load an INI file.
Definition inifile.cpp:238

◆ each() [2/2]

template<class CallbackT >
void Antares::IniFile::each ( const CallbackT & callback) const

Iterate through all sections (const)

IniFile ini;
if (ini.open("/tmp/test.ini"))
{
ini.each([&] (const IniFile::Section& section)
{
std::cout << section.name << std::endl;
});
}

◆ open()

bool Antares::IniFile::open ( const std::string & filename,
bool warnings = true )

Load an INI file.

Parameters
filenameFilename to load
Returns
True if the operation succeeded, false otherwise

◆ properties() [1/2]

template<class CallbackT >
void Antares::IniFile::properties ( const CallbackT & callback)

Iterate through all properties of all sections.

IniFile ini;
if (ini.open("/tmp/test.ini"))
{
ini.properties([&] (const IniFile::Section& section, const IniFile::Property& property)
{
std::cout << section.name << ": " << property.key << " = " << property.value <<
'\n'; * });
}
A single entry in an INI file.
Definition inifile.h:43
void properties(const CallbackT &callback)
Iterate through all properties of all sections.
Definition inifile.hxx:135

◆ properties() [2/2]

template<class CallbackT >
void Antares::IniFile::properties ( const CallbackT & callback) const

Iterate through all properties of all sections (const)

IniFile ini;
if (ini.open("/tmp/test.ini"))
{
ini.properties([&] (const IniFile::Section& section, const IniFile::Property& property)
{
std::cout << section.name << ": " << property.key << " = " << property.value <<
'\n'; * });
}

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