Read scalar values from a bounded, section-based INI file. More...
#include <ini_file.h>
Public Member Functions | |
| IniFile (const std::filesystem::path &path) | |
| Parse an INI file into unique section-qualified keys. | |
| void | validate (std::initializer_list< const char * > allowed) const |
| Reject keys not owned by the caller's configuration schema. | |
| bool | has (const std::string &key) const |
| Test whether a section-qualified key was present in the file. | |
| std::string | text (const std::string &key, const std::string &fallback={}) const |
| Read text or return a fallback when the key is absent. | |
| double | numeric (const std::string &key, double fallback) const |
Read a finite numeric value, using fallback only when absent. | |
| double | required (const std::string &key) const |
| Read a required finite numeric value. | |
| bool | boolean (const std::string &key, bool fallback=false) const |
| Read a strict numeric boolean whose only accepted values are 0 and 1. | |
Private Attributes | |
| std::map< std::string, std::string > | values_ |
Detailed Description
Read scalar values from a bounded, section-based INI file.
Keys are stored as section.name; duplicate and empty settings are rejected during construction. Call validate with the owning schema's allow-list before consuming values.
Definition at line 38 of file ini_file.h.
Constructor & Destructor Documentation
◆ IniFile()
|
inlineexplicit |
Parse an INI file into unique section-qualified keys.
- Parameters
-
[in] path Input file path.
- Exceptions
-
std::runtime_error If the file is unreadable or malformed.
Definition at line 46 of file ini_file.h.
Member Function Documentation
◆ boolean()
|
inline |
Read a strict numeric boolean whose only accepted values are 0 and 1.
Definition at line 98 of file ini_file.h.
◆ has()
|
inline |
Test whether a section-qualified key was present in the file.
Definition at line 82 of file ini_file.h.
◆ numeric()
|
inline |
Read a finite numeric value, using fallback only when absent.
Definition at line 89 of file ini_file.h.
◆ required()
|
inline |
Read a required finite numeric value.
Definition at line 93 of file ini_file.h.
◆ text()
|
inline |
Read text or return a fallback when the key is absent.
Definition at line 84 of file ini_file.h.
◆ validate()
|
inline |
Reject keys not owned by the caller's configuration schema.
- Parameters
-
[in] allowed Exact section.name keys accepted by the schema.
- Exceptions
-
std::runtime_error On the first unknown key.
Definition at line 75 of file ini_file.h.
Field Documentation
◆ values_
|
private |
Definition at line 39 of file ini_file.h.
The documentation for this class was generated from the following file:
- modules/pangea/ini_file.h