You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
|
#ifndef NMDATABASE_H
|
|
|
|
|
|
#define NMDATABASE_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
#include "nmData_global.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "rapidjson/document.h"
|
|
|
|
|
|
#include <QVariant>
|
|
|
|
|
|
#include <QVector>
|
|
|
|
|
|
|
|
|
|
|
|
// 所有数据对象的基类,都需要继承该类实现抽象方法
|
|
|
|
|
|
class NM_DATA_EXPORT nmDataBase : public QObject
|
|
|
|
|
|
{
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
public:
|
|
|
|
|
|
explicit nmDataBase(QObject *parent = nullptr);
|
|
|
|
|
|
~nmDataBase();
|
|
|
|
|
|
|
|
|
|
|
|
//// 将数据存入dom
|
|
|
|
|
|
//virtual void saveDataToDom(rapidjson::Document &dom) = 0;
|
|
|
|
|
|
//// 将数据从dom中读出
|
|
|
|
|
|
//virtual void readDataFromDom(rapidjson::Document &dom) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
// json的写入
|
|
|
|
|
|
void jsonAdd(rapidjson::Document &document, QVariant value, QVector<QVariant> path);
|
|
|
|
|
|
// 读json
|
|
|
|
|
|
void jsonRead(rapidjson::Document &document, QVariant &value, QVector<QVariant> path);
|
|
|
|
|
|
// 读json
|
|
|
|
|
|
void jsonRead(rapidjson::Document &document, int &value, QVector<QVariant> path);
|
|
|
|
|
|
// 读json
|
|
|
|
|
|
void jsonRead(rapidjson::Document &document, double &value, QVector<QVariant> path);
|
|
|
|
|
|
// 读json
|
|
|
|
|
|
void jsonRead(rapidjson::Document &document, QString &value, QVector<QVariant> path);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 将当前 C++ 对象序列化为 RapidJSON Value
|
|
|
|
|
|
// allocator 由调用者(通常是 Document)提供,用于内存分配
|
|
|
|
|
|
// @param allocator RapidJSON的内存分配器
|
|
|
|
|
|
// @return 序列化后的RapidJSON Value
|
|
|
|
|
|
virtual rapidjson::Value ToJsonValue(rapidjson::Document::AllocatorType& allocator) const = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 从 RapidJSON Value 反序列化数据到当前 C++ 对象
|
|
|
|
|
|
// @param jsonValue 包含数据的RapidJSON Value
|
|
|
|
|
|
virtual void FromJsonValue(const rapidjson::Value& jsonValue) = 0;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // NMDATABASE_H
|