Flatland
|
Public Types | |
enum | NodeTypeCheck { MAP, LIST, NO_CHECK } |
Public Member Functions | |
YamlReader () | |
Default constructor for yaml reader, initialize with a empty yaml Node. | |
YamlReader (const YAML::Node &node) | |
Constructor with a given node. More... | |
YamlReader (const std::string &path) | |
Constructor with a given path to a yaml file, throws exception on failure. More... | |
void | SetErrorInfo (std::string entry_location, std::string entry_name="") |
Use this method to set the entry location and entry name for error message purposes. More... | |
void | SetFile (const std::string &file_path) |
Use this method to set the file location of the yaml node. More... | |
void | EnsureAccessedAllKeys () |
This method checks all keys in the yaml node are used, otherwise it throws an exception. | |
YAML::Node | Node () |
bool | IsNodeNull () |
int | NodeSize () |
YamlReader | Subnode (int index, NodeTypeCheck type_check, std::string sub_node_location="") |
Get one of the subnode using a index, throws exception on failure, file path is inherited from the parent. More... | |
YamlReader | Subnode (const std::string &key, NodeTypeCheck type_check, std::string sub_node_location="") |
Get one of the subnode using a key, throws exception on failure, file path is inherited from the parent. More... | |
YamlReader | SubnodeOpt (const std::string &key, NodeTypeCheck type_check, std::string sub_node_location="") |
Optionally get one of the subnode using a key, throws exception on failure, file path is inherited from the parent. More... | |
template<typename T > | |
T | As () |
Convert the current node in yaml reader to a given template type. It uses yaml-cpp's as<T>() function, you could specify conversion for custom datatypes using yaml cpp's documented ways, this method throws exception on failure. More... | |
template<typename T > | |
std::vector< T > | AsList (int min_size, int max_size) |
Convert the current node to a list of given type, throws exception on failure. More... | |
template<typename T , int N> | |
std::array< T, N > | AsArray () |
Convert the current node to a array of given type, throws exception on failure. More... | |
template<typename T > | |
T | Get (const std::string &key) |
Get subnode with a given key and converted to the given type, throws on failure. More... | |
template<typename T > | |
T | Get (const std::string &key, const T &default_val) |
Optionally get subnode with a given key and converted to the given type, throws on failure. More... | |
template<typename T > | |
std::vector< T > | GetList (const std::string &key, int min_size, int max_size) |
Get subnode with a given key and converted to list of the given type, throws on failure. More... | |
template<typename T > | |
std::vector< T > | GetList (const std::string &key, const std::vector< T > default_val, int min_size, int max_size) |
Optionally get subnode with a given key and converted to list of the given type, throws on failure. More... | |
template<typename T , int N> | |
std::array< T, N > | GetArray (const std::string &key) |
Get subnode with a given key and converted to array of the given type, throws on failure. More... | |
template<typename T , int N> | |
std::array< T, N > | GetArray (const std::string &key, const std::array< T, N > default_val) |
Optionally get subnode with a given key and converted to array of a given type, throws on failure. More... | |
Vec2 | GetVec2 (const std::string &key) |
Vec2 | GetVec2 (const std::string &key, const Vec2 &default_val) |
Color | GetColor (const std::string &key, const Color &default_val) |
Pose | GetPose (const std::string &key) |
Pose | GetPose (const std::string &key, const Pose &default_val) |
Public Attributes | |
YAML::Node | node_ |
The YAML Node this processes. | |
std::set< std::string > | accessed_keys_ |
std::string | filename_ |
< location of the entry, used to show where the error come from More... | |
std::string | file_path_ |
std::string | entry_location_ |
name of the yaml entry, used to show where the error come from | |
std::string | entry_name_ |
std::string | fmt_in_ |
formatted entry location for display | |
std::string | fmt_name_ |
formatted entry location for display | |
flatland_server::YamlReader::YamlReader | ( | const YAML::Node & | node | ) |
Constructor with a given node.
[in] | node | A Yaml node to get data from |
flatland_server::YamlReader::YamlReader | ( | const std::string & | path | ) |
Constructor with a given path to a yaml file, throws exception on failure.
[in] | path | Path to the yaml file |
T flatland_server::YamlReader::As | ( | ) |
Convert the current node in yaml reader to a given template type. It uses yaml-cpp's as<T>() function, you could specify conversion for custom datatypes using yaml cpp's documented ways, this method throws exception on failure.
std::array< T, N > flatland_server::YamlReader::AsArray | ( | ) |
Convert the current node to a array of given type, throws exception on failure.
std::vector< T > flatland_server::YamlReader::AsList | ( | int | min_size, |
int | max_size | ||
) |
Convert the current node to a list of given type, throws exception on failure.
T flatland_server::YamlReader::Get | ( | const std::string & | key | ) |
Get subnode with a given key and converted to the given type, throws on failure.
[in] | key | Key to access the subnode |
T flatland_server::YamlReader::Get | ( | const std::string & | key, |
const T & | default_val | ||
) |
Optionally get subnode with a given key and converted to the given type, throws on failure.
[in] | key | Key to access the subnode |
[in] | default_val | Default value |
std::array< T, N > flatland_server::YamlReader::GetArray | ( | const std::string & | key | ) |
Get subnode with a given key and converted to array of the given type, throws on failure.
[in] | key | Key to access the subnode |
std::array< T, N > flatland_server::YamlReader::GetArray | ( | const std::string & | key, |
const std::array< T, N > | default_val | ||
) |
Optionally get subnode with a given key and converted to array of a given type, throws on failure.
[in] | key | Key to access the subnode |
[in] | default_val | Default value |
std::vector< T > flatland_server::YamlReader::GetList | ( | const std::string & | key, |
int | min_size, | ||
int | max_size | ||
) |
Get subnode with a given key and converted to list of the given type, throws on failure.
[in] | key | Key to access the subnode |
[in] | min_size | Minimum size of the list, -1 to ignore |
[in] | max_size | Maximum size of the list, -1 to ignore |
std::vector< T > flatland_server::YamlReader::GetList | ( | const std::string & | key, |
const std::vector< T > | default_val, | ||
int | min_size, | ||
int | max_size | ||
) |
Optionally get subnode with a given key and converted to list of the given type, throws on failure.
[in] | key | Key to access the subnode |
[in] | default_val | Default value |
[in] | min_size | Minimum size of the list, -1 to ignore |
[in] | max_size | Maximum size of the list, -1 to ignore |
Pose flatland_server::YamlReader::GetPose | ( | const std::string & | key | ) |
Vec2 flatland_server::YamlReader::GetVec2 | ( | const std::string & | key | ) |
bool flatland_server::YamlReader::IsNodeNull | ( | ) |
YAML::Node flatland_server::YamlReader::Node | ( | ) |
int flatland_server::YamlReader::NodeSize | ( | ) |
void flatland_server::YamlReader::SetErrorInfo | ( | std::string | entry_location, |
std::string | entry_name = "" |
||
) |
Use this method to set the entry location and entry name for error message purposes.
[in] | entry_location | Location of the entry, use "_NONE_" for no entry, empty string indicates keep current value |
[in] | entry_name | Name of the entry, optional, use "_NONE_" for no entry, empty string indicates keep current value |
void flatland_server::YamlReader::SetFile | ( | const std::string & | file_path | ) |
Use this method to set the file location of the yaml node.
[in] | file_path | path to the file, use "_NONE_" for empty string, file_path with empty string will keep current path |
YamlReader flatland_server::YamlReader::Subnode | ( | int | index, |
NodeTypeCheck | type_check, | ||
std::string | sub_node_location = "" |
||
) |
Get one of the subnode using a index, throws exception on failure, file path is inherited from the parent.
[in] | index | Index of the subnode |
[in] | type_check | Check if the type of the subnode, i.e. list or map |
[in] | sub_node_location | The error location of the subnode, optional, if not provided or a given an empty string, it will generate the location using its parents entry location and entry name. It also accepts "_NONE_" |
YamlReader flatland_server::YamlReader::Subnode | ( | const std::string & | key, |
NodeTypeCheck | type_check, | ||
std::string | sub_node_location = "" |
||
) |
Get one of the subnode using a key, throws exception on failure, file path is inherited from the parent.
[in] | key | Key of the subnode |
[in] | type_check | Check if the type of the subnode, i.e. list or map |
[in] | sub_node_location | The error location of the subnode, optional, if not provided or a given an empty string, it will generate the location using its parents entry location and entry name. It also accepts "_NONE_" |
YamlReader flatland_server::YamlReader::SubnodeOpt | ( | const std::string & | key, |
NodeTypeCheck | type_check, | ||
std::string | sub_node_location = "" |
||
) |
Optionally get one of the subnode using a key, throws exception on failure, file path is inherited from the parent.
[in] | key | Key of the subnode |
[in] | type_check | Check if the type of the subnode, i.e. list or map |
[in] | sub_node_location | The error location of the subnode, optional, if not provided or a given an empty string, it will generate the location using its parents entry location and entry name. It also accepts "_NONE_" |
std::string flatland_server::YamlReader::filename_ |
< location of the entry, used to show where the error come from
Records of the keys processed