|
coastline 0.0.4
|
The settings of BossRally.ini. More...
#include <config.h>
Public Member Functions | |
| bool | Save (const std::filesystem::path &path) const |
Atomically replace path under a process lock. | |
| std::optional< std::string > | Get (std::string_view section, std::string_view key) const |
| long | GetInteger (std::string_view section, std::string_view key, long fallback) const |
| int | GetIndex (std::string_view section, std::string_view key, std::size_t count, int fallback) const |
| float | GetFloat (std::string_view section, std::string_view key, float fallback) const |
| bool | GetBoolean (std::string_view section, std::string_view key, bool fallback) const |
| void | Set (std::string_view section, std::string_view key, std::string value) |
| Store a value, replacing any value of the same key. | |
Static Public Member Functions | |
| static GameConfig | Load (const std::filesystem::path &path) |
Read path. | |
| static GameConfig | Parse (std::string_view text) |
| Parse INI section headers, Key=Value lines, and comments that start with ; or #. | |
The settings of BossRally.ini.
The PC release writes the sections Video and Game, and the SDL game adds keys to the same sections. Section and key names compare without case, as the Windows profile routines compare them.
|
static |
Read path.
A missing, unreadable, or malformed file gives an empty configuration. Invalid numeric display and audio settings are removed to restore their defaults.
| path | The INI file. |
|
static |
Parse INI section headers, Key=Value lines, and comments that start with ; or #.
| text | The text of the file. |
| bool coastline::GameConfig::Save | ( | const std::filesystem::path & | path | ) | const |
Atomically replace path under a process lock.
Failures before replacement preserve existing data.
| path | The INI file. |
| std::optional< std::string > coastline::GameConfig::Get | ( | std::string_view | section, |
| std::string_view | key ) const |
| section | The section name. |
| key | The key name. |
| long coastline::GameConfig::GetInteger | ( | std::string_view | section, |
| std::string_view | key, | ||
| long | fallback ) const |
| section | The section name. |
| key | The key name. |
| fallback | The value for an absent or malformed key. |
| int coastline::GameConfig::GetIndex | ( | std::string_view | section, |
| std::string_view | key, | ||
| std::size_t | count, | ||
| int | fallback ) const |
| section | The section name. |
| key | The key name. |
| count | The number of choices. |
| fallback | The value for an absent or malformed key, or a value outside the choices. |
count - 1, or fallback for invalid input. | float coastline::GameConfig::GetFloat | ( | std::string_view | section, |
| std::string_view | key, | ||
| float | fallback ) const |
| section | The section name. |
| key | The key name. |
| fallback | The value for an absent or malformed key. |
fallback for invalid or non-finite input. | bool coastline::GameConfig::GetBoolean | ( | std::string_view | section, |
| std::string_view | key, | ||
| bool | fallback ) const |
| section | The section name. |
| key | The key name. |
| fallback | The value for an absent or malformed key. |
| void coastline::GameConfig::Set | ( | std::string_view | section, |
| std::string_view | key, | ||
| std::string | value ) |
Store a value, replacing any value of the same key.
| section | The section name. |
| key | The key name. |
| value | The new value. |