123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- #pragma once
- #include <iostream>
- #include <rapidjson/document.h>
- #include <rapidjson/rapidjson.h>
- #include <rapidjson/stringbuffer.h>
- #include <rapidjson/writer.h>
- using namespace std;
- class HepuTargetRe
- {
- private:
- public:
- const string cmd = "ivpTrackingCtrl";
- int ackvalue;
- int channelid;
- bool bTracking;
-
- HepuTargetRe(){};
- ~HepuTargetRe(){};
- bool jsonToObject(string& json){
- rapidjson::Document doc;
- doc.Parse(json.c_str());
- if(!doc.IsObject()){
- return false;
- }
- const auto end = doc.MemberEnd();
- if(end == doc.FindMember("cmd") || !doc["cmd"].IsString()){
- return false;
- }else{
- if(cmd != doc["cmd"].GetString())
- return false;
- }
- if(end == doc.FindMember("param") || !doc["param"].IsObject()) {
- return false;
- }else{
- const rapidjson::Value& object = doc["param"];
- if(end == object.FindMember("ackvalue") || !object["ackvalue"].IsInt()) {
- return false;
- }else{
- ackvalue = object["ackvalue"].GetInt();
- }
- if(end == object.FindMember("channelid") || !object["channelid"].IsInt()) {
- return false;
- }else{
- channelid = object["channelid"].GetInt();
- }
- if(end == object.FindMember("bTracking") || !object["bTracking"].IsBool()) {
- return false;
- }else{
- bTracking = object["bTracking"].GetBool();
- }
- }
- return true;
- }
- };
|