#include <iomanip>
#include <json-glib/json-glib.h>
#include <Types.h>
-#include <Json.h>
+#include <CtxJson1.h>
#define PATH_DELIM '.'
#define MAX_PRECISION 15
return out;
}
-SO_EXPORT Json::Json() :
+SO_EXPORT CtxJson1::CtxJson1() :
__jsonNode(NULL)
{
JsonObject *obj = json_object_new();
- IF_FAIL_VOID_TAG(obj, _E, "Json object construction failed");
+ IF_FAIL_VOID_TAG(obj, _E, "CtxJson1 object construction failed");
__jsonNode = json_node_new(JSON_NODE_OBJECT);
if (!__jsonNode) {
json_object_unref(obj);
- _E("Json object construction failed");
+ _E("CtxJson1 object construction failed");
}
json_node_set_object(__jsonNode, obj);
json_object_unref(obj);
}
-SO_EXPORT Json::Json(const Json &j)
+SO_EXPORT CtxJson1::CtxJson1(const CtxJson1 &j)
: __jsonNode(NULL)
{
__jsonNode = json_node_copy(j.__jsonNode);
- IF_FAIL_VOID_TAG(__jsonNode, _E, "Json object construction failed");
+ IF_FAIL_VOID_TAG(__jsonNode, _E, "CtxJson1 object construction failed");
}
-SO_EXPORT Json::Json(const char *s)
+SO_EXPORT CtxJson1::CtxJson1(const char *s)
: __jsonNode(NULL)
{
if (s) {
}
}
-SO_EXPORT Json::Json(const std::string &s)
+SO_EXPORT CtxJson1::CtxJson1(const std::string &s)
: __jsonNode(NULL)
{
if (s.empty()) {
}
}
-SO_EXPORT Json::~Json()
+SO_EXPORT CtxJson1::~CtxJson1()
{
__release();
}
-void Json::__parse(const char *s)
+void CtxJson1::__parse(const char *s)
{
gboolean result;
JsonParser *parser = NULL;
g_object_unref(parser);
}
-void Json::__release()
+void CtxJson1::__release()
{
if (__jsonNode) {
json_node_free(__jsonNode);
}
}
-SO_EXPORT bool Json::valid()
+SO_EXPORT bool CtxJson1::valid()
{
return (__jsonNode != NULL);
}
-SO_EXPORT Json& Json::operator=(const Json &j)
+SO_EXPORT CtxJson1& CtxJson1::operator=(const CtxJson1 &j)
{
__release();
__jsonNode = json_node_copy(j.__jsonNode);
if (!__jsonNode) {
- _E("Json object copy failed");
+ _E("CtxJson1 object copy failed");
}
return *this;
}
-SO_EXPORT Json& Json::operator=(const char *s)
+SO_EXPORT CtxJson1& CtxJson1::operator=(const char *s)
{
__release();
if (s) {
return *this;
}
-SO_EXPORT Json& Json::operator=(const std::string &s)
+SO_EXPORT CtxJson1& CtxJson1::operator=(const std::string &s)
{
__release();
if (s.empty()) {
return *this;
}
-SO_EXPORT bool Json::operator==(const Json &rhs)
+SO_EXPORT bool CtxJson1::operator==(const CtxJson1 &rhs)
{
return __nodeEq(__jsonNode, rhs.__jsonNode);
}
-SO_EXPORT bool Json::operator!=(const Json &rhs)
+SO_EXPORT bool CtxJson1::operator!=(const CtxJson1 &rhs)
{
return !operator==(rhs);
}
-char* Json::__strDup()
+char* CtxJson1::__strDup()
{
- IF_FAIL_RETURN_TAG(__jsonNode, NULL, _E, "Json object not initialized");
+ IF_FAIL_RETURN_TAG(__jsonNode, NULL, _E, "CtxJson1 object not initialized");
JsonGenerator *jgen = NULL;
char *output = NULL;
return NULL;
}
-SO_EXPORT std::string Json::str()
+SO_EXPORT std::string CtxJson1::str()
{
std::string output;
char *_s = __strDup();
return jobj;
}
-SO_EXPORT bool Json::set(const char *path, const char *key, Json &val)
+SO_EXPORT bool CtxJson1::set(const char *path, const char *key, CtxJson1 &val)
{
- IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "Json object not initialized");
+ IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "CtxJson1 object not initialized");
IF_FAIL_RETURN_TAG(key && val.__jsonNode, false, _E, "Invalid parameter");
JsonObject *jobj = __traverse(__jsonNode, path, true);
json_object_set_member(jobj, key, val.__jsonNode);
val.__jsonNode = NULL;
- val = Json();
+ val = CtxJson1();
return true;
}
-SO_EXPORT bool Json::set(const char *path, const char *key, int val)
+SO_EXPORT bool CtxJson1::set(const char *path, const char *key, int val)
{
return set(path, key, static_cast<int64_t>(val));
}
-SO_EXPORT bool Json::set(const char *path, const char *key, int64_t val)
+SO_EXPORT bool CtxJson1::set(const char *path, const char *key, int64_t val)
{
- IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "Json object not initialized");
+ IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "CtxJson1 object not initialized");
IF_FAIL_RETURN_TAG(key, false, _E, "Invalid parameter");
JsonObject *jobj = __traverse(__jsonNode, path, true);
return true;
}
-SO_EXPORT bool Json::set(const char *path, const char *key, double val)
+SO_EXPORT bool CtxJson1::set(const char *path, const char *key, double val)
{
return set(path, key, __double_to_string(val));
}
-SO_EXPORT bool Json::set(const char *path, const char *key, std::string val)
+SO_EXPORT bool CtxJson1::set(const char *path, const char *key, std::string val)
{
- IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "Json object not initialized");
+ IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "CtxJson1 object not initialized");
IF_FAIL_RETURN_TAG(key, false, _E, "Invalid parameter");
JsonObject *jobj = __traverse(__jsonNode, path, true);
return true;
}
-SO_EXPORT bool Json::set(const char *path, const char *key, GVariant *val)
+SO_EXPORT bool CtxJson1::set(const char *path, const char *key, GVariant *val)
{
#if JSON_CHECK_VERSION(0, 14, 0)
- IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "Json object not initialized");
+ IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "CtxJson1 object not initialized");
IF_FAIL_RETURN_TAG(key && val, false, _E, "Invalid parameter");
const gchar *typeStr = g_variant_get_type_string(val);
json_node_t *node = json_gvariant_serialize(val);
IF_FAIL_RETURN_TAG(node, false, _E, "GVariant manipulation failed");
- Json gvarJson;
+ CtxJson1 gvarJson;
gvarJson.set(NULL, GVAR_TYPES, std::string(typeStr));
json_object_set_member(json_node_get_object(gvarJson.__jsonNode), GVAR_VALUES, node);
#endif
}
-SO_EXPORT bool Json::get(const char *path, const char *key, Json *val)
+SO_EXPORT bool CtxJson1::get(const char *path, const char *key, CtxJson1 *val)
{
- IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "Json object not initialized");
+ IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "CtxJson1 object not initialized");
IF_FAIL_RETURN_TAG(key && val, false, _E, "Invalid parameter");
JsonObject *jobj = NULL;
return node;
}
-SO_EXPORT bool Json::get(const char *path, const char *key, int *val)
+SO_EXPORT bool CtxJson1::get(const char *path, const char *key, int *val)
{
- IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "Json object not initialized");
+ IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "CtxJson1 object not initialized");
IF_FAIL_RETURN_TAG(key && val, false, _E, "Invalid parameter");
int64_t v;
return false;
}
-SO_EXPORT bool Json::get(const char *path, const char *key, int64_t *val)
+SO_EXPORT bool CtxJson1::get(const char *path, const char *key, int64_t *val)
{
- IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "Json object not initialized");
+ IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "CtxJson1 object not initialized");
IF_FAIL_RETURN_TAG(key && val, false, _E, "Invalid parameter");
JsonNode *node = __get_value_node(__jsonNode, path, key);
return true;
}
-SO_EXPORT bool Json::get(const char *path, const char *key, double *val)
+SO_EXPORT bool CtxJson1::get(const char *path, const char *key, double *val)
{
- IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "Json object not initialized");
+ IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "CtxJson1 object not initialized");
IF_FAIL_RETURN_TAG(key && val, false, _E, "Invalid parameter");
JsonNode *node = __get_value_node(__jsonNode, path, key);
return true;
}
-SO_EXPORT bool Json::get(const char *path, const char *key, std::string *val)
+SO_EXPORT bool CtxJson1::get(const char *path, const char *key, std::string *val)
{
- IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "Json object not initialized");
+ IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "CtxJson1 object not initialized");
IF_FAIL_RETURN_TAG(key && val, false, _E, "Invalid parameter");
JsonNode *node = __get_value_node(__jsonNode, path, key);
return true;
}
-SO_EXPORT bool Json::get(const char *path, const char *key, GVariant **val)
+SO_EXPORT bool CtxJson1::get(const char *path, const char *key, GVariant **val)
{
#if JSON_CHECK_VERSION(0, 14, 0)
- IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "Json object not initialized");
+ IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "CtxJson1 object not initialized");
IF_FAIL_RETURN_TAG(key && val, false, _E, "Invalid parameter");
bool ret;
- Json gvarJson;
+ CtxJson1 gvarJson;
ret = get(path, key, &gvarJson);
IF_FAIL_RETURN(ret, false);
ret = gvarJson.get(NULL, GVAR_TYPES, &gvarTypes);
IF_FAIL_RETURN(ret, false);
- Json gvarValues;
+ CtxJson1 gvarValues;
ret = gvarJson.get(NULL, GVAR_VALUES, &gvarValues);
IF_FAIL_RETURN(ret, false);
#endif
}
-SO_EXPORT bool Json::remove(const char *path, const char *key)
+SO_EXPORT bool CtxJson1::remove(const char *path, const char *key)
{
- IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "Json object not initialized");
+ IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "CtxJson1 object not initialized");
IF_FAIL_RETURN_TAG(key, false, _E, "Invalid parameter");
JsonObject *jobj = __traverse(__jsonNode, path, true);
return json_node_get_array(node);
}
-SO_EXPORT int Json::getSize(const char *path, const char *key)
+SO_EXPORT int CtxJson1::getSize(const char *path, const char *key)
{
- IF_FAIL_RETURN_TAG(this->__jsonNode, -1, _E, "Json object not initialized");
+ IF_FAIL_RETURN_TAG(this->__jsonNode, -1, _E, "CtxJson1 object not initialized");
IF_FAIL_RETURN_TAG(key, -1, _E, "Invalid parameter");
JsonArray *jarr = __get_array(__jsonNode, path, key, false);
return json_array_get_length(jarr);
}
-SO_EXPORT bool Json::append(const char *path, const char *key, Json &val)
+SO_EXPORT bool CtxJson1::append(const char *path, const char *key, CtxJson1 &val)
{
- IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "Json object not initialized");
+ IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "CtxJson1 object not initialized");
IF_FAIL_RETURN_TAG(key && val.__jsonNode, false, _E, "Invalid parameter");
JsonArray *arr = __get_array(__jsonNode, path, key, true);
json_array_add_element(arr, val.__jsonNode);
val.__jsonNode = NULL;
- val = Json();
+ val = CtxJson1();
return true;
}
-SO_EXPORT bool Json::append(const char *path, const char *key, int val)
+SO_EXPORT bool CtxJson1::append(const char *path, const char *key, int val)
{
return append(path, key, static_cast<int64_t>(val));
}
-SO_EXPORT bool Json::append(const char *path, const char *key, int64_t val)
+SO_EXPORT bool CtxJson1::append(const char *path, const char *key, int64_t val)
{
- IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "Json object not initialized");
+ IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "CtxJson1 object not initialized");
IF_FAIL_RETURN_TAG(key, false, _E, "Invalid parameter");
JsonArray *arr = __get_array(__jsonNode, path, key, true);
return true;
}
-SO_EXPORT bool Json::append(const char *path, const char *key, double val)
+SO_EXPORT bool CtxJson1::append(const char *path, const char *key, double val)
{
return append(path, key, __double_to_string(val));
}
-SO_EXPORT bool Json::append(const char *path, const char *key, std::string val)
+SO_EXPORT bool CtxJson1::append(const char *path, const char *key, std::string val)
{
- IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "Json object not initialized");
+ IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "CtxJson1 object not initialized");
IF_FAIL_RETURN_TAG(key, false, _E, "Invalid parameter");
JsonArray *arr = __get_array(__jsonNode, path, key, true);
return node;
}
-SO_EXPORT bool Json::setAt(const char *path, const char *key, int index, Json &val)
+SO_EXPORT bool CtxJson1::setAt(const char *path, const char *key, int index, CtxJson1 &val)
{
- IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "Json object not initialized");
+ IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "CtxJson1 object not initialized");
IF_FAIL_RETURN_TAG(val.__jsonNode && key && index >= 0, false, _E, "Invalid parameter");
JsonNode *node = __get_array_elem(__jsonNode, path, key, index);
json_node_set_object(node, obj);
json_node_free(val.__jsonNode);
val.__jsonNode = NULL;
- val = Json();
+ val = CtxJson1();
return true;
}
-SO_EXPORT bool Json::setAt(const char *path, const char *key, int index, int val)
+SO_EXPORT bool CtxJson1::setAt(const char *path, const char *key, int index, int val)
{
return setAt(path, key, index, static_cast<int64_t>(val));
}
-SO_EXPORT bool Json::setAt(const char *path, const char *key, int index, int64_t val)
+SO_EXPORT bool CtxJson1::setAt(const char *path, const char *key, int index, int64_t val)
{
- IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "Json object not initialized");
+ IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "CtxJson1 object not initialized");
IF_FAIL_RETURN_TAG(key && index >= 0, false, _E, "Invalid parameter");
JsonNode *node = __get_array_elem(__jsonNode, path, key, index);
return true;
}
-SO_EXPORT bool Json::setAt(const char *path, const char *key, int index, double val)
+SO_EXPORT bool CtxJson1::setAt(const char *path, const char *key, int index, double val)
{
return setAt(path, key, index, __double_to_string(val));
}
-SO_EXPORT bool Json::setAt(const char *path, const char *key, int index, std::string val)
+SO_EXPORT bool CtxJson1::setAt(const char *path, const char *key, int index, std::string val)
{
- IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "Json object not initialized");
+ IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "CtxJson1 object not initialized");
IF_FAIL_RETURN_TAG(key && index >= 0, false, _E, "Invalid parameter");
JsonNode *node = __get_array_elem(__jsonNode, path, key, index);
return true;
}
-SO_EXPORT bool Json::getAt(const char *path, const char *key, int index, Json *val)
+SO_EXPORT bool CtxJson1::getAt(const char *path, const char *key, int index, CtxJson1 *val)
{
- IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "Json object not initialized");
+ IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "CtxJson1 object not initialized");
IF_FAIL_RETURN_TAG(key && val && index >= 0, false, _E, "Invalid parameter");
JsonNode *node = __get_array_elem(__jsonNode, path, key, index);
return true;
}
-SO_EXPORT bool Json::getAt(const char *path, const char *key, int index, int *val)
+SO_EXPORT bool CtxJson1::getAt(const char *path, const char *key, int index, int *val)
{
- IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "Json object not initialized");
+ IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "CtxJson1 object not initialized");
IF_FAIL_RETURN_TAG(key && val && index >= 0, false, _E, "Invalid parameter");
int64_t v;
return false;
}
-SO_EXPORT bool Json::getAt(const char *path, const char *key, int index, int64_t *val)
+SO_EXPORT bool CtxJson1::getAt(const char *path, const char *key, int index, int64_t *val)
{
- IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "Json object not initialized");
+ IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "CtxJson1 object not initialized");
IF_FAIL_RETURN_TAG(key && val && index >= 0, false, _E, "Invalid parameter");
JsonNode *node = __get_array_elem(__jsonNode, path, key, index);
return true;
}
-SO_EXPORT bool Json::getAt(const char *path, const char *key, int index, double *val)
+SO_EXPORT bool CtxJson1::getAt(const char *path, const char *key, int index, double *val)
{
- IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "Json object not initialized");
+ IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "CtxJson1 object not initialized");
IF_FAIL_RETURN_TAG(key && val && index >= 0, false, _E, "Invalid parameter");
JsonNode *node = __get_array_elem(__jsonNode, path, key, index);
return true;
}
-SO_EXPORT bool Json::getAt(const char *path, const char *key, int index, std::string *val)
+SO_EXPORT bool CtxJson1::getAt(const char *path, const char *key, int index, std::string *val)
{
- IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "Json object not initialized");
+ IF_FAIL_RETURN_TAG(this->__jsonNode, false, _E, "CtxJson1 object not initialized");
IF_FAIL_RETURN_TAG(key && val && index >= 0, false, _E, "Invalid parameter");
JsonNode *node = __get_array_elem(__jsonNode, path, key, index);
return true;
}
-bool Json::__getMembers(json_node_t *node, std::list<std::string> &list)
+bool CtxJson1::__getMembers(json_node_t *node, std::list<std::string> &list)
{
IF_FAIL_RETURN(node, false);
list.clear();
JsonObject *jobj = json_node_get_object(node);
- IF_FAIL_RETURN_TAG(jobj, false, _E, "Getting Json object failed");
+ IF_FAIL_RETURN_TAG(jobj, false, _E, "Getting CtxJson1 object failed");
GList *members = json_object_get_members(jobj);
IF_FAIL_RETURN(members, true);
return true;
}
-SO_EXPORT bool Json::getKeys(std::list<std::string>* list)
+SO_EXPORT bool CtxJson1::getKeys(std::list<std::string>* list)
{
IF_FAIL_RETURN_TAG(list, false, _E, "Invalid parameter");
return __getMembers(__jsonNode, *list);
}
-bool Json::__nodeEq(json_node_t *lhs, json_node_t *rhs)
+bool CtxJson1::__nodeEq(json_node_t *lhs, json_node_t *rhs)
{
IF_FAIL_RETURN(lhs && rhs, false);
return true;
}
-bool Json::__valueEq(json_node_t *lhs, json_node_t *rhs)
+bool CtxJson1::__valueEq(json_node_t *lhs, json_node_t *rhs)
{
GType ltype = json_node_get_value_type(lhs);
GType rtype = json_node_get_value_type(rhs);
}
}
-bool Json::__objectEq(json_node_t *lhs, json_node_t *rhs)
+bool CtxJson1::__objectEq(json_node_t *lhs, json_node_t *rhs)
{
std::list<std::string> lm, rm;
IF_FAIL_RETURN(__getMembers(lhs, lm), false);
return true;
}
-bool Json::__arrayEq(json_node_t *lhs, json_node_t *rhs)
+bool CtxJson1::__arrayEq(json_node_t *lhs, json_node_t *rhs)
{
JsonArray *larr = json_node_get_array(lhs);
JsonArray *rarr = json_node_get_array(rhs);