Manages configuration options for RapidsMPF operations. More...
#include <config.hpp>
Public Member Functions | |
| Options (std::unordered_map< std::string, OptionValue > options={}) | |
Constructs an Options instance from option values. More... | |
| Options (std::unordered_map< std::string, std::string > options_as_strings) | |
Constructs an Options instance from option values as strings. More... | |
| bool | insert_if_absent (std::string const &key, std::string option_as_string) |
| Inserts an option only if it is not already present. More... | |
| std::size_t | insert_if_absent (std::unordered_map< std::string, std::string > options_as_strings) |
| Inserts multiple options if they are not already present. More... | |
| template<typename T > | |
| T const & | get (const std::string &key, OptionFactory< T > factory) |
| Retrieves a configuration option by key. More... | |
| std::unordered_map< std::string, std::string > | get_strings () const |
| Retrieves all option values as strings. More... | |
| std::vector< std::uint8_t > | serialize () const |
| Serializes the options into a binary buffer. More... | |
Static Public Member Functions | |
| static Options | deserialize (std::vector< std::uint8_t > const &buffer) |
| Deserializes a binary buffer into an Options object. More... | |
Manages configuration options for RapidsMPF operations.
The Options class provides a high-level interface for storing and retrieving configuration options.
All keys are trimmed and converted to lower case using rapidsmpf::trim() and rapidsmpf::to_lower().
rapidsmpf::config::Options is efficient as it uses a shared pointer to the shared options (OptionsShared). Definition at line 124 of file config.hpp.
| rapidsmpf::config::Options::Options | ( | std::unordered_map< std::string, OptionValue > | options = {} | ) |
Constructs an Options instance from option values.
| options | A map of option keys to their corresponding option value. |
| std::invalid_argument | If keys are not case-insensitive. |
| rapidsmpf::config::Options::Options | ( | std::unordered_map< std::string, std::string > | options_as_strings | ) |
Constructs an Options instance from option values as strings.
| options_as_strings | A map of option keys to their string representations. |
| std::invalid_argument | If keys are not case-insensitive. |
|
static |
Deserializes a binary buffer into an Options object.
See Options::serialize() for the binary format.
| buffer | The binary buffer produced by Options::serialize(). |
| std::invalid_argument | If the buffer is malformed or incomplete. |
| std::out_of_range | If offsets exceed buffer boundaries. |
|
inline |
Retrieves a configuration option by key.
If the option is not present, it will be constructed using the provided factory, which receives the string representation of the option (or an empty string if unset).
| T | The type of the option to retrieve. |
| key | The option key (should be lower case). |
| factory | Function to construct the option from a string. |
| std::invalid_argument | If the stored option type does not match T. |
| std::bad_any_cast | If T doesn't match the type of the option. |
T, subsequent calls to get on the same key must use the same T. Using a different T for the same key will result in a std::bad_any_cast. Definition at line 194 of file config.hpp.
| std::unordered_map<std::string, std::string> rapidsmpf::config::Options::get_strings | ( | ) | const |
Retrieves all option values as strings.
This method returns a map of all currently stored options where both the keys and values are represented as strings.
| bool rapidsmpf::config::Options::insert_if_absent | ( | std::string const & | key, |
| std::string | option_as_string | ||
| ) |
Inserts an option only if it is not already present.
This method checks whether the given option key exists in the current set of options. If it does not, the option is inserted in its string representation.
| key | The option key to insert. The key is trimmed and converted to lower case before insertion. |
| option_as_string | The string representation of the option value. |
true if the option was inserted; false if it was already present. | std::size_t rapidsmpf::config::Options::insert_if_absent | ( | std::unordered_map< std::string, std::string > | options_as_strings | ) |
Inserts multiple options if they are not already present.
This method attempts to insert each option key-value pair from the provided map into the current set of options. Each insertion is performed only if the key does not already exist in the options.
| options_as_strings | A map of option keys to their string representations. |
| std::vector<std::uint8_t> rapidsmpf::config::Options::serialize | ( | ) | const |
Serializes the options into a binary buffer.
An Options instance can only be serialized if no options have been accessed. This is because serialization is based on the original string representations of the options. Once an option has been accessed and parsed, its string value may no longer accurately reflect its state, making serialization potentially inconsistent.
The format (v1) is:
Offsets are absolute byte positions into the buffer.
Serialization limits:
| std::invalid_argument | If any option has already been accessed. |