SendLogin.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #pragma once
  2. #include <iostream>
  3. #include <rapidjson/document.h>
  4. #include <rapidjson/rapidjson.h>
  5. #include <rapidjson/stringbuffer.h>
  6. #include <rapidjson/writer.h>
  7. using namespace std;
  8. class SendLogin
  9. {
  10. private:
  11. /* data */
  12. // 客户端分配的帐号
  13. string account;
  14. // 给客户端的密码
  15. string pwd;
  16. // 请求时间
  17. string reqTime;
  18. // 签名
  19. string reqSign;
  20. // 该连接关联的相机IP
  21. string cameraIp;
  22. // 扩展数据
  23. string attr1;
  24. string attr2;
  25. string attr3;
  26. public:
  27. SendLogin(){}
  28. ~SendLogin(){}
  29. void setAccount(string Account){
  30. account = Account;
  31. }
  32. void setPwd(string Pwd){
  33. pwd = Pwd;
  34. }
  35. void setReqTime(string ReqTime){
  36. reqTime = ReqTime;
  37. }
  38. void setReqSign(string ReqSign){
  39. reqSign = ReqSign;
  40. }
  41. void setCameraIp(string CameraIp){
  42. cameraIp = CameraIp;
  43. }
  44. void setAttr1(string Attr1){
  45. attr1 = Attr1;
  46. }
  47. void setAttr2(string Attr2){
  48. attr2 = Attr2;
  49. }
  50. void setAttr3(string Attr3){
  51. attr3 = Attr3;
  52. }
  53. string getAccount(){
  54. return account;
  55. }
  56. string getPwd(){
  57. return pwd;
  58. }
  59. string getReqTime()
  60. {
  61. return reqTime;
  62. }
  63. string getReqSign()
  64. {
  65. return reqSign;
  66. }
  67. string getCameraIp(){
  68. return cameraIp;
  69. }
  70. string getAttr1(){
  71. return attr1;
  72. }
  73. string getAttr2(){
  74. return attr2;
  75. }
  76. string getAttr3(){
  77. return attr3;
  78. }
  79. void objectToJson(string& str){
  80. rapidjson::StringBuffer strBuf;
  81. rapidjson::Writer<rapidjson::StringBuffer> writer(strBuf);
  82. this->objectToJson(writer);
  83. str = strBuf.GetString();
  84. }
  85. void objectToJson(rapidjson::Writer<rapidjson::StringBuffer>& writer){
  86. writer.StartObject();
  87. writer.Key("account");
  88. writer.String(account.c_str());
  89. // writer.Key("pwd");
  90. // writer.String(pwd.c_str());
  91. writer.Key("reqTime");
  92. writer.String(reqTime.c_str());
  93. writer.Key("reqSign");
  94. writer.String(reqSign.c_str());
  95. writer.Key("cameraIp");
  96. writer.String(cameraIp.c_str());
  97. writer.Key("attr1");
  98. writer.String(attr1.c_str());
  99. writer.Key("attr2");
  100. writer.String(attr2.c_str());
  101. writer.Key("attr3");
  102. writer.String(attr3.c_str());
  103. writer.EndObject();
  104. }
  105. bool JsonToObject(){
  106. return true;
  107. }
  108. };