1
0

jsonBuilder.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /**
  2. * @brief
  3. json构造器类
  4. * @version
  5. V 1.0.0
  6. * @author
  7. 王益俊
  8. * @date
  9. 创建时间: 2018-08-17\n
  10. * @note
  11. 2018-08-17 创建类。\n
  12. * @warning
  13. * @bug
  14. */
  15. #ifndef _JSONBUILDER_H_
  16. #define _JSONBUILDER_H_
  17. #include <map>
  18. #include <rapidjson/document.h>
  19. #include "jsonCommon.h"
  20. #include "ws_common.h"
  21. namespace YA
  22. {
  23. class jsonBuilder
  24. {
  25. private:
  26. /**
  27. * @brief
  28. 加上版本信息函数。
  29. * @param [out] rapidjson::Value& root 根jason对象\n
  30. * @param [out] rapidjson::Document::AllocatorType& Allocator 分配器\n
  31. * @return 无\n
  32. * @note
  33. * @warning
  34. * @bug
  35. */
  36. void __AddVersion( rapidjson::Value& root, rapidjson::Document::AllocatorType& Allocator );
  37. /**
  38. * @brief
  39. 设置命令信息函数。
  40. * @param [in] const char* szCmd 命令\n
  41. * @param [out] rapidjson::Value& root 根jason对象\n
  42. * @param [out] rapidjson::Document::AllocatorType& Allocator 分配器\n
  43. * @return 无\n
  44. * @note
  45. * @warning
  46. * @bug
  47. */
  48. void __SetCmd( const char* szCmd, rapidjson::Value& root, rapidjson::Document::AllocatorType& Allocator );
  49. /**
  50. * @brief
  51. 构造卡明细函数。
  52. * @param [in] const _CARD_POS_& CardPos 卡位置\n
  53. * @param [out] rapidjson::Document::AllocatorType& Allocator 分配器\n
  54. * @param [out] rapidjson::Value& DetailItem 生成的单个人卡明细\n
  55. * @return 构造是否成功\n
  56. * @note
  57. * @warning
  58. * @bug
  59. */
  60. bool __BuildDetail( const _CARD_POS_& CardPos, rapidjson::Document::AllocatorType& Allocator, rapidjson::Value& DetailItem );
  61. /**
  62. * @brief
  63. 构造部门列表json对象函数。
  64. * @param [in] const std::map<int, _STAT_DEPT_ITEM_>& dept_map 部门统计列表\n
  65. * @param [out] rapidjson::Document::AllocatorType& Allocator 分配器\n
  66. * @param [out] rapidjson::Value& Dept 生成的部门json对象\n
  67. * @return 构造是否成功\n
  68. * @note
  69. * @warning
  70. * @bug
  71. */
  72. bool __BuildDept( const std::map<int, _STAT_DEPT_ITEM_>& dept_map, rapidjson::Document::AllocatorType& Allocator, rapidjson::Value& Dept );
  73. /**
  74. * @brief
  75. 构造部门项json对象函数。
  76. * @param [in] const _STAT_DEPT_ITEM_& st_dept_item 部门项\n
  77. * @param [out] rapidjson::Document::AllocatorType& Allocator 分配器\n
  78. * @param [out] rapidjson::Value& DeptItem 生成的部门项json对象\n
  79. * @return 无\n
  80. * @note
  81. * @warning
  82. * @bug
  83. */
  84. void __BuildDeptItem( const _STAT_DEPT_ITEM_& st_dept_item, rapidjson::Document::AllocatorType& Allocator, rapidjson::Value& DeptItem );
  85. /**
  86. * @brief
  87. 生成Dept Map函数。
  88. * @param [in] const _CARD_POS_& CardPos 卡定位数据\n
  89. * @param [out] std::map<int, _STAT_DEPT_ITEM_>& DeptMap 生成的Dept Map\n
  90. * @return 无\n
  91. * @note
  92. * @warning
  93. * @bug
  94. */
  95. void __CreateDeptMap( const _CARD_POS_& CardPos, std::map<int, _STAT_DEPT_ITEM_>& DeptMap );
  96. /**
  97. * @brief
  98. 生成_STAT_DEPT_ITEM_结构体函数。
  99. * @param [in] const _CARD_POS_& CardPos 卡定位数据\n
  100. * @param [out] _STAT_DEPT_ITEM_& DeptItem 生成的DeptItem\n
  101. * @return 无\n
  102. * @note
  103. * @warning
  104. * @bug
  105. */
  106. void __CreateDeptItem( const _CARD_POS_& CardPos, _STAT_DEPT_ITEM_& DeptItem );
  107. /**
  108. * @brief
  109. 构造id sum map对象函数。
  110. * @param [in] const std::map<int,int>& id_sum_map id sum 列表\n
  111. * @param [in] const char* szName 名称\n
  112. * @param [out] rapidjson::Document::AllocatorType& Allocator 分配器\n
  113. * @param [out] rapidjson::Value& Dept 生成的部门json对象\n
  114. * @return 无\n
  115. * @note
  116. * @warning
  117. * @bug
  118. */
  119. void __BuildIDSumMap( const std::map<int,int>& id_sum_map, const char* szName, rapidjson::Document::AllocatorType & Allocator, rapidjson::Value & Parent );
  120. /**
  121. * @brief
  122. 格式化生成卡号函数。
  123. * @param [in] const _CARD_POS_& CardPos 卡位置\n
  124. * @return 格式化生成的卡号\n
  125. * @note
  126. * @warning
  127. * @bug
  128. */
  129. std::string __FmtCardID( const _CARD_POS_& CardPos );
  130. public:
  131. jsonBuilder();
  132. virtual ~jsonBuilder();
  133. /**
  134. * @brief
  135. 生成登录jason函数。
  136. * @param [in] const _JS_LOGIN_& Login 登录参数\n
  137. * @return 如果成功返回生成的json字符串,否则返回空字符串\n
  138. * @note
  139. * @warning
  140. * @bug
  141. */
  142. std::string BuildLogin( const _JS_LOGIN_& Login );
  143. /**
  144. * @brief
  145. 生成卡位置jason函数。
  146. * @param [in] const std::map<int, _CARD_POS_>& CardPosList 卡位置列表\n
  147. * @return 如果成功返回生成的json字符串,否则返回空字符串\n
  148. * @note
  149. * @warning
  150. * @bug
  151. */
  152. std::string BuildCardPos( const std::map<int, _CARD_POS_>& CardPosList );
  153. /**
  154. * @brief
  155. 解析呼叫结构体函数。
  156. * @param [in] const _JS_LOGIN_& Login 登录参数\n
  157. * @return 如果成功返回生成的jason字符串,否则返回空字符串\n
  158. * @note
  159. * @warning
  160. * @bug
  161. */
  162. bool ParseCall_Card_Req( const std::string& JasonText, _JS_CALL_CARD_REQ_& CallCardReq, std::string& Error );
  163. };
  164. }
  165. #endif /* _JSONBUILDER_H_ */