123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- #pragma once
- #include <iostream>
- #include <rapidjson/document.h>
- #include <rapidjson/rapidjson.h>
- #include <rapidjson/stringbuffer.h>
- #include <rapidjson/writer.h>
- using namespace std;
- class SendLogin
- {
- private:
- /* data */
- // 客户端分配的帐号
- string account;
-
- // 给客户端的密码
- string pwd;
-
- // 请求时间
- string reqTime;
- // 签名
- string reqSign;
- // 该连接关联的相机IP
- string cameraIp;
- // 扩展数据
- string attr1;
- string attr2;
- string attr3;
- public:
- SendLogin(){}
- ~SendLogin(){}
- void setAccount(string Account){
- account = Account;
- }
- void setPwd(string Pwd){
- pwd = Pwd;
- }
- void setReqTime(string ReqTime){
- reqTime = ReqTime;
- }
- void setReqSign(string ReqSign){
- reqSign = ReqSign;
- }
- void setCameraIp(string CameraIp){
- cameraIp = CameraIp;
- }
- void setAttr1(string Attr1){
- attr1 = Attr1;
- }
- void setAttr2(string Attr2){
- attr2 = Attr2;
- }
- void setAttr3(string Attr3){
- attr3 = Attr3;
- }
- string getAccount(){
- return account;
- }
- string getPwd(){
- return pwd;
- }
- string getReqTime()
- {
- return reqTime;
- }
- string getReqSign()
- {
- return reqSign;
- }
- string getCameraIp(){
- return cameraIp;
- }
- string getAttr1(){
- return attr1;
- }
- string getAttr2(){
- return attr2;
- }
- string getAttr3(){
- return attr3;
- }
- void objectToJson(string& str){
- rapidjson::StringBuffer strBuf;
- rapidjson::Writer<rapidjson::StringBuffer> writer(strBuf);
- this->objectToJson(writer);
- str = strBuf.GetString();
- }
- void objectToJson(rapidjson::Writer<rapidjson::StringBuffer>& writer){
- writer.StartObject();
-
- writer.Key("account");
- writer.String(account.c_str());
- // writer.Key("pwd");
- // writer.String(pwd.c_str());
- writer.Key("reqTime");
- writer.String(reqTime.c_str());
- writer.Key("reqSign");
- writer.String(reqSign.c_str());
- writer.Key("cameraIp");
- writer.String(cameraIp.c_str());
- writer.Key("attr1");
- writer.String(attr1.c_str());
- writer.Key("attr2");
- writer.String(attr2.c_str());
- writer.Key("attr3");
- writer.String(attr3.c_str());
- writer.EndObject();
- }
-
- bool JsonToObject(){
- return true;
- }
- };
|