data_process_resp.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. #pragma once
  2. #include <sstream>
  3. #include <string>
  4. #include <vector>
  5. #include "rapidxml/1.13/rapidxml.hpp"
  6. #include "rapidxml/1.13/rapidxml_print.hpp"
  7. #include "rapidxml/1.13/rapidxml_utils.hpp"
  8. #include "request/data_process_req.h"
  9. #include "response/object_resp.h"
  10. namespace qcloud_cos {
  11. class ImageRespBase : virtual public BaseResp {
  12. public:
  13. ImageRespBase() {}
  14. virtual ~ImageRespBase() {}
  15. virtual bool ParseFromXmlString(const std::string& body);
  16. UploadResult GetUploadResult() const { return m_upload_result; }
  17. static bool ParseObject(rapidxml::xml_node<>* root, Object& object);
  18. static bool ParseQRcodeInfo(rapidxml::xml_node<>* root, QRcodeInfo& qr_code);
  19. protected:
  20. bool ParseOriginalInfo(rapidxml::xml_node<>* root);
  21. UploadResult m_upload_result;
  22. };
  23. class PutImageByFileResp : public ImageRespBase, public PutObjectByFileResp {
  24. public:
  25. PutImageByFileResp() {}
  26. virtual ~PutImageByFileResp() {}
  27. };
  28. class CloudImageProcessResp : public ImageRespBase {
  29. public:
  30. CloudImageProcessResp() {}
  31. virtual ~CloudImageProcessResp() {}
  32. };
  33. class GetQRcodeResp : public BaseResp {
  34. public:
  35. GetQRcodeResp() {}
  36. virtual ~GetQRcodeResp() {}
  37. virtual bool ParseFromXmlString(const std::string& body);
  38. GetQRcodeResult GetResult() const { return m_result; }
  39. private:
  40. GetQRcodeResult m_result;
  41. };
  42. class DescribeDocProcessBucketsResp : public BaseResp {
  43. public:
  44. DescribeDocProcessBucketsResp() {}
  45. virtual ~DescribeDocProcessBucketsResp() {}
  46. virtual bool ParseFromXmlString(const std::string& body);
  47. DocBucketResponse GetResult() const { return m_result; }
  48. static bool ParseBucketInfo(rapidxml::xml_node<>* root,
  49. BucketInfo& bucket_info);
  50. private:
  51. DocBucketResponse m_result;
  52. };
  53. class DocPreviewResp : public GetObjectByFileResp {
  54. public:
  55. DocPreviewResp() {}
  56. virtual ~DocPreviewResp() {}
  57. void ParseFromHeaders(const std::map<std::string, std::string>& headers);
  58. // 返回文档总页数(表格文件表示当前 sheet 转换后的总图片数),异常时为空
  59. unsigned GetTotalPage() const { return m_x_total_page; }
  60. // 当异常时返回错误码
  61. std::string GetErrNo() const { return m_x_errno; }
  62. // 返回文档中总表数
  63. unsigned GetTotalSheet() const { return m_x_total_sheet; }
  64. // 返回当前 sheet 名
  65. std::string GetSheetName() const { return m_sheet_name; }
  66. private:
  67. unsigned m_x_total_page;
  68. std::string m_x_errno;
  69. unsigned m_x_total_sheet;
  70. std::string m_sheet_name;
  71. };
  72. class DocProcessJobBase : public BaseResp {
  73. public:
  74. DocProcessJobBase() {}
  75. virtual ~DocProcessJobBase() {}
  76. virtual bool ParseFromXmlString(const std::string& body);
  77. JobsDetail GetJobsDetail() const { return m_jobs_detail; }
  78. protected:
  79. bool ParseJobsDetail(rapidxml::xml_node<>* root, JobsDetail& jobs_detail);
  80. bool ParseOperation(rapidxml::xml_node<>* root, Operation& operation);
  81. bool ParseDocProcess(rapidxml::xml_node<>* root, DocProcess& doc_process);
  82. bool ParseDocProcessResult(rapidxml::xml_node<>* root,
  83. DocProcessResult& doc_process_result);
  84. private:
  85. JobsDetail m_jobs_detail;
  86. };
  87. class CreateDocProcessJobsResp : public DocProcessJobBase {
  88. public:
  89. CreateDocProcessJobsResp() {}
  90. virtual ~CreateDocProcessJobsResp() {}
  91. };
  92. class DescribeDocProcessJobResp : public DocProcessJobBase {
  93. public:
  94. DescribeDocProcessJobResp() {}
  95. virtual ~DescribeDocProcessJobResp() {}
  96. };
  97. class DescribeDocProcessJobsResp : public DocProcessJobBase {
  98. public:
  99. DescribeDocProcessJobsResp() {}
  100. virtual ~DescribeDocProcessJobsResp() {}
  101. virtual bool ParseFromXmlString(const std::string& body);
  102. std::vector<JobsDetail> GetJobsDetails() const { return m_jobs_details; }
  103. std::string GetNextToken() const { return m_next_token; }
  104. private:
  105. std::vector<JobsDetail> m_jobs_details;
  106. std::string m_next_token;
  107. };
  108. class QueuesBase : public BaseResp {
  109. public:
  110. QueuesBase() {}
  111. virtual ~QueuesBase() {}
  112. protected:
  113. bool ParseNonExistPIDs(rapidxml::xml_node<>* root,
  114. NonExistPIDs& non_exist_pids);
  115. bool ParseQueueList(rapidxml::xml_node<>* root, QueueList& queue_list);
  116. };
  117. class DescribeQueuesResp : public QueuesBase {
  118. public:
  119. DescribeQueuesResp() {}
  120. virtual ~DescribeQueuesResp() {}
  121. virtual bool ParseFromXmlString(const std::string& body);
  122. int GetTotalCount() const { return m_total_count; }
  123. std::string GetRequestId() const { return m_request_id; }
  124. int GetPageNumber() const { return m_page_number; }
  125. int GetPageSize() const { return m_page_size; }
  126. QueueList GetQueueList() const { return m_queue_list; }
  127. NonExistPIDs GetNonExistPIDs() const { return m_non_exist_pids; }
  128. private:
  129. int m_total_count;
  130. std::string m_request_id;
  131. int m_page_number;
  132. int m_page_size;
  133. QueueList m_queue_list;
  134. NonExistPIDs m_non_exist_pids;
  135. };
  136. class UpdateQueueResp : public QueuesBase {
  137. public:
  138. UpdateQueueResp() {}
  139. virtual ~UpdateQueueResp() {}
  140. virtual bool ParseFromXmlString(const std::string& body);
  141. std::string GetRequestId() const { return m_request_id; }
  142. QueueList GetQueueList() const { return m_queue; }
  143. private:
  144. std::string m_request_id;
  145. QueueList m_queue;
  146. };
  147. class DescribeDocProcessQueuesResp : public DescribeQueuesResp {
  148. public:
  149. DescribeDocProcessQueuesResp() {}
  150. virtual ~DescribeDocProcessQueuesResp() {}
  151. // virtual bool ParseFromXmlString(const std::string& body);
  152. // int GetTotalCount() const { return m_total_count; }
  153. // std::string GetRequestId() const { return m_request_id; }
  154. // int GetPageNumber() const { return m_page_number; }
  155. // int GetPageSize() const { return m_page_size; }
  156. // QueueList GetQueueList() const { return m_queue_list; }
  157. // NonExistPIDs GetNonExistPIDs() const { return m_non_exist_pids; }
  158. // private:
  159. // int m_total_count;
  160. // std::string m_request_id;
  161. // int m_page_number;
  162. // int m_page_size;
  163. // QueueList m_queue_list;
  164. // NonExistPIDs m_non_exist_pids;
  165. };
  166. class UpdateDocProcessQueueResp : public UpdateQueueResp {
  167. public:
  168. UpdateDocProcessQueueResp() {}
  169. virtual ~UpdateDocProcessQueueResp() {}
  170. // virtual bool ParseFromXmlString(const std::string& body);
  171. // std::string GetRequestId() const { return m_request_id; }
  172. // QueueList GetQueueList() const { return m_queue; }
  173. // private:
  174. // std::string m_request_id;
  175. // QueueList m_queue;
  176. };
  177. class DescribeMediaBucketsResp : public BaseResp {
  178. public:
  179. DescribeMediaBucketsResp() {}
  180. virtual ~DescribeMediaBucketsResp() {}
  181. virtual bool ParseFromXmlString(const std::string& body);
  182. DescribeMediaBucketsResult GetResult() const { return m_result; }
  183. private:
  184. DescribeMediaBucketsResult m_result;
  185. };
  186. class PutBucketToCIResp : public BaseResp {
  187. public:
  188. PutBucketToCIResp() {}
  189. virtual ~PutBucketToCIResp() {}
  190. };
  191. class CreateDocBucketResp : public BaseResp {
  192. public:
  193. CreateDocBucketResp() {}
  194. virtual ~CreateDocBucketResp() {}
  195. virtual bool ParseFromXmlString(const std::string& body);
  196. CreateDocBucketResult GetResult() const { return m_result; }
  197. private:
  198. CreateDocBucketResult m_result;
  199. };
  200. class CreateMediaBucketResp : public BaseResp {
  201. public:
  202. CreateMediaBucketResp() {}
  203. virtual ~CreateMediaBucketResp() {}
  204. virtual bool ParseFromXmlString(const std::string& body);
  205. CreateMediaBucketResult GetResult() const { return m_result; }
  206. private:
  207. CreateMediaBucketResult m_result;
  208. };
  209. class GetSnapshotResp : public GetObjectByFileResp {
  210. public:
  211. GetSnapshotResp() {}
  212. virtual ~GetSnapshotResp() {}
  213. };
  214. class GetMediaInfoResp : public BaseResp {
  215. public:
  216. GetMediaInfoResp() {}
  217. virtual ~GetMediaInfoResp() {}
  218. virtual bool ParseFromXmlString(const std::string& body);
  219. GetMediaInfoResult GetResult() const { return m_result; }
  220. private:
  221. bool ParseVideo(rapidxml::xml_node<>* root, VideoInfo& video_info);
  222. bool ParseAudio(rapidxml::xml_node<>* root, AudioInfo& audio_info);
  223. bool ParseSubtitle(rapidxml::xml_node<>* root, SubtitleInfo& subtitle_info);
  224. bool ParseFormat(rapidxml::xml_node<>* root, FormatInfo& format_info);
  225. GetMediaInfoResult m_result;
  226. };
  227. class GetPm3u8Resp : public GetObjectByFileResp {
  228. public:
  229. GetPm3u8Resp() {}
  230. virtual ~GetPm3u8Resp() {}
  231. };
  232. class DataProcessJobBase : public BaseResp {
  233. public:
  234. DataProcessJobBase() {}
  235. virtual ~DataProcessJobBase() {}
  236. virtual bool ParseFromXmlString(const std::string& body);
  237. JobsDetails GetJobsDetail() const { return m_jobs_detail; }
  238. protected:
  239. static bool ParseTranscode(rapidxml::xml_node<>* root, Transcode& transcode);
  240. static bool ParseAudioMix(rapidxml::xml_node<>* root, AudioMix& audio_mix);
  241. static bool ParseVideo(rapidxml::xml_node<>* root, Video& video);
  242. static bool ParseTimeInterval(rapidxml::xml_node<>* root, TimeInterval& time_interval);
  243. static bool ParseContainer(rapidxml::xml_node<>* root, Container& container);
  244. static bool ParseAudio(rapidxml::xml_node<>* root, Audio& audio);
  245. static bool ParseTransConfig(rapidxml::xml_node<>* root, TransConfig& trans_config);
  246. static bool ParseSnapshot(rapidxml::xml_node<>* root, Snapshot& snapshot);
  247. static bool ParseWatermark(rapidxml::xml_node<>* root, Watermark& watermark);
  248. static bool ParseMediaResult(rapidxml::xml_node<>* root, MediaResult& media_result);
  249. static bool ParseOutput(rapidxml::xml_node<>* root, Output& output);
  250. static bool ParseRemoveWatermark(rapidxml::xml_node<>* root, RemoveWatermark& remove_watermark);
  251. static bool ParseSubtitles(rapidxml::xml_node<>* root, Subtitles& subtitles);
  252. static bool ParseFileUncompressConfig(rapidxml::xml_node<>* root, FileUncompressConfig& file_uncompress_config);
  253. static bool ParseFileUncompressResult(rapidxml::xml_node<>* root, FileUncompressResult& file_uncompress_result);
  254. static bool ParseAnimation(rapidxml::xml_node<>* root, Animation& animation);
  255. static bool ParseInput(rapidxml::xml_node<>* root, Input& input);
  256. static bool ParseSmartCover(rapidxml::xml_node<>* root, SmartCover& smartcover);
  257. static bool ParseConcat(rapidxml::xml_node<>* root, Concat& concat);
  258. static bool ParseConcatFragment(rapidxml::xml_node<>* root, ConcatFragment& concat_fragment);
  259. static bool ParseDigitalWatermark(rapidxml::xml_node<>* root, DigitalWatermark& digital_watermark);
  260. static bool ParseExtractDigitalWatermark(rapidxml::xml_node<>* root, ExtractDigitalWatermark& extract_digital_watermark);
  261. static bool ParseVideoMontage(rapidxml::xml_node<>* root, VideoMontage& video_montage);
  262. static bool ParseVoiceSeparate(rapidxml::xml_node<>* root, VoiceSeparate& voice_separate);
  263. static bool ParseSegment(rapidxml::xml_node<>* root, Segment& segment);
  264. private:
  265. JobsDetails m_jobs_detail;
  266. };
  267. class CreateDataProcessJobsResp : public DataProcessJobBase {
  268. public:
  269. CreateDataProcessJobsResp() {}
  270. virtual ~CreateDataProcessJobsResp() {}
  271. // virtual bool ParseFromXmlString(const std::string& body);
  272. };
  273. class DescribeDataProcessJobResp : public DataProcessJobBase {
  274. public:
  275. DescribeDataProcessJobResp() {}
  276. virtual ~DescribeDataProcessJobResp() {}
  277. };
  278. class CancelDataProcessJobResp : public BaseResp {
  279. public:
  280. CancelDataProcessJobResp() {}
  281. virtual ~CancelDataProcessJobResp() {}
  282. };
  283. } // namespace qcloud_cos