Class Parameter¶
Defined in File parameter.hpp
Nested Relationships¶
Nested Types¶
Class Documentation¶
-
class Parameter¶
An owned parameter.
Public Functions
-
explicit Parameter(std::string_view name)¶
Constructor for an unset parameter.
-
explicit Parameter(std::string_view name, double value)¶
Constructor for a floating point parameter.
-
explicit Parameter(std::string_view name, bool value)¶
Constructor for a boolean parameter.
-
explicit Parameter(std::string_view name, std::string_view value)¶
Constructor for a string parameter.
-
inline explicit Parameter(std::string_view name, const char *value)¶
Constructor for a string parameter from a C-style string.
-
explicit Parameter(std::string_view name, const uint8_t *data, size_t data_length)¶
Constructor for a byte array parameter.
-
inline explicit Parameter(std::string_view name, const std::vector<std::byte> &bytes)¶
Constructor for a byte array parameter from a vector of bytes.
-
explicit Parameter(std::string_view name, const std::vector<double> &values)¶
Constructor for an array of floating point values.
-
explicit Parameter(std::string_view name, std::map<std::string, ParameterValue> values)¶
Constructor for an dictionary parameter.
-
explicit Parameter(std::string_view name, ParameterType type, ParameterValue &&value)¶
Constructor for a parameter from raw parts.
-
~Parameter() = default¶
-
ParameterView view() const noexcept¶
Returns an immutable view of this parameter.
-
inline std::string_view name() const noexcept¶
Returns the parameter name.
-
inline ParameterType type() const noexcept¶
Returns the parameter type, used for disambiguation.
-
inline std::optional<ParameterValueView> value() const noexcept¶
Returns the parameter value.
-
inline bool hasValue() const noexcept¶
Returns true if the parameter has a value.
-
template<typename T>
inline bool is() const¶ Checks whether the parameter value matches the specified type.
Returns false if the parameter does not have a value.
- Template Parameters:
T – The expected type of the parameter value.
-
template<typename T>
inline bool isArray() const noexcept¶ Checks whether the parameter value is an array whose elements match the specified type.
Returns false if the parameter does not have a value. Returns true for empty arrays.
- Template Parameters:
T – The expected type of the array’s elements.
-
template<typename T>
inline bool isDict() const noexcept¶ Checks whether the parameter value is a dictionary whose values match the specified type.
Returns false if the parameter does not have a value. Returns true for an empty dictionary.
- Template Parameters:
T – The expected type of the dictionary’s values.
-
inline bool isByteArray() const noexcept¶
Checks whether the parameter value is a byte array.
-
template<typename T>
inline T get() const¶ Extracts a value from the parameter.
This method will throw an exception if the value is unset or the type does not match. You can use
ParameterView::is<T>()
to check that the type matches before calling this method.- Template Parameters:
T – The type of the value to extract.
-
template<typename T>
inline std::vector<T> getArray() const¶ Extracts an array value from the parameter.
This method will throw an exception if the value is unset, the value is not an array or the element type does not match. You can use
ParameterView::isArray<T>()
to check that the element type matches before calling this method.- Template Parameters:
T – The type of the array’s elements.
-
template<typename T>
inline std::map<std::string, T> getDict() const¶ Extracts a dictionary value from the parameter.
This method will throw an exception if the value is unset, the value is not a dictionary or the value type does not match. You can use
ParameterView::isDict<T>()
to check that the value type matches before calling this method.- Template Parameters:
T – The type of the dictionary’s values.
-
inline FoxgloveResult<std::vector<std::byte>> getByteArray() const¶
Extracts a dictionary value from the parameter.
This method will return
ValueError
if the value is unset or the value is not a byte array. It will returnBase64DecodeError
if the value is not a valid base64-encoding.
-
explicit Parameter(std::string_view name)¶