123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- /*
- * @Description:
- * @Version: 1.0
- * @Autor: lishengyin
- * @Date: 2022-02-15 15:48:43
- * @LastEditors: lishengyin
- * @LastEditTime: 2022-02-16 09:24:27
- */
- #ifndef __PALYERDEVCELIST_H_
- #define __PALYERDEVCELIST_H_
- #include <iostream>
- #include <rapidjson/document.h>
- #include <rapidjson/rapidjson.h>
- #include <rapidjson/stringbuffer.h>
- #include <rapidjson/writer.h>
- using namespace std;
- class dSocket
- {
- public:
- bool removed;
- public:
- dSocket() {}
- ~dSocket() {}
- bool jsonToObject(const rapidjson::Value& object){
- const auto end = object.MemberEnd();
- if(end == object.FindMember("removed") || !object["removed"].IsBool()){
- return false;
- }else{
- removed = object["removed"].GetBool();
- }
- return true;
- }
- };
- class PlayerDeviceList
- {
- public:
- dSocket d_socket;
- std::string d_status;
- std::string did;
- std::string dname;
- std::string donline;
- std::string dtype;
- std::string ip_port;
- std::string loginDate;
- public:
- PlayerDeviceList(){}
- ~PlayerDeviceList(){}
- /**
- * @description: json转换为对象
- * @param {Value&} object
- * @return {*}
- */
- bool jsonToObject(const rapidjson::Value& object){
- const auto end = object.MemberEnd();
- if(end == object.FindMember("d_socket") || !object["d_socket"].IsObject()){
- return false;
- }
- else{
- const rapidjson::Value& obj = object["d_socket"];
- if(d_socket.jsonToObject(obj) == false) return false;
- }
- if(end == object.FindMember("d_status") || !object["d_status"].IsString()){
- return false;
- }
- else{
- d_status = object["d_status"].GetString();
- }
-
- if(end == object.FindMember("did") || !object["did"].IsString()){
- return false;
- }
- else{
- did = object["did"].GetString();
- }
- if(end == object.FindMember("dname") || !object["dname"].IsString()){
- return false;
- }
- else{
- dname = object["dname"].GetString();
- }
- if(end == object.FindMember("donline") || !object["donline"].IsString()){
- return false;
- }
- else{
- donline = object["donline"].GetString();
- }
- if(end == object.FindMember("dtype") || !object["dtype"].IsString()){
- return false;
- }
- else{
- dtype = object["dtype"].GetString();
- }
- if(end == object.FindMember("ip_port") || !object["ip_port"].IsString()){
- return false;
- }
- else{
- ip_port = object["ip_port"].GetString();
- }
- if(end == object.FindMember("loginDate") || !object["loginDate"].IsString()){
- return false;
- }
- else{
- loginDate = object["loginDate"].GetString();
- }
- return true;
- }
- };
- #endif
|