JSON-backed persistent settings file.
More...
#include <properties_file.hpp>
|
| | PropertiesFile ()=default |
| bool | load (std::string_view path) |
| | Load properties from a JSON file. Returns false if file doesn't exist or is invalid.
|
| bool | save (std::string_view path) |
| | Save properties to a JSON file. Stores the path for subsequent save() calls.
|
| bool | save () const |
| | Save to the path it was loaded from (or last saved to).
|
| std::optional< std::string > | get_string (std::string_view key) const |
| | Get/set string properties.
|
| void | set_string (std::string_view key, std::string_view value) |
| std::optional< int64_t > | get_int (std::string_view key) const |
| | Get/set integer properties.
|
| void | set_int (std::string_view key, int64_t value) |
| std::optional< double > | get_double (std::string_view key) const |
| | Get/set float properties.
|
| void | set_double (std::string_view key, double value) |
| std::optional< bool > | get_bool (std::string_view key) const |
| | Get/set boolean properties.
|
| void | set_bool (std::string_view key, bool value) |
| void | remove (std::string_view key) |
| | Remove a property.
|
| bool | contains (std::string_view key) const |
| | Whether a key exists.
|
| void | clear () |
| | Clear all properties.
|
| int | size () const |
| | Number of properties.
|
| std::vector< std::string > | keys () const |
| | Get all keys.
|
| const std::string & | path () const |
| | The file path (set after load or explicit set).
|
| void | set_path (std::string_view p) |
JSON-backed persistent settings file.
◆ PropertiesFile()
| pulp::state::PropertiesFile::PropertiesFile |
( |
| ) |
|
|
default |
◆ clear()
| void pulp::state::PropertiesFile::clear |
( |
| ) |
|
◆ contains()
| bool pulp::state::PropertiesFile::contains |
( |
std::string_view | key | ) |
const |
◆ get_bool()
| std::optional< bool > pulp::state::PropertiesFile::get_bool |
( |
std::string_view | key | ) |
const |
Get/set boolean properties.
◆ get_double()
| std::optional< double > pulp::state::PropertiesFile::get_double |
( |
std::string_view | key | ) |
const |
Get/set float properties.
◆ get_int()
| std::optional< int64_t > pulp::state::PropertiesFile::get_int |
( |
std::string_view | key | ) |
const |
Get/set integer properties.
◆ get_string()
| std::optional< std::string > pulp::state::PropertiesFile::get_string |
( |
std::string_view | key | ) |
const |
Get/set string properties.
◆ keys()
| std::vector< std::string > pulp::state::PropertiesFile::keys |
( |
| ) |
const |
◆ load()
| bool pulp::state::PropertiesFile::load |
( |
std::string_view | path | ) |
|
Load properties from a JSON file. Returns false if file doesn't exist or is invalid.
◆ path()
| const std::string & pulp::state::PropertiesFile::path |
( |
| ) |
const |
|
inline |
The file path (set after load or explicit set).
◆ remove()
| void pulp::state::PropertiesFile::remove |
( |
std::string_view | key | ) |
|
◆ save() [1/2]
| bool pulp::state::PropertiesFile::save |
( |
| ) |
const |
Save to the path it was loaded from (or last saved to).
◆ save() [2/2]
| bool pulp::state::PropertiesFile::save |
( |
std::string_view | path | ) |
|
Save properties to a JSON file. Stores the path for subsequent save() calls.
◆ set_bool()
| void pulp::state::PropertiesFile::set_bool |
( |
std::string_view | key, |
|
|
bool | value ) |
◆ set_double()
| void pulp::state::PropertiesFile::set_double |
( |
std::string_view | key, |
|
|
double | value ) |
◆ set_int()
| void pulp::state::PropertiesFile::set_int |
( |
std::string_view | key, |
|
|
int64_t | value ) |
◆ set_path()
| void pulp::state::PropertiesFile::set_path |
( |
std::string_view | p | ) |
|
|
inline |
◆ set_string()
| void pulp::state::PropertiesFile::set_string |
( |
std::string_view | key, |
|
|
std::string_view | value ) |
◆ size()
| int pulp::state::PropertiesFile::size |
( |
| ) |
const |
|
inline |
The documentation for this class was generated from the following file: