Go to the documentation of this file.
25 #include <ArmarXCore/interface/observers/VariantBase.h>
27 #include <ArmarXCore/interface/serialization/JSONSerialization.h>
29 #include <jsoncpp/json/json.h>
53 std::string
toString(const ::Ice::Current& = Ice::emptyCurrent)
const override;
54 void fromString(const ::std::string& jsonString, const ::Ice::Current& = Ice::emptyCurrent)
override;
60 unsigned int size()
const override;
61 bool hasElement(const ::std::string& key)
const override;
63 float getFloat(const ::std::string& key)
const override;
64 double getDouble(const ::std::string& key)
const override;
65 int getInt(const ::std::string& key)
const override;
66 bool getBool(const ::std::string& key)
const override;
67 std::string
getString(const ::std::string& key)
const override;
73 void getArray(
const std::string& key, std::vector<T>& result)
77 if (!arrValue.isArray())
79 throw JSONInvalidDataTypeException();
83 result.resize(arrValue.size());
85 for (
size_t i = 0; i < arrValue.size(); ++i)
87 get(arrValue[
int(i)], result[
int(i)]);
91 void getIntArray(const ::std::string& key, std::vector<int>& result)
override
95 void getFloatArray(const ::std::string& key, std::vector<float>& result)
override
99 void getDoubleArray(const ::std::string& key, std::vector<double>& result)
override
103 void getStringArray(const ::std::string& key, std::vector<std::string>& result)
override
107 void getVariantArray(const ::std::string& key, std::vector<armarx::VariantPtr>& result)
override;
110 template <
typename T>
111 void set(const ::std::string& key,
T val)
116 template <
typename T>
122 template <
typename T>
123 void setArray(const ::std::string& key,
const std::vector<T>& val)
129 arr.resize(val.size());
131 for (
size_t i = 0; i < val.size(); ++i)
137 jsonValue[key] = arr;
140 void setBool(const ::std::string& key,
bool val)
override
144 void setInt(const ::std::string& key,
int val)
override
148 void setFloat(const ::std::string& key,
float val)
override
152 void setDouble(const ::std::string& key,
double val)
override
156 void setString(const ::std::string& key,
const std::string& val)
override
162 void setIntArray(const ::std::string& key,
const std::vector<int>& val)
override
166 void setFloatArray(const ::std::string& key,
const std::vector<float>& val)
override
170 void setDoubleArray(const ::std::string& key,
const std::vector<double>& val)
override
174 void setStringArray(const ::std::string& key,
const std::vector<std::string>& val)
override
178 void setVariantArray(const ::std::string& key,
const std::vector<armarx::VariantBasePtr>& val)
override;
179 void setVariantArray(const ::std::string& key,
const std::vector<armarx::VariantPtr>& val)
override;
209 void reset()
override;
216 std::string
asString(
bool pretty =
false)
const;
221 const Json::Value& getValue(
const std::string& key)
const;
223 void get(
const Json::Value& val,
bool& result)
const;
224 void get(
const Json::Value& val,
int& result)
const;
225 void get(
const Json::Value& val,
float& result)
const;
226 void get(
const Json::Value& val,
double& result)
const;
227 void get(
const Json::Value& val, std::string& result)
const;
void setBool(const ::std::string &key, bool val) override
void setString(unsigned int index, const std::string &val) override
armarx::AbstractObjectSerializerPtr getElement(unsigned int index) const override
bool hasElement(const ::std::string &key) const override
Value
Color maps that associate a color to every float from [0..1].
void append(const armarx::AbstractObjectSerializerPtr &val) override
void setFloat(unsigned int index, float val) override
std::map< std::string, VariantBasePtr > StringVariantBaseMap
void setInt(unsigned int index, int val) override
void setFloatArray(const ::std::string &key, const std::vector< float > &val) override
void setVariantMap(const ::std::string &key, const armarx::StringVariantBaseMap &val) override
static StringVariantBaseMap ConvertToBasicVariantMap(const JSONObjectPtr &serializer, const VariantBasePtr &variant)
void setString(const ::std::string &key, const std::string &val) override
The JSONObject class is used to represent and (de)serialize JSON objects.
double getDouble(const ::std::string &key) const override
void setDouble(unsigned int index, double val) override
void getIntArray(const ::std::string &key, std::vector< int > &result) override
void set(const ::std::string &key, T val)
std::string toString(const ::Ice::Current &=Ice::emptyCurrent) const override
std::string getString(const ::std::string &key) const override
void getDoubleArray(const ::std::string &key, std::vector< double > &result) override
void getVariantMap(const ::std::string &key, armarx::StringVariantBaseMap &result) override
const Json::Value & getJsonValue() const
void setElement(const ::std::string &key, const armarx::AbstractObjectSerializerPtr &obj) override
void setIntArray(const ::std::string &key, const std::vector< int > &val) override
void setDoubleArray(const ::std::string &key, const std::vector< double > &val) override
armarx::AbstractObjectSerializerPtr createElement() const override
void fromString(const ::std::string &jsonString, const ::Ice::Current &=Ice::emptyCurrent) override
std::vector< std::string > getElementNames() const override
void setBool(unsigned int index, bool val) override
void setFloat(const ::std::string &key, float val) override
void setDouble(const ::std::string &key, double val) override
void getArray(const std::string &key, std::vector< T > &result)
void merge(const armarx::AbstractObjectSerializerPtr &val) override
void set(int index, T val)
void getVariantArray(const ::std::string &key, std::vector< armarx::VariantPtr > &result) override
void setInt(const ::std::string &key, int val) override
void setStringArray(const ::std::string &key, const std::vector< std::string > &val) override
void getStringArray(const ::std::string &key, std::vector< std::string > &result) override
void setVariantArray(const ::std::string &key, const std::vector< armarx::VariantBasePtr > &val) override
JSONObject(armarx::ElementType nodeType=armarx::ElementTypes::eObject, const Ice::CommunicatorPtr ic=Ice::CommunicatorPtr())
int getInt(const ::std::string &key) const override
void getFloatArray(const ::std::string &key, std::vector< float > &result) override
unsigned int size() const override
float getFloat(const ::std::string &key) const override
std::string asString(bool pretty=false) const
void setArray(const ::std::string &key, const std::vector< T > &val)
void setElementType(armarx::ElementType nodeType, const ::Ice::Current &=Ice::emptyCurrent) override
armarx::ElementType getElementType(const ::Ice::Current &=Ice::emptyCurrent) const override
bool getBool(const ::std::string &key) const override
This file offers overloads of toIce() and fromIce() functions for STL container types.