Routines for converting the Param data to json.
This commit is contained in:
parent
0cbd0d16a1
commit
466920bf4e
3 changed files with 52 additions and 2 deletions
38
pglab/ParamListJson.cpp
Normal file
38
pglab/ParamListJson.cpp
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
#include "ParamListJson.h"
|
||||||
|
#include "ParamListModel.h"
|
||||||
|
|
||||||
|
Json::Value ParamToJson(const Param ¶m)
|
||||||
|
{
|
||||||
|
Json::Value v;
|
||||||
|
v["type"] = (int)param.type.toUtf8().data();
|
||||||
|
v["value"] = param.value.toUtf8().data();
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
Param ParamFromJson(const Json::Value &json)
|
||||||
|
{
|
||||||
|
Param p;
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
Json::Value ParamListModelToJson(const t_ParamList &list)
|
||||||
|
{
|
||||||
|
Json::Value root;
|
||||||
|
for (const auto ¶m : list) {
|
||||||
|
root.append(ParamToJson(param));
|
||||||
|
}
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
t_ParamList ParamListModelFromJson(const Json::Value &json)
|
||||||
|
{
|
||||||
|
t_ParamList result;
|
||||||
|
if (json.isArray()) {
|
||||||
|
result.reserve(json.size());
|
||||||
|
for (auto &e : json) {
|
||||||
|
result.push_back(ParamFromJson(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
10
pglab/ParamListJson.h
Normal file
10
pglab/ParamListJson.h
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef PARAMLISTJSON_H
|
||||||
|
#define PARAMLISTJSON_H
|
||||||
|
|
||||||
|
#include "json/json.h"
|
||||||
|
|
||||||
|
class ParamListModel;
|
||||||
|
|
||||||
|
Json::Value ParamListModelToJson(const t_ParamList &list);
|
||||||
|
|
||||||
|
#endif // PARAMLISTJSON_H
|
||||||
|
|
@ -69,7 +69,8 @@ PgDatabaseCatalogue.cpp \
|
||||||
CodeBuilderConfiguration.cpp \
|
CodeBuilderConfiguration.cpp \
|
||||||
ResultTableModelUtil.cpp \
|
ResultTableModelUtil.cpp \
|
||||||
BaseTableModel.cpp \
|
BaseTableModel.cpp \
|
||||||
QueryParamListController.cpp
|
QueryParamListController.cpp \
|
||||||
|
ParamListJson.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
QueryResultModel.h \
|
QueryResultModel.h \
|
||||||
|
|
@ -113,7 +114,8 @@ PgDatabaseCatalogue.h \
|
||||||
CodeBuilderConfiguration.h \
|
CodeBuilderConfiguration.h \
|
||||||
ResultTableModelUtil.h \
|
ResultTableModelUtil.h \
|
||||||
BaseTableModel.h \
|
BaseTableModel.h \
|
||||||
QueryParamListController.h
|
QueryParamListController.h \
|
||||||
|
ParamListJson.h
|
||||||
|
|
||||||
FORMS += mainwindow.ui \
|
FORMS += mainwindow.ui \
|
||||||
DatabaseWindow.ui \
|
DatabaseWindow.ui \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue