A trusted wrapper around the untrusted toml library
More...
#include <ssgx_config_t.h>
|
| | TomlConfig () |
| | Default constructor for the TOML class.
|
| |
| | ~TomlConfig () |
| | Destruction.
|
| |
| bool | LoadFile (const char *toml_file_path) |
| | Load a TOML file and initialize the TOML object.
|
| |
| template<typename... Types> |
| std::optional< int64_t > | GetInteger (Types... args) |
| | Finds an integer value in the TOML file.
|
| |
| template<typename... Types> |
| std::optional< std::string > | GetString (Types... args) |
| | Finds a string value in the TOML file.
|
| |
| template<typename... Types> |
| std::optional< std::vector< int64_t > > | GetIntegerArray (Types... args) |
| | Finds an integer array of values in the TOML file.
|
| |
| template<typename... Types> |
| std::optional< std::vector< std::string > > | GetStringArray (Types... args) |
| | Finds a string array of values in the TOML file.
|
| |
| std::string | GetLastErrorMsg () const |
| | Get the error code when the function returns false.
|
| |
A trusted wrapper around the untrusted toml library
Compared to the TOML v1.0.0 standard:
- We support reading strings and their arrays.
- We support reading integers (-2^63 to 2^63-1) and their arrays.
- We do not support reading dates and times or their arrays.
- We do not support reading floating-point numbers or their arrays.
- We do not support reading booleans or their arrays.
◆ TomlConfig()
| ssgx::config_t::TomlConfig::TomlConfig |
( |
| ) |
|
|
inline |
Default constructor for the TOML class.
◆ ~TomlConfig()
| ssgx::config_t::TomlConfig::~TomlConfig |
( |
| ) |
|
◆ GetInteger()
template<typename... Types>
| std::optional< int64_t > ssgx::config_t::TomlConfig::GetInteger |
( |
Types... | args | ) |
|
|
inline |
Finds an integer value in the TOML file.
- Template Parameters
-
| Types | The types of the keys (either const char* or int) |
- Parameters
-
| [in] | args | The keys representing the data path to the integer value |
- Returns
- The integer value if success, otherwise return std::nullopt.
- Example
bool ok;
if (!ok) return false;
std::optional<int64_t> value = toml.
GetInteger(
"animal",
"dog",
"age");
if (!value.has_value()) {
return false;
}
Printf("Value: %d\n", value);
A trusted wrapper around the untrusted toml library
Definition ssgx_config_t.h:124
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
std::string GetLastErrorMsg() const
Get the error code when the function returns false.
Definition ssgx_config_t.h:285
◆ GetIntegerArray()
template<typename... Types>
| std::optional< std::vector< int64_t > > ssgx::config_t::TomlConfig::GetIntegerArray |
( |
Types... | args | ) |
|
|
inline |
Finds an integer array of values in the TOML file.
- Template Parameters
-
| Types | The types of the keys (either const char* or int) |
- Parameters
-
| [in] | args | The keys representing the data path to the array of values |
- Returns
- The integer values array if success, otherwise return std::nullopt.
- Example
bool ok;
if (!ok) return false;
if (!values.has_value()) {
return false;
}
Printf("values count: %d\n", values.size());
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
◆ GetLastErrorMsg()
| std::string ssgx::config_t::TomlConfig::GetLastErrorMsg |
( |
| ) |
const |
|
inlinenodiscard |
Get the error code when the function returns false.
- Returns
- error code
- Example
bool ok;
if (!ok) {
return false;
}
◆ GetString()
template<typename... Types>
| std::optional< std::string > ssgx::config_t::TomlConfig::GetString |
( |
Types... | args | ) |
|
|
inline |
Finds a string value in the TOML file.
- Template Parameters
-
| Types | The types of the keys (either const char* or int) |
- Parameters
-
| [in] | args | The keys representing the data path to the string value |
- Returns
- The string value if success, otherwise return std::nullopt.
- Example
bool ok;
if (!ok) return false;
std::optional<std::string>> value = toml.
GetString(
"animal",
"dog",
"name");
if (!value.has_value()) {
return false;
}
Printf("Value: %s\n", value.c_str());
std::optional< std::string > GetString(Types... args)
Finds a string value in the TOML file.
Definition ssgx_config_t.h:207
◆ GetStringArray()
template<typename... Types>
| std::optional< std::vector< std::string > > ssgx::config_t::TomlConfig::GetStringArray |
( |
Types... | args | ) |
|
|
inline |
Finds a string array of values in the TOML file.
- Template Parameters
-
| Types | The types of the keys (either const char* or int) |
- Parameters
-
| [in] | args | The keys representing the data path to the array of values |
- Returns
- The string values array if success, otherwise return std::nullopt.
- Example
bool ok;
if (!ok) return false;
if (!values.has_value()) {
return false;
}
Printf("values count: %d\n", values.size());
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
◆ LoadFile()
| bool ssgx::config_t::TomlConfig::LoadFile |
( |
const char * | toml_file_path | ) |
|
Load a TOML file and initialize the TOML object.
- Parameters
-
| [in] | toml_file_path | The path to the TOML file to parse |
- Returns
- True if the TOML object was successfully created; false otherwise
- Example
bool ok;
ok = toml.
LoadFile(toml,
"/root/config");
if (!ok) return false;
The documentation for this class was generated from the following file: