Arion 1.0.2-alpha
A high-performance C++ framework for emulating executable binaries.
 
Loading...
Searching...
No Matches
config.hpp
Go to the documentation of this file.
1#ifndef ARION_CONFIG_HPP
2#define ARION_CONFIG_HPP
3
4#include <any>
7
8namespace arion
9{
10
13{
14 private:
17 std::map<std::string, std::any> config_map = {
18 {"log_lvl", LOG_LEVEL::INFO}, {"enable_sleep_syscalls", false}, {"thread_blocking_io", false}};
19
20 public:
27 template <typename T> void ARION_EXPORT set_field(const std::string &key, T value)
28 {
29 auto it = this->config_map.find(key);
30 if (it == this->config_map.end())
32 it->second = value;
33 }
34
41 template <typename T> T ARION_EXPORT get_field(const std::string &key) const
42 {
43 auto it = this->config_map.find(key);
44 if (it == this->config_map.end())
46 try
47 {
48 return std::any_cast<T>(it->second);
49 }
50 catch (const std::bad_any_cast &)
51 {
53 }
54 }
55
61 {
62 Config newConfig;
63 newConfig.config_map = this->config_map;
64 return newConfig;
65 }
66};
67
68}; // namespace arion
69
70#endif // ARION_CONFIG_HPP
This class is responsible for storing a configuration which conditions the emulation of an Arion inst...
Definition config.hpp:13
void set_field(const std::string &key, T value)
Definition config.hpp:27
Config clone() const
Definition config.hpp:60
std::map< std::string, std::any > config_map
Definition config.hpp:17
T get_field(const std::string &key) const
Definition config.hpp:41
Thrown when a key is not found in the configuration.
Definition global_excepts.hpp:151
Thrown when trying to access a configuration key with the wrong type.
Definition global_excepts.hpp:163
#define ARION_EXPORT
Defines which symbols should be exported from the library.
Definition global_defs.hpp:13
Definition arch_x86-64.hpp:11