ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
Loading...
Searching...
No Matches
config.h
Go to the documentation of this file.
1
8
9#ifndef ASW_CONFIG_H
10#define ASW_CONFIG_H
11
12#include <optional>
13#include <string>
14
15namespace asw::config {
16
18inline constexpr const char* PATH_VARIABLE = "ASW_CONFIG";
19
23void _init();
24
27void _shutdown();
28
39bool load(const std::string& path);
40
46bool has(const std::string& key);
47
53std::optional<std::string> get_string(const std::string& key);
54
61std::optional<bool> get_bool(const std::string& key);
62
68std::optional<int> get_int(const std::string& key);
69
75std::optional<float> get_float(const std::string& key);
76
77} // namespace asw::config
78
79#endif // ASW_CONFIG_H
void _shutdown()
Remove all settings. Called by asw::core::shutdown().
Definition config.cpp:75
std::optional< std::string > get_string(const std::string &key)
Get a setting as text.
Definition config.cpp:99
constexpr const char * PATH_VARIABLE
Name of the environment variable that holds the config file path.
Definition config.h:18
std::optional< float > get_float(const std::string &key)
Get a setting as a number.
Definition config.cpp:145
bool has(const std::string &key)
Check if a setting is set.
Definition config.cpp:94
std::optional< int > get_int(const std::string &key)
Get a setting as a whole number.
Definition config.cpp:127
bool load(const std::string &path)
Load settings from a file. Settings already loaded stay, unless the file sets them again.
Definition config.cpp:80
void _init()
Load the file named by ASW_CONFIG, if it is set. Called by asw::core::init() before the window opens.
Definition config.cpp:65
std::optional< bool > get_bool(const std::string &key)
Get a setting as true or false. 1, true, yes and on are true. 0, false, no and off are false....
Definition config.cpp:108