Go to the documentation of this file.
25 #include <ArmarXCore/interface/observers/VariantBase.h>
26 #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,
55 const ::Ice::Current& = Ice::emptyCurrent)
override;
60 getElementType(const ::Ice::Current& = Ice::emptyCurrent)
const override;
62 const ::Ice::Current& = Ice::emptyCurrent)
override;
64 unsigned int size()
const override;
65 bool hasElement(const ::std::string& key)
const override;
67 float getFloat(const ::std::string& key)
const override;
68 double getDouble(const ::std::string& key)
const override;
69 int getInt(const ::std::string& key)
const override;
70 bool getBool(const ::std::string& key)
const override;
71 std::string
getString(const ::std::string& key)
const override;
78 getArray(
const std::string& key, std::vector<T>& result)
82 if (!arrValue.isArray())
84 throw JSONInvalidDataTypeException();
88 result.resize(arrValue.size());
90 for (
size_t i = 0; i < arrValue.size(); ++i)
92 get(arrValue[
int(i)], result[
int(i)]);
97 getIntArray(const ::std::string& key, std::vector<int>& result)
override
103 getFloatArray(const ::std::string& key, std::vector<float>& result)
override
115 getStringArray(const ::std::string& key, std::vector<std::string>& result)
override
121 std::vector<armarx::VariantPtr>& result)
override;
124 template <
typename T>
126 set(const ::std::string& key,
T val)
131 template <
typename T>
138 template <
typename T>
140 setArray(const ::std::string& key,
const std::vector<T>& val)
146 arr.resize(val.size());
148 for (
size_t i = 0; i < val.size(); ++i)
154 jsonValue[key] = arr;
158 setBool(const ::std::string& key,
bool val)
override
164 setInt(const ::std::string& key,
int val)
override
170 setFloat(const ::std::string& key,
float val)
override
176 setDouble(const ::std::string& key,
double val)
override
182 setString(const ::std::string& key,
const std::string& val)
override
191 setIntArray(const ::std::string& key,
const std::vector<int>& val)
override
197 setFloatArray(const ::std::string& key,
const std::vector<float>& val)
override
203 setDoubleArray(const ::std::string& key,
const std::vector<double>& val)
override
209 setStringArray(const ::std::string& key,
const std::vector<std::string>& val)
override
215 const std::vector<armarx::VariantBasePtr>& val)
override;
217 const std::vector<armarx::VariantPtr>& val)
override;
259 void reset()
override;
267 std::string
asString(
bool pretty =
false)
const;
272 const Json::Value& getValue(
const std::string& key)
const;
274 void get(
const Json::Value& val,
bool& result)
const;
275 void get(
const Json::Value& val,
int& result)
const;
276 void get(
const Json::Value& val,
float& result)
const;
277 void get(
const Json::Value& val,
double& result)
const;
278 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.