1#ifndef SAFEHERON_SGX_TRUSTED_CONFIG_H
2#define SAFEHERON_SGX_TRUSTED_CONFIG_H
63 explicit TomlKey(
int index_key) {
71 explicit TomlKey(
const char* str_key) {
94std::vector<TomlKey>
MakeArgs(T first) {
95 std::vector<TomlKey> vec;
97 vec.push_back(TomlKey(first));
112template <
typename T,
typename... Types>
113std::vector<TomlKey>
MakeArgs(T first, Types... args) {
114 std::vector<TomlKey> vec = std::move(
MakeArgs(args...));
115 vec.push_back(TomlKey(first));
157 bool LoadFile(
const char* toml_file_path);
182 template <
typename... Types>
183 std::optional<int64_t>
GetInteger(Types... args) {
184 std::vector<TomlKey> path = std::move(
MakeArgs(args...));
211 template <
typename... Types>
212 std::optional<std::string>
GetString(Types... args) {
213 std::vector<TomlKey> path = std::move(
MakeArgs(args...));
240 template <
typename... Types>
242 std::vector<TomlKey> path = std::move(
MakeArgs(args...));
269 template <
typename... Types>
270 std::optional<std::vector<std::string>>
GetStringArray(Types... args) {
271 std::vector<TomlKey> path = std::move(
MakeArgs(args...));
302 std::optional<int64_t>
GetInteger(
const std::vector<TomlKey>& path);
311 std::optional<std::string>
GetString(
const std::vector<TomlKey>& path);
320 std::optional<std::vector<int64_t>>
GetIntegerArray(
const std::vector<TomlKey>& path);
329 std::optional<std::vector<std::string>>
GetStringArray(
const std::vector<TomlKey>& path);
340 bool GetArrayValues(uint64_t ptr_toml,
const std::string &path_str, std::string &values);
343 uint64_t ref_untrusted_toml_obj_;
345 std::string err_msg_;
A trusted wrapper around the untrusted toml library
Definition ssgx_config_t.h:124
std::optional< std::vector< std::string > > GetStringArray(Types... args)
Finds a string array of values in the TOML file.
Definition ssgx_config_t.h:265
bool LoadFile(const char *toml_file_path)
Load a TOML file and initialize the TOML object.
std::optional< int64_t > GetInteger(Types... args)
Finds an integer value in the TOML file.
Definition ssgx_config_t.h:178
TomlConfig()
Default constructor for the TOML class.
Definition ssgx_config_t.h:129
~TomlConfig()
Destruction.
std::optional< std::string > GetString(Types... args)
Finds a string value in the TOML file.
Definition ssgx_config_t.h:207
std::string GetLastErrorMsg() const
Get the error code when the function returns false.
Definition ssgx_config_t.h:285
std::optional< std::vector< int64_t > > GetIntegerArray(Types... args)
Finds an integer array of values in the TOML file.
Definition ssgx_config_t.h:236
std::vector< TomlKey > MakeArgs(T first)
Creates a vector of TomlKey objects from a single key.
Definition ssgx_config_t.h:89
Definition ssgx_attestation_t.h:6
std::string str_key_
Store the string key (if type is string)
Definition ssgx_config_t.h:77
int index_key_
Store the integer key (if type is integer)
Definition ssgx_config_t.h:76
~TomlKey()=default
Destruction.
TomlKey(int index_key)
Constructs a TomlKey with an integer key.
Definition ssgx_config_t.h:58
KeyType type_
The type of key: integer or string.
Definition ssgx_config_t.h:75
KeyType
Definition ssgx_config_t.h:50
@ String
The key is a String type.
@ Integer
The key is an Integer type.