IQRF Gateway Daemon
|
Rapid Json values manipulation functions. More...
Functions | |
void | parseJsonFile (const std::string &fname, rapidjson::Document &json) |
Parse file with Json content. More... | |
void | parseIstream (std::istream &istr, rapidjson::Document &json) |
Parse stream with Json content. More... | |
void | parseString (const std::string &str, rapidjson::Document &json) |
Parse string with Json content. More... | |
template<typename T > | |
void | assertIs (const std::string &name, const rapidjson::Value &v) |
Assert json value holds T type. More... | |
template<> | |
void | assertIs< std::string > (const std::string &name, const rapidjson::Value &v) |
Assert json value holds std::string type. More... | |
void | assertIsObject (const std::string &name, const rapidjson::Value &v) |
Assert json value holds Json object. More... | |
void | assertIsArray (const std::string &name, const rapidjson::Value &v) |
Assert json value holds Json array. More... | |
const rapidjson::Value::ConstMemberIterator | getMember (const std::string &name, const rapidjson::Value &jsonValue) |
Get rapidjson member iterator. More... | |
template<typename T > | |
T | getMemberAs (const std::string &name, const rapidjson::Value &v) |
Get member with value of type T. More... | |
template<> | |
std::string | getMemberAs< std::string > (const std::string &name, const rapidjson::Value &v) |
Get member with value of type std::string. More... | |
const rapidjson::Value & | getMemberAsObject (const std::string &name, const rapidjson::Value &v) |
Get member with value of type Json object. More... | |
template<typename T > | |
std::vector< T > | getMemberAsVector (const std::string &name, const rapidjson::Value &v) |
Get member with value std::vector of values of template type T. More... | |
template<> | |
std::vector< std::string > | getMemberAsVector< std::string > (const std::string &name, const rapidjson::Value &v) |
Get member with value std::vector of values of type std::string. More... | |
template<typename T > | |
T | getPossibleMemberAs (const std::string &name, const rapidjson::Value &v, T defaultVal) |
Get possible member with value of type T. More... | |
template<> | |
std::string | getPossibleMemberAs< std::string > (const std::string &name, const rapidjson::Value &v, std::string defaultVal) |
Get possible member with value of type std::string. More... | |
template<typename T > | |
std::vector< T > | getPossibleMemberAsVector (const std::string &name, const rapidjson::Value &v, std::vector< T > defaultVal=std::vector< T >()) |
Get possible member with std::vector of values of template type T. More... | |
template<typename T > | |
bool | getMemberIfExistsAs (const std::string &name, const rapidjson::Value &v, T &member) |
Get member value if exists of template type T. More... | |
template<> | |
bool | getMemberIfExistsAs< std::string > (const std::string &name, const rapidjson::Value &v, std::string &member) |
Get member value if exists of template type std::string. More... | |
Rapid Json values manipulation functions.
|
inline |
Assert json value holds T type.
[in] | name | json item name (key) |
[in] | v | json value to be checked |
std::logic_error | in case of assert failure |
Json value named name is checked if its content is template type T else the exception std::logic_error is thrown
|
inline |
Assert json value holds std::string type.
[in] | name | json item name (key) |
[in] | v | json value to be checked |
std::logic_error | in case of assert failure |
Json value named name is checked if its content is std::string else the exception std::logic_error is thrown. It is template specialization for std::string.
|
inline |
Assert json value holds Json array.
[in] | name | json item name (key) |
[in] | v | json value to be checked |
std::logic_error | in case of assert failure |
Json value named name is checked if its content is Json object [...] else the exception std::logic_error is thrown
|
inline |
Assert json value holds Json object.
[in] | name | json item name (key) |
[in] | v | json value to be checked |
std::logic_error | in case of assert failure |
Json value named name is checked if its content is Json object {...} else the exception std::logic_error is thrown If not the exception std::logic_error is thrown
|
inline |
Get rapidjson member iterator.
[in] | name | json item name (key) |
[in] | v | json value to be checked |
std::logic_error | in case the item doesn't exist |
Tries to find Json value named name and if found returns its iterator else the exception std::logic_error is thrown
|
inline |
Get member with value of type T.
[in] | name | json member |
[in] | v | json value to be examined for the member |
std::logic_error | in case the member doesn't exist or has different type |
Tries to find Json member named name and if it is found and holds a value of the template type T it returns the value else the exception std::logic_error is thrown
|
inline |
Get member with value of type std::string.
[in] | name | json member |
[in] | v | json value to be examined for the member |
std::logic_error | in case the member doesn't exist or has different type |
Tries to find Json member named name and if it is found and holds a value of the type std::string it returns the value else the exception std::logic_error is thrown It is template specialization for std::string
|
inline |
Get member with value of type Json object.
[in] | name | json member |
[in] | v | json value to be examined for the member |
std::logic_error | in case the member doesn't exist or has different type |
Tries to find Json member named name and if it is found and holds Json object {...} it returns the object else the exception std::logic_error is thrown
|
inline |
Get member with value std::vector of values of template type T.
[in] | name | json member |
[in] | v | json value to be examined for the member |
std::logic_error | in case the member doesn't exist or has different type |
Tries to find Json member named name and if it is found and holds Json vector [...] of values of template type T it returns the vector else the exception std::logic_error is thrown.
|
inline |
Get member with value std::vector of values of type std::string.
[in] | name | json member |
[in] | v | json value to be examined for the member |
std::logic_error | in case the member doesn't exist or has different type |
Tries to find Json member named name and if it is found and holds Json vector [...] of values of types std::string it returns the vector else the exception std::logic_error is thrown. It is template specialization for std::string.
|
inline |
Get member value if exists of template type T.
[in] | name | json member |
[in] | v | json value to be examined for the member |
[out] | member | the value to be set if the member is found |
std::logic_error | in case the member exists but has different type |
Tries to find Json member named name and if it is found and holds a value of the type std::vector of values of type T it returns the vector else the default one. If the member exists but has different type the exception std::logic_error is thrown.
|
inline |
Get member value if exists of template type std::string.
[in] | name | json member |
[in] | v | json value to be examined for the member |
[out] | member | the value to be set if the member is found |
std::logic_error | in case the member exists but has different type |
Tries to find Json member named name and if it is found and holds a value of the type std::vector of values of type std::string it returns the vector else the default one. If the member exists but has different type the exception std::logic_error is thrown. It is template specialization for std::string.
|
inline |
Get possible member with value of type T.
[in] | name | json member |
[in] | v | json value to be examined for the member |
[in] | defaultVal | the value to be returned if the member is not found |
std::logic_error | in case the member has different type |
Tries to find Json member named name and if it is found and holds a value of the template type T it returns the value else the default one. If the member exists but has different type the exception std::logic_error is thrown.
|
inline |
Get possible member with value of type std::string.
[in] | name | json member |
[in] | v | json value to be examined for the member |
[in] | defaultVal | the value to be returned if the member is not found |
std::logic_error | in case the member has different type |
Tries to find Json member named name and if it is found and holds a value of the type std::string it returns the value else the default one. If the member exists but has different type the exception std::logic_error is thrown. It is template specialization for std::string.
|
inline |
Get possible member with std::vector of values of template type T.
[in] | name | json member |
[in] | v | json value to be examined for the member |
[in] | defaultVal | the value to be returned if the member is not found |
std::logic_error | in case the member has different type |
Tries to find Json member named name and if it is found and holds a value of the type std::vector of values of template type T it returns the vector else the default one. If the member exists but has different type the exception std::logic_error is thrown.
|
inline |
Parse stream with Json content.
[in] | istr | stream object |
[out] | json | value to hold parsed result |
std::logic_error | in case of parse error |
Stream content is taken and parsed to json value by rapidjson functions, In case of json syntax error the exception std::logic_error is thrown
|
inline |
Parse file with Json content.
[in] | fname | file name |
[out] | json | value to hold parsed result |
std::logic_error | in case of parse error |
File fname is parsed to json value by rapidjson functions, In case of file open error or json syntax error the exception std::logic_error is thrown
|
inline |
Parse string with Json content.
[in] | str | string object |
[out] | json | value to hold parsed result |
std::logic_error | in case of parse error |
String content is taken and parsed to json value by rapidjson functions, In case of json syntax error the exception std::logic_error is thrown