|
libmx2 2.2.1
C++20 multimedia and game-engine library (SDL2 / OpenGL / Vulkan)
|
Parses and manages an INI-style configuration file. More...
#include <cfg.hpp>
Public Member Functions | |
| ConfigFile ()=default | |
| Default constructor — no file loaded. | |
| ConfigFile (const std::string &filex) | |
| Open and parse a configuration file. | |
| ~ConfigFile () | |
| Destructor — closes any open file resources. | |
| ConfigFile (const ConfigFile &)=delete | |
| ConfigFile & | operator= (const ConfigFile &)=delete |
| ConfigFile (ConfigFile &&)=delete | |
| ConfigFile & | operator= (ConfigFile &&)=delete |
| Item | itemAtKey (const std::string §ion, const std::string &key) |
| Retrieve a configuration item by section and key. | |
| void | setItem (const std::string §ion, const std::string &key, const std::string value) |
| Insert or update a configuration item. | |
| void | loadFile (const std::string &f) |
| Load (or reload) a configuration file from disk. | |
| void | saveFile (const std::string &f2) |
| Save the current configuration to a file. | |
| std::vector< std::string > | splitByComma (const std::string &str) |
| Split a string on comma delimiters. | |
Private Attributes | |
| std::unordered_map< std::string, std::unordered_map< std::string, Item > > | values |
| std::string | filename |
Parses and manages an INI-style configuration file.
Sections are denoted by [SectionName] headers. Items within a section are stored as key=value pairs. The file can be loaded, queried, modified in memory, and saved back to disk.
|
default |
Default constructor — no file loaded.
Referenced by ConfigFile(), ConfigFile(), operator=(), and operator=().
| mx::ConfigFile::ConfigFile | ( | const std::string & | filex | ) |
Open and parse a configuration file.
| filex | Path to the configuration file. |
Definition at line 104 of file cfg.cpp.
References filename, and loadFile().
| mx::ConfigFile::~ConfigFile | ( | ) |
Destructor — closes any open file resources.
Definition at line 108 of file cfg.cpp.
References filename, and saveFile().
|
delete |
References ConfigFile().
|
delete |
References ConfigFile().
| Item mx::ConfigFile::itemAtKey | ( | const std::string & | section, |
| const std::string & | key ) |
| void mx::ConfigFile::loadFile | ( | const std::string & | f | ) |
Load (or reload) a configuration file from disk.
| f | Path to the file. |
Definition at line 12 of file cfg.cpp.
References mx::Item::key, mx::Item::value, and values.
Referenced by ConfigFile().
|
delete |
References ConfigFile().
|
delete |
References ConfigFile().
| void mx::ConfigFile::saveFile | ( | const std::string & | f2 | ) |
Save the current configuration to a file.
| f2 | Destination file path. |
Definition at line 46 of file cfg.cpp.
References mx::keys, and values.
Referenced by ~ConfigFile().
| void mx::ConfigFile::setItem | ( | const std::string & | section, |
| const std::string & | key, | ||
| const std::string | value ) |
| std::vector< std::string > mx::ConfigFile::splitByComma | ( | const std::string & | str | ) |
|
private |
Definition at line 39 of file cfg.hpp.
Referenced by ConfigFile(), and ~ConfigFile().
|
private |
Definition at line 38 of file cfg.hpp.
Referenced by itemAtKey(), loadFile(), saveFile(), and setItem().