Files
GUI/src/json/ScanJson.h
2022-05-11 15:44:43 +08:00

45 lines
812 B
C++

//
// Created by Krad on 2022/5/11.
//
#ifndef GUI_SCANJSON_H
#define GUI_SCANJSON_H
#include <string>
#include "cJSON.h"
class ScanJson {
public:
~ScanJson(){
if(root)cJSON_Delete(root);
}
void store(cJSON* json){
if(root){
cJSON_Delete(root);
root = nullptr;
}
root = json;
}
void setScanID(const char * id){
scanID.clear();
scanID.append(id);
}
void setEmptyScanID(const char * id){
emptyScanID.clear();
emptyScanID.append(id);
setScanID(id);
}
void save();
static ScanJson* Current(){
static ScanJson instance;
return &instance;
}
private:
std::string emptyScanID;
std::string scanID;
cJSON* root = nullptr;
};
#endif //GUI_SCANJSON_H