IQRF Gateway Daemon
Namespaces | Functions
JsonUtils.h File Reference
#include "IqrfLogging.h"
#include "rapidjson/rapidjson.h"
#include "rapidjson/document.h"
#include "rapidjson/istreamwrapper.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/prettywriter.h"
#include <vector>
#include <utility>
#include <stdexcept>

Go to the source code of this file.

Namespaces

 jutils
 Rapid Json values manipulation functions.
 

Functions

void jutils::parseJsonFile (const std::string &fname, rapidjson::Document &json)
 Parse file with Json content. More...
 
void jutils::parseIstream (std::istream &istr, rapidjson::Document &json)
 Parse stream with Json content. More...
 
void jutils::parseString (const std::string &str, rapidjson::Document &json)
 Parse string with Json content. More...
 
template<typename T >
void jutils::assertIs (const std::string &name, const rapidjson::Value &v)
 Assert json value holds T type. More...
 
template<>
void jutils::assertIs< std::string > (const std::string &name, const rapidjson::Value &v)
 Assert json value holds std::string type. More...
 
void jutils::assertIsObject (const std::string &name, const rapidjson::Value &v)
 Assert json value holds Json object. More...
 
void jutils::assertIsArray (const std::string &name, const rapidjson::Value &v)
 Assert json value holds Json array. More...
 
const rapidjson::Value::ConstMemberIterator jutils::getMember (const std::string &name, const rapidjson::Value &jsonValue)
 Get rapidjson member iterator. More...
 
template<typename T >
jutils::getMemberAs (const std::string &name, const rapidjson::Value &v)
 Get member with value of type T. More...
 
template<>
std::string jutils::getMemberAs< std::string > (const std::string &name, const rapidjson::Value &v)
 Get member with value of type std::string. More...
 
const rapidjson::Value & jutils::getMemberAsObject (const std::string &name, const rapidjson::Value &v)
 Get member with value of type Json object. More...
 
template<typename T >
std::vector< T > jutils::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 > jutils::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 >
jutils::getPossibleMemberAs (const std::string &name, const rapidjson::Value &v, T defaultVal)
 Get possible member with value of type T. More...
 
template<>
std::string jutils::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 > jutils::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 jutils::getMemberIfExistsAs (const std::string &name, const rapidjson::Value &v, T &member)
 Get member value if exists of template type T. More...
 
template<>
bool jutils::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...