*/
#include <map>
+#include <json/json.h>
#include <ContextTypes.h>
-#include <CtxJson.h>
#include <Tuple.h>
#include <app_history_internal.h>
#include <app_history_types_internal.h>
} _cx_history_handle;
typedef struct _context_history_filter_handle_s {
- ctx::CtxJson jfilter;
+ Json::Value jfilter;
} _cx_history_filter_handle;
typedef struct _context_history_list_handle_s {
// Check filter and its data type
IF_FAIL_RETURN_TAG(check_filter_data_int(filter_type, val), CONTEXT_HISTORY_ERROR_INVALID_PARAMETER, _E, "Filter type mismatched");
- filter->jfilter.set(NULL, filter_str.c_str(), val);
+ filter->jfilter[filter_str] = val;
return CONTEXT_HISTORY_ERROR_NONE;
}
// Check filter and its data type
IF_FAIL_RETURN_TAG(check_filter_data_string(filter_type, val), CONTEXT_HISTORY_ERROR_INVALID_PARAMETER, _E, "Filter type mismatched");
- filter->jfilter.set(NULL, filter_str.c_str(), val);
+ filter->jfilter[filter_str] = val;
return CONTEXT_HISTORY_ERROR_NONE;
}
*list = new(std::nothrow) _cx_history_list_handle();
ASSERT_ALLOC(*list);
- int err = _ctx_history_query(data_type_str.c_str(), filter ? filter->jfilter.str().c_str() : "", &((*list)->cursor));
+ std::string filterStr;
+ if (filter) {
+ Json::FastWriter fw;
+ fw.omitEndingLineFeed();
+ filterStr = fw.write(filter->jfilter);
+ }
+
+ int err = _ctx_history_query(data_type_str.c_str(), filterStr.c_str(), &((*list)->cursor));
IF_FAIL_RETURN_TAG(err == E_NONE, err, _E, "Query failed");
return CONTEXT_HISTORY_ERROR_NONE;
}
bool found = true;
- std::list<std::string> keys;
- filter->jfilter.getKeys(&keys);
+ std::vector<std::string> keys = filter->jfilter.getMemberNames();
- for (std::list<std::string>::iterator it = keys.begin(); it != keys.end(); ++it) {
- std::string key = (*it);
+ for (auto& key : keys) {
found = false;
for (int i = 1; i < FILTER_KEY_LIMIT; ++i) {
if (allowed[i] && key == filter_key[i]) {