items.cpp 1.0 KB

1234567891011121314151617181920212223242526272829
  1. #include "items.h"
  2. namespace hm {
  3. std::string User::getJsonStr() {
  4. /* 13: timestamp: 2023-1-1_0:0:0=>1672502400000, 2100-1-1_0:0:0=>4102416000000
  5. * 47: {"uid":"","name":"","password":"","timestamp":}
  6. * */
  7. size_t size = uid.size() + name.size() + password.size() + 60;
  8. std::string res(size, 0);
  9. sprintf(
  10. res.data(), R"({"uid":"%s","name":"%s","password":"%s","timestamp":%ld})",
  11. uid.c_str(), name.c_str(), password.c_str(), timestamp
  12. );
  13. return res;
  14. }
  15. std::string Plate::getJsonStr() {
  16. /* 13: timestamp: 2023-1-1_0:0:0=>1672502400000, 2100-1-1_0:0:0=>4102416000000
  17. * 42: {"cid":,"name":"","plate":"","timestamp":}
  18. * */
  19. size_t size = cid_s.size() + name.size() + plate.size() + 55;
  20. std::string res(size, 0);
  21. sprintf(
  22. res.data(), R"({"cid":%d,"name":"%s","plate":"%s","timestamp":%ld})",
  23. cid, name.c_str(), plate.c_str(), timestamp
  24. );
  25. return res;
  26. }
  27. }