PlayerLogin.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * @Description:
  3. * @Version: 1.0
  4. * @Autor: lishengyin
  5. * @Date: 2022-02-15 15:15:51
  6. * @LastEditors: lishengyin
  7. * @LastEditTime: 2022-02-16 09:12:37
  8. */
  9. #ifndef __PALYRLOGIN_H_
  10. #define __PALYRLOGIN_H_
  11. #include <iostream>
  12. #include <rapidjson/document.h>
  13. #include <rapidjson/rapidjson.h>
  14. #include <rapidjson/stringbuffer.h>
  15. #include <rapidjson/writer.h>
  16. using namespace std;
  17. class PlayerLogin
  18. {
  19. private:
  20. std::string URL = "/manager.do";
  21. public:
  22. std::string cid;
  23. std::string ctype;
  24. std::string cname;
  25. std::string cpwd;
  26. public:
  27. PlayerLogin();
  28. ~PlayerLogin();
  29. void setURL(std::string url){
  30. this->URL = url;
  31. }
  32. std::string getUrl(){
  33. return this->URL;
  34. }
  35. void objectToJson(std::string& str){
  36. rapidjson::StringBuffer strBuf;
  37. rapidjson::Writer<rapidjson::StringBuffer> writer(strBuf);
  38. this->objectToJson(writer);
  39. str = strBuf.GetString();
  40. }
  41. void objectToJson(rapidjson::Writer<rapidjson::StringBuffer>& writer){
  42. writer.StartObject();
  43. writer.Key("cid");
  44. writer.String(cid.c_str());
  45. writer.Key("ctype");
  46. writer.String(ctype.c_str());
  47. writer.Key("cname");
  48. writer.String(cname.c_str());
  49. writer.Key("cpwd");
  50. writer.String(cpwd.c_str());
  51. writer.EndObject();
  52. }
  53. };
  54. #endif