Simplify access to values hold within a JSON file. More...
#include <mc_rtc/Configuration.h>
Classes | |
struct | Exception |
Exception thrown by this class when something bad occurs. More... | |
Public Member Functions | |
MC_RTC_DEPRECATED bool | isMember (const std::string &key) const |
Deprecated, see has. More... | |
bool | has (const std::string &key) const |
Check if the key is part of the conf. More... | |
operator bool () const | |
Cast to bool. More... | |
operator int8_t () const | |
Cast to int8_t. More... | |
operator uint8_t () const | |
Cast to uint8_t. More... | |
operator int16_t () const | |
Cast to int16_t. More... | |
operator uint16_t () const | |
Cast to uint16_t. More... | |
operator int32_t () const | |
Cast to int32_t. More... | |
operator uint32_t () const | |
Cast to uint32_t. More... | |
operator int64_t () const | |
Cast to int64_t. More... | |
operator uint64_t () const | |
Cast to uint64_t. More... | |
operator double () const | |
Cast to double. More... | |
operator std::string () const | |
Cast to a string. More... | |
operator Eigen::Vector2d () const | |
Retrieve as a Eigen::Vector2d instance. More... | |
operator Eigen::Vector3d () const | |
Retrieve as a Eigen::Vector3d instance. More... | |
operator Eigen::Vector4d () const | |
Retrieve as a Eigen::Vector4d instance. More... | |
operator Eigen::Vector6d () const | |
Retrieve as a Eigen::Vector6d instance. More... | |
operator mc_rbdyn::Gains2d () const | |
Retrieve as a mc_rbdyn::Gains2d instance. More... | |
operator mc_rbdyn::Gains3d () const | |
Retrieve as a mc_rbdyn::Gains3d instance. More... | |
operator mc_rbdyn::Gains6d () const | |
Retrieve as a mc_rbdyn::Gains6d instance. More... | |
operator Eigen::VectorXd () const | |
Retrieve as a Eigen::VectorXd instance. More... | |
operator Eigen::Quaterniond () const | |
Retrieve as a Eigen::Quaterniond instance. More... | |
operator Eigen::Matrix3d () const | |
Retrieve as a Eigen::Matrix3d instance. More... | |
operator Eigen::Matrix6d () const | |
Retrieve as a Eigen::Matrix6d instance. More... | |
operator Eigen::MatrixXd () const | |
Retrieve as a Eigen::MatrixXd instance. More... | |
operator sva::PTransformd () const | |
Retrieve as an sva::PTransformd. More... | |
operator sva::ForceVecd () const | |
Retrieve as an sva::ForceVecd. More... | |
operator sva::MotionVecd () const | |
Retrieve as an sva::MotionVecd. More... | |
operator sva::ImpedanceVecd () const | |
Retrieve as an sva::ImpedanceVecd. More... | |
template<class T , class A > | |
operator std::vector< T, A > () const | |
Retrieve a vector instance. More... | |
template<class T , std::size_t N> | |
operator std::array< T, N > () const | |
Retrieve an array instance. More... | |
template<class T1 , class T2 > | |
operator std::pair< T1, T2 > () const | |
Retrieve a pair instance. More... | |
template<typename T , class C , class A > | |
operator std::map< std::string, T, C, A > () const | |
Retrieve a string-indexed map instance. More... | |
template<typename T , typename C = std::less<T>, typename A = std::allocator<T>> | |
operator std::set< T, C, A > () const | |
Retrieve a set of objects. More... | |
template<typename T , typename H = std::hash<T>, typename E = std::equal_to<T>, typename A = std::allocator<T>> | |
operator std::unordered_set< T, H, E, A > () const | |
Retrieve an unordered set of objects. More... | |
template<typename... Args> | |
operator std::variant< Args... > () const | |
template<typename T , typename std::enable_if< internal::is_integral_v< T >, int >::type = 0> | |
operator T () const | |
template<typename T , typename std::enable_if< internal::has_configuration_load_object_v< T >||internal::has_static_fromConfiguration_v< T >, int >::type = 0> | |
operator T () const | |
User-defined conversions. More... | |
template<typename T > | |
operator std::optional< T > () const | |
Retrieves an optional<T> More... | |
Configuration () | |
Creates an empty configuration. More... | |
Configuration (const std::string &path) | |
Constructor using a file path. More... | |
Configuration (const char *path) | |
Constructor using a file path (C-style string) More... | |
void | load (const std::string &path) |
Load more data into the configuration. More... | |
void | load (const mc_rtc::Configuration &config) |
Load data from another Configuration object. More... | |
void | loadData (const std::string &data) |
Load data from a JSON string. More... | |
void | loadYAMLData (const std::string &data) |
Load data from a YAML string. More... | |
void | save (const std::string &path, bool pretty=true) const |
Save the configuration to a file. More... | |
std::string | dump (bool pretty=false, bool yaml=false) const |
Dump the configuration into a string. More... | |
size_t | toMessagePack (std::vector< char > &data) const |
Convert to MessagePack. More... | |
void | toMessagePack (MessagePackBuilder &builder) const |
Append to an existing MessagePackBuilder. More... | |
Configuration | operator() (const std::string &key) const |
Returns a Entry value stored within the configuration. More... | |
std::optional< Configuration > | find (const std::string &key) const |
Returns the Configuration entry if it exists, std::nullopt otherwise. More... | |
template<typename... Args> | |
std::optional< Configuration > | find (const std::string &key, Args &&... others) const |
Return the Configuration entry at (key, others...) if it exists, std::nullopt otherwise. More... | |
template<typename T , typename... Args> | |
std::optional< T > | find (const std::string &key, Args &&... others) const |
Return the Configuration entry at (key, others...) if it exists, std::nullopt otherwise. More... | |
bool | empty () const |
Returns true if the underlying array or underlying object is empty. More... | |
size_t | size () const |
If the stored value is an array, returns its size, otherwise returns 0. More... | |
bool | isArray () const noexcept |
Returns true if the underlying value is an array. More... | |
bool | isObject () const noexcept |
Returns true if the underlying value is an object. More... | |
bool | isString () const noexcept |
Returns true if the underlying value is a string. More... | |
bool | isNumeric () const noexcept |
Returns true if the underlying value is numeric. More... | |
Configuration | operator[] (size_t i) const |
If the stored value is an array, return a Configuration element for the i-th element. More... | |
template<typename T > | |
T | at (size_t i, const T &v) const |
Retrieve a given value from a JSON array. More... | |
template<typename T > | |
void | operator() (const std::string &key, T &v) const |
Retrieve and store a given value stored within the configuration. More... | |
template<typename T > | |
T | operator() (const std::string &key, const T &v) const |
Retrieve a given value stored within the configuration with a default value. More... | |
bool | operator== (const char *rhs) const |
Non-template version for C-style strings comparison. More... | |
template<typename T > | |
bool | operator== (const T &rhs) const |
Compare stored values with given value. More... | |
void | add_null (const std::string &key) |
Add a null element to the configuration. More... | |
void | add (const std::string &key, bool value) |
Add a bool element to the Configuration. More... | |
void | add (const std::string &key, int8_t value) |
Add a int64_t element to the Configuration. More... | |
void | add (const std::string &key, uint8_t value) |
Add a uint8_t element to the Configuration. More... | |
void | add (const std::string &key, int16_t value) |
Add a int16_t element to the Configuration. More... | |
void | add (const std::string &key, uint16_t value) |
Add a uint16_t element to the Configuration. More... | |
void | add (const std::string &key, int32_t value) |
Add a int32_t element to the Configuration. More... | |
void | add (const std::string &key, uint32_t value) |
Add a uint32_t element to the Configuration. More... | |
void | add (const std::string &key, int64_t value) |
Add a int64_t element to the Configuration. More... | |
void | add (const std::string &key, uint64_t value) |
Add a uint64_t element to the Configuration. More... | |
void | add (const std::string &key, double value) |
Add a double element to the Configuration. More... | |
void | add (const std::string &key, const std::string &value) |
Add a std::string element to the Configuration. More... | |
void | add (const std::string &key, const char *value) |
Add a const char* element to the Configuration, Behaves like std::string. More... | |
void | add (const std::string &key, const Eigen::Vector2d &value) |
Add a Eigen::Vector2d element to the Configuration. More... | |
void | add (const std::string &key, const Eigen::Vector3d &value) |
Add a Eigen::Vector3d element to the Configuration. More... | |
void | add (const std::string &key, const Eigen::Vector4d &value) |
Add a Eigen::Vector4d element to the Configuration. More... | |
void | add (const std::string &key, const Eigen::Vector6d &value) |
Add a Eigen::Vector6d element to the Configuration. More... | |
void | add (const std::string &key, const Eigen::VectorXd &value) |
Add a Eigen::VectorXd element to the Configuration. More... | |
void | add (const std::string &key, const Eigen::Quaterniond &value) |
Add a Eigen::Quaterniond element to the Configuration. More... | |
void | add (const std::string &key, const Eigen::Matrix3d &value) |
Add a Eigen::Matrix3d element to the Configuration. More... | |
void | add (const std::string &key, const Eigen::Matrix6d &value) |
Add a Eigen::Matrix6d element to the Configuration. More... | |
void | add (const std::string &key, const Eigen::MatrixXd &value) |
Add an Eigen::MatrixXd element to the Configuration. More... | |
void | add (const std::string &key, const sva::PTransformd &value) |
Add an sva::PTransformd element to the Configuration. More... | |
void | add (const std::string &key, const sva::ForceVecd &value) |
Add an sva::ForceVecd element to the Configuration. More... | |
void | add (const std::string &key, const sva::MotionVecd &value) |
Add an sva::MotionVecd element to the Configuration. More... | |
void | add (const std::string &key, const sva::ImpedanceVecd &value) |
Add an sva::ImpedanceVecd element to the Configuration. More... | |
void | add (const std::string &key, const Configuration &value) |
Add another Configuration to the Configuration. More... | |
Configuration | add (const std::string &key) |
Create an empty object in the Configuration. More... | |
Configuration | array (const std::string &key, size_t size=0) |
Create an empty array in the Configuration. More... | |
void | push_null () |
Insert a null value into an array. More... | |
void | push (bool value) |
Insert a bool element into an array. More... | |
void | push (int8_t value) |
Insert a int8_t element int8_to an array. More... | |
void | push (uint8_t value) |
Insert a uint8_t element into an array. More... | |
void | push (int16_t value) |
Insert a int16_t element int16_to an array. More... | |
void | push (uint16_t value) |
Insert a uint16_t element into an array. More... | |
void | push (int32_t value) |
Insert a int32_t element int32_to an array. More... | |
void | push (uint32_t value) |
Insert a uint32_t element into an array. More... | |
void | push (int64_t value) |
Insert a int64_t element int64_to an array. More... | |
void | push (uint64_t value) |
Insert a uint64_t element into an array. More... | |
void | push (double value) |
Insert a double element into an array. More... | |
void | push (const std::string &value) |
Insert a std::string element into an array. More... | |
void | push (const char *value) |
Insert a const char * element into an array Behaves like push(std::string) More... | |
void | push (const Eigen::Vector2d &value) |
Insert a Eigen::Vector2d element into an array. More... | |
void | push (const Eigen::Vector3d &value) |
Insert a Eigen::Vector3d element into an array. More... | |
void | push (const Eigen::Vector4d &value) |
Insert a Eigen::Vector4d element into an array. More... | |
void | push (const Eigen::Vector6d &value) |
Insert a Eigen::Vector6d element into an array. More... | |
void | push (const Eigen::VectorXd &value) |
Insert a Eigen::VectorXd element into an array. More... | |
void | push (const Eigen::Quaterniond &value) |
Insert a Eigen::Quaterniond element into an array. More... | |
void | push (const Eigen::Matrix3d &value) |
Insert a Eigen::Matrix3d element into an array. More... | |
void | push (const Eigen::Matrix6d &value) |
Insert a Eigen::Matrix6d element into an array. More... | |
void | push (const Eigen::MatrixXd &value) |
Insert a Eigen::MatrixXd element into an array. More... | |
void | push (const sva::PTransformd &value) |
Insert an sva::PTransformd element into an array. More... | |
void | push (const sva::ForceVecd &value) |
Insert an sva::ForceVecd element into an array. More... | |
void | push (const sva::MotionVecd &value) |
Insert an sva::MotionVecd element into an array. More... | |
void | push (const sva::ImpedanceVecd &value) |
Insert an sva::ImpedanceVecd element into an array. More... | |
void | push (const Configuration &value) |
Push a Configuration element into an array. More... | |
Configuration | array (size_t reserve=0) |
Push an empty array. More... | |
Configuration | object () |
Push an empty object. More... | |
template<typename T , typename... Args, typename std::enable_if< internal::has_configuration_save_object_v< T, Args... >||internal::has_toConfiguration_method_v< T, Args... >, int >::type = 0> | |
void | push (const T &value, Args &&... args) |
User-defined conversion. More... | |
template<typename T , typename std::enable_if< internal::is_integral_v< T >, int >::type = 0> | |
void | push (const T &value) |
template<typename T , typename A = std::allocator<T>, typename... Args> | |
void | add (const std::string &key, const std::vector< T, A > &value, Args &&... args) |
Add a vector into the JSON document. More... | |
template<typename T , std::size_t N, typename... Args> | |
void | add (const std::string &key, const std::array< T, N > &value, Args &&... args) |
Add an array into the JSON document. More... | |
template<typename T1 , typename T2 , typename... Args> | |
void | add (const std::string &key, const std::pair< T1, T2 > &value, Args &&... args) |
Add a pair into the JSON document. More... | |
template<typename T , class C = std::less<std::string>, class A = std::allocator<std::pair<const std::string, T>>, typename... Args> | |
void | add (const std::string &key, const std::map< std::string, T, C, A > &value, Args &&... args) |
Add string-indexed map into the JSON document. More... | |
template<typename T , typename C = std::less<T>, typename A = std::allocator<T>, typename... Args> | |
void | add (const std::string &key, const std::set< T, C, A > &value, Args &&... args) |
Add a set into the JSON document. More... | |
template<typename T , typename H = std::hash<T>, typename E = std::equal_to<T>, typename A = std::allocator<T>, typename... Args> | |
void | add (const std::string &key, const std::unordered_set< T, H, E, A > &value, Args &&... args) |
Add an unordered set into the JSON document. More... | |
template<typename... Args> | |
void | add (const std::string &key, const std::variant< Args... > &value) |
Add a variant object into the JSON document. More... | |
template<typename T , typename std::enable_if< internal::is_integral_v< T >, int >::type = 0> | |
void | add (const std::string &key, const T &value) |
template<typename T , typename... Args, typename std::enable_if< internal::has_configuration_save_object_v< T, Args... >||internal::has_toConfiguration_method_v< T, Args... >, int >::type = 0> | |
void | add (const std::string &key, const T &value, Args &&... args) |
User-defined conversion. More... | |
template<typename T , typename A = std::allocator<T>, typename... Args> | |
void | push (const std::vector< T, A > &value, Args &&... args) |
Push a vector into the JSON document. More... | |
template<typename T , std::size_t N, typename... Args> | |
void | push (const std::array< T, N > &value, Args &&... args) |
Push an array into the JSON document. More... | |
template<typename T1 , typename T2 , typename... Args> | |
void | push (const std::pair< T1, T2 > &value, Args &&... args) |
Push a pair into the JSON document. More... | |
template<typename T , class C = std::less<std::string>, class A = std::allocator<std::pair<const std::string, T>>, typename... Args> | |
void | push (const std::map< std::string, T, C, A > &value, Args &&... args) |
Push a string-indexed map into the JSON document. More... | |
template<typename T , typename C = std::less<T>, typename A = std::allocator<T>, typename... Args> | |
void | push (const std::set< T, C, A > &value, Args &&... args) |
Push a set into the JSON document. More... | |
template<typename T , typename H = std::hash<T>, typename E = std::equal_to<T>, typename A = std::allocator<T>, typename... Args> | |
void | push (const std::unordered_set< T, H, E, A > &value, Args &&... args) |
Push an unordered set into the JSON document. More... | |
template<typename... Args> | |
void | push (const std::variant< Args... > &value) |
Push a variant object into the JSON document. More... | |
bool | remove (const std::string &key) |
std::vector< std::string > | keys () const |
ConfigurationArrayIterator | begin () const |
ConfigurationArrayIterator | end () const |
template<> | |
void MC_RTC_UTILS_DLLAPI | operator() (const std::string &key, std::string &v) const |
Specialized version to lift ambiguity. More... | |
Static Public Member Functions | |
static Configuration | rootArray () |
Returns a Configuration with an array as root entry. More... | |
static Configuration | fromData (const std::string &data) |
Static constructor to load from JSON data. More... | |
static Configuration | fromData (const char *data) |
Static constructor to load from JSON data (C overload) More... | |
static Configuration | fromYAMLData (const std::string &data) |
Static constructor to load from YAML data. More... | |
static Configuration | fromYAMLData (const char *data) |
Static constructor to load from YAML data (C overload) More... | |
static Configuration | fromMessagePack (const char *data, size_t size) |
Static constructor to load from MessagePack data. More... | |
Simplify access to values hold within a JSON file.
Configuration values can be accessed using a key system, type conversion are ensured by the class.
mc_rtc::Configuration::Configuration | ( | ) |
Creates an empty configuration.
mc_rtc::Configuration::Configuration | ( | const std::string & | path | ) |
Constructor using a file path.
path | Path to the configuration file |
mc_rtc::Configuration::Configuration | ( | const char * | path | ) |
Constructor using a file path (C-style string)
path | Path to the configuration file |
Configuration mc_rtc::Configuration::add | ( | const std::string & | key | ) |
Create an empty object in the Configuration.
Overwrite existing content if any.
key | Key to add |
void mc_rtc::Configuration::add | ( | const std::string & | key, |
bool | value | ||
) |
Add a bool element to the Configuration.
Overrides the existing value if it holds one for the given key.
key | Key of the element |
value | Value of the element |
void mc_rtc::Configuration::add | ( | const std::string & | key, |
const char * | value | ||
) |
Add a const char* element to the Configuration, Behaves like std::string.
void mc_rtc::Configuration::add | ( | const std::string & | key, |
const Configuration & | value | ||
) |
Add another Configuration to the Configuration.
void mc_rtc::Configuration::add | ( | const std::string & | key, |
const Eigen::Matrix3d & | value | ||
) |
Add a Eigen::Matrix3d element to the Configuration.
void mc_rtc::Configuration::add | ( | const std::string & | key, |
const Eigen::Matrix6d & | value | ||
) |
Add a Eigen::Matrix6d element to the Configuration.
void mc_rtc::Configuration::add | ( | const std::string & | key, |
const Eigen::MatrixXd & | value | ||
) |
Add an Eigen::MatrixXd element to the Configuration.
void mc_rtc::Configuration::add | ( | const std::string & | key, |
const Eigen::Quaterniond & | value | ||
) |
Add a Eigen::Quaterniond element to the Configuration.
void mc_rtc::Configuration::add | ( | const std::string & | key, |
const Eigen::Vector2d & | value | ||
) |
Add a Eigen::Vector2d element to the Configuration.
void mc_rtc::Configuration::add | ( | const std::string & | key, |
const Eigen::Vector3d & | value | ||
) |
Add a Eigen::Vector3d element to the Configuration.
void mc_rtc::Configuration::add | ( | const std::string & | key, |
const Eigen::Vector4d & | value | ||
) |
Add a Eigen::Vector4d element to the Configuration.
void mc_rtc::Configuration::add | ( | const std::string & | key, |
const Eigen::Vector6d & | value | ||
) |
Add a Eigen::Vector6d element to the Configuration.
void mc_rtc::Configuration::add | ( | const std::string & | key, |
const Eigen::VectorXd & | value | ||
) |
Add a Eigen::VectorXd element to the Configuration.
|
inline |
Add an array into the JSON document.
Overwrites existing content if any.
key | Key of the element |
value | Array of elements to add |
|
inline |
Add string-indexed map into the JSON document.
Overwrites existing content if any.
key | Key of the element |
value | Map of elements to add |
|
inline |
Add a pair into the JSON document.
Overwrite existing content if any.
key | Key of the element |
value | Pair to add |
|
inline |
Add a set into the JSON document.
Overwrites existing content if any.
key | Key of the element |
value | Set of elements to add |
void mc_rtc::Configuration::add | ( | const std::string & | key, |
const std::string & | value | ||
) |
Add a std::string element to the Configuration.
|
inline |
Add an unordered set into the JSON document.
Overwrites existing content if any.
key | Key of the element |
value | Set of elements to add |
|
inline |
Add a variant object into the JSON document.
The variant is written as [value.index(), std::get<value.index()>(value)]
If | the variant is in valueless state |
key | Key of the element |
value | Variant value to add |
|
inline |
Add a vector into the JSON document.
Overwrites existing content if any.
key | Key of the element |
value | Vector of elements to add |
void mc_rtc::Configuration::add | ( | const std::string & | key, |
const sva::ForceVecd & | value | ||
) |
Add an sva::ForceVecd element to the Configuration.
void mc_rtc::Configuration::add | ( | const std::string & | key, |
const sva::ImpedanceVecd & | value | ||
) |
Add an sva::ImpedanceVecd element to the Configuration.
void mc_rtc::Configuration::add | ( | const std::string & | key, |
const sva::MotionVecd & | value | ||
) |
Add an sva::MotionVecd element to the Configuration.
void mc_rtc::Configuration::add | ( | const std::string & | key, |
const sva::PTransformd & | value | ||
) |
Add an sva::PTransformd element to the Configuration.
|
inline |
Integral type conversions
Key | key of the element |
value | Value to add |
|
inline |
User-defined conversion.
Requires the existence of: mc_rtc::Configuration mc_rtc::ConfigurationLoader<T>::save(const T&, Args ... args);
key | Key of the element |
value | Value to add |
void mc_rtc::Configuration::add | ( | const std::string & | key, |
double | value | ||
) |
Add a double element to the Configuration.
void mc_rtc::Configuration::add | ( | const std::string & | key, |
int16_t | value | ||
) |
Add a int16_t element to the Configuration.
void mc_rtc::Configuration::add | ( | const std::string & | key, |
int32_t | value | ||
) |
Add a int32_t element to the Configuration.
void mc_rtc::Configuration::add | ( | const std::string & | key, |
int64_t | value | ||
) |
Add a int64_t element to the Configuration.
void mc_rtc::Configuration::add | ( | const std::string & | key, |
int8_t | value | ||
) |
Add a int64_t element to the Configuration.
void mc_rtc::Configuration::add | ( | const std::string & | key, |
uint16_t | value | ||
) |
Add a uint16_t element to the Configuration.
void mc_rtc::Configuration::add | ( | const std::string & | key, |
uint32_t | value | ||
) |
Add a uint32_t element to the Configuration.
void mc_rtc::Configuration::add | ( | const std::string & | key, |
uint64_t | value | ||
) |
Add a uint64_t element to the Configuration.
void mc_rtc::Configuration::add | ( | const std::string & | key, |
uint8_t | value | ||
) |
Add a uint8_t element to the Configuration.
void mc_rtc::Configuration::add_null | ( | const std::string & | key | ) |
Add a null element to the configuration.
Overrides the existing value if it holds one for the given key
key | Key of the element |
Configuration mc_rtc::Configuration::array | ( | const std::string & | key, |
size_t | size = 0 |
||
) |
Create an empty array in the Configuration.
Overwrite existing content if any.
key | Key to add |
size | Size that is reserved for the array |
Configuration mc_rtc::Configuration::array | ( | size_t | reserve = 0 | ) |
Push an empty array.
|
inline |
Retrieve a given value from a JSON array.
Returns the default value if the index is too high or if the underlying value does not match the requested type.
i | Index to retrieve |
v | The default value |
ConfigurationArrayIterator mc_rtc::Configuration::begin | ( | ) | const |
std::string mc_rtc::Configuration::dump | ( | bool | pretty = false , |
bool | yaml = false |
||
) | const |
Dump the configuration into a string.
pretty | Writes a human-readable string, defaults to false |
yaml | Writes YAML instead of JSON, defaults to false |
bool mc_rtc::Configuration::empty | ( | ) | const |
Returns true if the underlying array or underlying object is empty.
ConfigurationArrayIterator mc_rtc::Configuration::end | ( | ) | const |
std::optional<Configuration> mc_rtc::Configuration::find | ( | const std::string & | key | ) | const |
Returns the Configuration entry if it exists, std::nullopt otherwise.
key | key used to store the value |
|
inline |
Return the Configuration entry at (key, others...) if it exists, std::nullopt otherwise.
This is equivalent if(auto a = cfg.find("a")) { if(auto b = cfg.find("b")) { ... } }
key | key used to store the value |
others | Keys searched one after the other |
|
inline |
Return the Configuration entry at (key, others...) if it exists, std::nullopt otherwise.
key | key used to store the value |
others | Keys searched one after the other |
T | Type of the entry retrieved |
If | the key exists but the conversion to |
T | fails |
|
static |
Static constructor to load from JSON data (C overload)
data | JSON data to load |
|
static |
Static constructor to load from JSON data.
data | JSON data to load |
|
static |
Static constructor to load from MessagePack data.
data | MessagePack data to load |
size | Size of data |
|
static |
Static constructor to load from YAML data (C overload)
data | YAML data to load |
|
static |
Static constructor to load from YAML data.
data | YAML data to load |
bool mc_rtc::Configuration::has | ( | const std::string & | key | ) | const |
Check if the key is part of the conf.
key | The key to test |
|
inlinenoexcept |
Returns true if the underlying value is an array.
MC_RTC_DEPRECATED bool mc_rtc::Configuration::isMember | ( | const std::string & | key | ) | const |
Deprecated, see has.
key | The key to test |
|
inlinenoexcept |
Returns true if the underlying value is numeric.
|
inlinenoexcept |
Returns true if the underlying value is an object.
|
inlinenoexcept |
Returns true if the underlying value is a string.
std::vector<std::string> mc_rtc::Configuration::keys | ( | ) | const |
Returns the keys of the JSON objects
Returns an empty vector if the underlying JSON object is not an object
void mc_rtc::Configuration::load | ( | const mc_rtc::Configuration & | config | ) |
Load data from another Configuration object.
For any key existing in both objects:
config | The configuration object |
void mc_rtc::Configuration::load | ( | const std::string & | path | ) |
Load more data into the configuration.
For any key existing in both objects:
path | Path to the configuration file |
void mc_rtc::Configuration::loadData | ( | const std::string & | data | ) |
Load data from a JSON string.
Same rules apply as ::load methods
data | JSON data to load |
void mc_rtc::Configuration::loadYAMLData | ( | const std::string & | data | ) |
Load data from a YAML string.
Same rules apply as ::load methods
data | YAML data to load |
Configuration mc_rtc::Configuration::object | ( | ) |
Push an empty object.
mc_rtc::Configuration::operator bool | ( | ) | const |
Cast to bool.
If | the underlying value does not hold a boolean |
mc_rtc::Configuration::operator double | ( | ) | const |
Cast to double.
Will actually convert any numeric entry into a double
If | the underlying value does not hold a numeric value |
mc_rtc::Configuration::operator Eigen::Matrix3d | ( | ) | const |
mc_rtc::Configuration::operator Eigen::Matrix6d | ( | ) | const |
Retrieve as a Eigen::Matrix6d instance.
If | the underlying value does not hold a numeric sequence of size 36 |
mc_rtc::Configuration::operator Eigen::MatrixXd | ( | ) | const |
Retrieve as a Eigen::MatrixXd instance.
If | the underlying value does not hold an array of array of numeric values |
mc_rtc::Configuration::operator Eigen::Quaterniond | ( | ) | const |
Retrieve as a Eigen::Quaterniond instance.
If | the underlying value does not hold a numeric sequence of size 4 |
mc_rtc::Configuration::operator Eigen::Vector2d | ( | ) | const |
Retrieve as a Eigen::Vector2d instance.
If | the underlying value does not hold a numeric sequence of size 2 |
mc_rtc::Configuration::operator Eigen::Vector3d | ( | ) | const |
Retrieve as a Eigen::Vector3d instance.
If | the underlying value does not hold a numeric sequence of size 3 |
mc_rtc::Configuration::operator Eigen::Vector4d | ( | ) | const |
Retrieve as a Eigen::Vector4d instance.
If | the underlying value does not hold a numeric sequence of size 4 |
mc_rtc::Configuration::operator Eigen::Vector6d | ( | ) | const |
Retrieve as a Eigen::Vector6d instance.
If | the underlying value does not hold a numeric sequence of size 6 |
mc_rtc::Configuration::operator Eigen::VectorXd | ( | ) | const |
Retrieve as a Eigen::VectorXd instance.
If the underlying value holds an empty sequence, this functions returns an empty (size 0) vector
If | the underlying value does not hold a numeric sequence |
mc_rtc::Configuration::operator int16_t | ( | ) | const |
Cast to int16_t.
Strictly for int16_t-typed entries
If | the underlying value does not hold an int16_t |
mc_rtc::Configuration::operator int32_t | ( | ) | const |
Cast to int32_t.
Strictly for int32_t-typed entries
If | the underlying value does not hold an int32_t |
mc_rtc::Configuration::operator int64_t | ( | ) | const |
Cast to int64_t.
Strictly for int64_t-typed entries
If | the underlying value does not hold an int64_t |
mc_rtc::Configuration::operator int8_t | ( | ) | const |
Cast to int8_t.
Strictly for int8_t-typed entries
If | the underlying value does not hold an int8_t |
mc_rtc::Configuration::operator mc_rbdyn::Gains2d | ( | ) | const |
Retrieve as a mc_rbdyn::Gains2d instance.
If | the underlying value is not a single double or a numeric sequence of size 2 |
mc_rtc::Configuration::operator mc_rbdyn::Gains3d | ( | ) | const |
Retrieve as a mc_rbdyn::Gains3d instance.
If | the underlying value is not a single double or a numeric sequence of size 3 |
mc_rtc::Configuration::operator mc_rbdyn::Gains6d | ( | ) | const |
Retrieve as a mc_rbdyn::Gains6d instance.
If | the underlying value is not a single double or a numeric sequence of size 6 |
|
inline |
Retrieve an array instance.
If | the underlying value does not hold an array of the correct size or if any member of the array does not meet the requirements of the array elements' type. |
|
inline |
Retrieve a string-indexed map instance.
If | the underlying value is not an object or if the member of the object do not meet the requiremenent of the value type. |
|
inlineexplicit |
Retrieves an optional<T>
Returns nullopt if the conversion fails
|
inline |
Retrieve a pair instance.
If | the underlying value does not hold an array of size 2 or if the member of the array do not meet the requirement of the pair type |
|
inline |
Retrieve a set of objects.
If | the underlying value is not an array, if the member of the array do not meet the requirement of the set key type or if the elements in the array are not unique |
mc_rtc::Configuration::operator std::string | ( | ) | const |
Cast to a string.
If | the underlying value does not hold a string |
|
inline |
Retrieve an unordered set of objects.
If | the underlying value is not an array, if the member of the array do not meet the requirement of the set key type or if the elements in the array are not unique |
|
inline |
Retrieve a variant object
If | the underlying value is not an array of size 2 |
If | the first value of the array is an invalid index for this variant |
If | the data in the second value of the array does not allow to deserialize a value of the type given at the index |
|
inline |
Retrieve a vector instance.
If | the underlying value does not hold an array or if any member of the array does not meeting the requirement of the vector elements' type |
mc_rtc::Configuration::operator sva::ForceVecd | ( | ) | const |
Retrieve as an sva::ForceVecd.
If | the underlying value is not an object with couple and force members |
mc_rtc::Configuration::operator sva::ImpedanceVecd | ( | ) | const |
Retrieve as an sva::ImpedanceVecd.
If | the underlying value is not an object with angular and linear members |
mc_rtc::Configuration::operator sva::MotionVecd | ( | ) | const |
Retrieve as an sva::MotionVecd.
If | the underlying value is not an object with angular and linear members |
mc_rtc::Configuration::operator sva::PTransformd | ( | ) | const |
Retrieve as an sva::PTransformd.
If | the underlying value is not an object with rotation and/or translation members |
|
inline |
Integral type conversions
If | the cast to the similar standard integral type would fail |
|
inline |
User-defined conversions.
Requires:
mc_rtc::Configuration::operator uint16_t | ( | ) | const |
Cast to uint16_t.
Int entries that are strictly positive will be treated as uint16_t entries
If | the underlying value does not hold an uint16_t |
mc_rtc::Configuration::operator uint32_t | ( | ) | const |
Cast to uint32_t.
Int entries that are strictly positive will be treated as uint32_t entries
If | the underlying value does not hold an uint32_t |
mc_rtc::Configuration::operator uint64_t | ( | ) | const |
Cast to uint64_t.
Int entries that are strictly positive will be treated as uint64_t entries
If | the underlying value does not hold an uint64_t |
mc_rtc::Configuration::operator uint8_t | ( | ) | const |
Cast to uint8_t.
Int entries that are strictly positive will be treated as uint8_t entries
If | the underlying value does not hold an uint8_t |
Configuration mc_rtc::Configuration::operator() | ( | const std::string & | key | ) | const |
Returns a Entry value stored within the configuration.
key | The key used to store the value |
If | key is not stored in the Configuration |
|
inline |
Retrieve a given value stored within the configuration with a default value.
If the key is not stored in the Configuration or if the underyling value does not match the requested type, the default value is returned.
key | The key used to store the value |
v | The default value |
void MC_RTC_UTILS_DLLAPI mc_rtc::Configuration::operator() | ( | const std::string & | key, |
std::string & | v | ||
) | const |
Specialized version to lift ambiguity.
|
inline |
Retrieve and store a given value stored within the configuration.
If they key is not stored in the Configuration, the value is unchanged.
key | The key used to store the value |
v | The value to retrieve |
bool mc_rtc::Configuration::operator== | ( | const char * | rhs | ) | const |
Non-template version for C-style strings comparison.
|
inline |
Compare stored values with given value.
Configuration mc_rtc::Configuration::operator[] | ( | size_t | i | ) | const |
If the stored value is an array, return a Configuration element for the i-th element.
i | Access i-th element |
If | i >= size() |
void mc_rtc::Configuration::push | ( | bool | value | ) |
Insert a bool element into an array.
value | Value to add |
If | the underlying Json value is not an array. |
void mc_rtc::Configuration::push | ( | const char * | value | ) |
Insert a const char * element into an array Behaves like push(std::string)
void mc_rtc::Configuration::push | ( | const Configuration & | value | ) |
Push a Configuration element into an array.
void mc_rtc::Configuration::push | ( | const Eigen::Matrix3d & | value | ) |
Insert a Eigen::Matrix3d element into an array.
void mc_rtc::Configuration::push | ( | const Eigen::Matrix6d & | value | ) |
Insert a Eigen::Matrix6d element into an array.
void mc_rtc::Configuration::push | ( | const Eigen::MatrixXd & | value | ) |
Insert a Eigen::MatrixXd element into an array.
void mc_rtc::Configuration::push | ( | const Eigen::Quaterniond & | value | ) |
Insert a Eigen::Quaterniond element into an array.
void mc_rtc::Configuration::push | ( | const Eigen::Vector2d & | value | ) |
Insert a Eigen::Vector2d element into an array.
void mc_rtc::Configuration::push | ( | const Eigen::Vector3d & | value | ) |
Insert a Eigen::Vector3d element into an array.
void mc_rtc::Configuration::push | ( | const Eigen::Vector4d & | value | ) |
Insert a Eigen::Vector4d element into an array.
void mc_rtc::Configuration::push | ( | const Eigen::Vector6d & | value | ) |
Insert a Eigen::Vector6d element into an array.
void mc_rtc::Configuration::push | ( | const Eigen::VectorXd & | value | ) |
Insert a Eigen::VectorXd element into an array.
|
inline |
Push an array into the JSON document.
value | Array of elements to add |
|
inline |
Push a string-indexed map into the JSON document.
value | Map of elements to add |
|
inline |
Push a pair into the JSON document.
value | Pair of elements to add |
|
inline |
Push a set into the JSON document.
Overwrites existing content if any.
key | Key of the element |
value | Set of elements to add |
void mc_rtc::Configuration::push | ( | const std::string & | value | ) |
Insert a std::string element into an array.
|
inline |
Push an unordered set into the JSON document.
Overwrites existing content if any.
key | Key of the element |
value | Set of elements to add |
|
inline |
Push a variant object into the JSON document.
The variant is written as [value.index(), std::get<value.index()>(value)]
If | the variant is in valueless state |
key | Key of the element |
value | Variant value to add |
|
inline |
Push a vector into the JSON document.
value | Vector of elements to add |
void mc_rtc::Configuration::push | ( | const sva::ForceVecd & | value | ) |
Insert an sva::ForceVecd element into an array.
void mc_rtc::Configuration::push | ( | const sva::ImpedanceVecd & | value | ) |
Insert an sva::ImpedanceVecd element into an array.
void mc_rtc::Configuration::push | ( | const sva::MotionVecd & | value | ) |
Insert an sva::MotionVecd element into an array.
void mc_rtc::Configuration::push | ( | const sva::PTransformd & | value | ) |
Insert an sva::PTransformd element into an array.
|
inline |
Integral type conversions
value | Value to push |
|
inline |
User-defined conversion.
Requires the existence of: mc_rtc::Configuration mc_rtc::ConfigurationLoader<T>::save(const T&, Args ...);
value | Value to push |
void mc_rtc::Configuration::push | ( | double | value | ) |
Insert a double element into an array.
void mc_rtc::Configuration::push | ( | int16_t | value | ) |
Insert a int16_t element int16_to an array.
void mc_rtc::Configuration::push | ( | int32_t | value | ) |
Insert a int32_t element int32_to an array.
void mc_rtc::Configuration::push | ( | int64_t | value | ) |
Insert a int64_t element int64_to an array.
void mc_rtc::Configuration::push | ( | int8_t | value | ) |
Insert a int8_t element int8_to an array.
void mc_rtc::Configuration::push | ( | uint16_t | value | ) |
Insert a uint16_t element into an array.
void mc_rtc::Configuration::push | ( | uint32_t | value | ) |
Insert a uint32_t element into an array.
void mc_rtc::Configuration::push | ( | uint64_t | value | ) |
Insert a uint64_t element into an array.
void mc_rtc::Configuration::push | ( | uint8_t | value | ) |
Insert a uint8_t element into an array.
void mc_rtc::Configuration::push_null | ( | ) |
Insert a null value into an array.
If | the underlying Json value is not an array. |
bool mc_rtc::Configuration::remove | ( | const std::string & | key | ) |
Remove a given element
Has no effect if the element is not present.
key | Element to remove |
|
static |
Returns a Configuration with an array as root entry.
This is not valid standard JSON
void mc_rtc::Configuration::save | ( | const std::string & | path, |
bool | pretty = true |
||
) | const |
Save the configuration to a file.
If the path extension is yaml or yml then save in YAML format
path | Path to the configuration file |
pretty | Writes a human-readable file, defaults to true |
size_t mc_rtc::Configuration::size | ( | ) | const |
If the stored value is an array, returns its size, otherwise returns 0.
void mc_rtc::Configuration::toMessagePack | ( | MessagePackBuilder & | builder | ) | const |
Append to an existing MessagePackBuilder.
The whole configuration will be stored in the MessagePack being built
builder | MessagePackBuilder instance |
size_t mc_rtc::Configuration::toMessagePack | ( | std::vector< char > & | data | ) | const |
Convert to MessagePack.
data | Will hold the message data |