123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- #pragma once
- #include <iostream>
- #include <memory>
- #include "Util/SqlPool.h"
- using namespace toolkit;
- using namespace std;
- class FrameInferData
- {
- public:
- using Ptr = std::shared_ptr<FrameInferData>;
- public:
- int ID;
- int ClassId;
- int Num;
- string Remark;
- string ImageBase64;
- string WarningTime;
- string VideoPath;
- string attr1;
- string attr2;
- string attr3;
- int Warn = 0;
- std::string uuid;
- public:
- FrameInferData(){}
- ~FrameInferData(){}
- std::string ObjectToSql(){
- SqlStream sqlStream("insert into gsdDB.`InferData` (ClassId, Num, Remark, ImageBase64, WarningTime, VideoPath, attr1, attr2,attr3,Warn,uuid, ISDELETE)\
- values ('?','?','?','?','?', '?','?','?','?','?','?', 0)");
- sqlStream << ClassId << Num << Remark << ImageBase64 << WarningTime << VideoPath << attr1 << attr2 << attr3 << Warn << uuid;
- return (std::string)sqlStream;
- }
- // Json转为对象
- bool JsonToObject(std::string& json){
- rapidjson::Document doc;
- doc.Parse(json.c_str());
- if(!doc.IsObject()){
- return false;
- }
- // get members
- const auto end = doc.MemberEnd();
- // json_type
- if(end == doc.FindMember("ID") || !doc["ID"].IsString()) {
- return false;
- }else{
- ID = atoi(doc["ID"].GetString());
- }
-
- // json_type
- if(end == doc.FindMember("ClassId") || !doc["ClassId"].IsString()) {
- return false;
- }else{
- ClassId = atoi(doc["ClassId"].GetString());
- }
- if (end == doc.FindMember("Num") || !doc["Num"].IsString()) {
- return false;
- } else {
- Num = atoi(doc["Num"].GetString());
- }
- if(end == doc.FindMember("Remark") || !doc["Remark"].IsString()) {
- return false;
- }else{
- Remark = doc["Remark"].GetString();
- }
-
- if (end == doc.FindMember("ImageBase64") || !doc["ImageBase64"].IsString()) {
- return false;
- } else {
- ImageBase64 = doc["ImageBase64"].GetString();
- }
- if(end == doc.FindMember("WarningTime") || !doc["WarningTime"].IsString()) {
- return false;
- }else{
- WarningTime = doc["WarningTime"].GetString();
- }
- if(end == doc.FindMember("VideoPath") || !doc["VideoPath"].IsString()) {
- return false;
- }else{
- VideoPath = doc["VideoPath"].GetString();
- }
- if(end == doc.FindMember("attr1") || !doc["attr1"].IsString()) {
- return false;
- }else{
- attr1 = doc["attr1"].IsString();
- }
- if(end == doc.FindMember("attr2") || !doc["attr2"].IsString()) {
- return false;
- }else{
- attr2 = doc["attr2"].GetString();
- }
- if(end == doc.FindMember("attr3") || !doc["attr3"].IsString()) {
- return false;
- }else{
- attr2 = doc["attr3"].GetString();
- }
- if(end == doc.FindMember("Warn") || !doc["Warn"].IsString()) {
- return false;
- }else{
- attr2 = atoi(doc["Warn"].GetString());
- }
- if(end == doc.FindMember("uuid") || !doc["uuid"].IsString()) {
- return false;
- }else{
- uuid = doc["uuid"].GetString();
- }
- return true;
- }
- };
|