DescribeCasterProgramResult.cc 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright 2009-2017 Alibaba Cloud All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include <alibabacloud/live/model/DescribeCasterProgramResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Live;
  19. using namespace AlibabaCloud::Live::Model;
  20. DescribeCasterProgramResult::DescribeCasterProgramResult() :
  21. ServiceResult()
  22. {}
  23. DescribeCasterProgramResult::DescribeCasterProgramResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeCasterProgramResult::~DescribeCasterProgramResult()
  29. {}
  30. void DescribeCasterProgramResult::parse(const std::string &payload)
  31. {
  32. Json::CharReaderBuilder builder;
  33. Json::CharReader *reader = builder.newCharReader();
  34. Json::Value *val;
  35. Json::Value value;
  36. JSONCPP_STRING *errs;
  37. reader->parse(payload.data(), payload.data() + payload.size(), val, errs);
  38. value = *val;
  39. setRequestId(value["RequestId"].asString());
  40. auto allEpisodes = value["Episodes"]["Episode"];
  41. for (auto value : allEpisodes)
  42. {
  43. Episode episodesObject;
  44. if(!value["EpisodeId"].isNull())
  45. episodesObject.episodeId = value["EpisodeId"].asString();
  46. if(!value["EpisodeType"].isNull())
  47. episodesObject.episodeType = value["EpisodeType"].asString();
  48. if(!value["EpisodeName"].isNull())
  49. episodesObject.episodeName = value["EpisodeName"].asString();
  50. if(!value["ResourceId"].isNull())
  51. episodesObject.resourceId = value["ResourceId"].asString();
  52. if(!value["StartTime"].isNull())
  53. episodesObject.startTime = value["StartTime"].asString();
  54. if(!value["EndTime"].isNull())
  55. episodesObject.endTime = value["EndTime"].asString();
  56. if(!value["SwitchType"].isNull())
  57. episodesObject.switchType = value["SwitchType"].asString();
  58. if(!value["Status"].isNull())
  59. episodesObject.status = std::stoi(value["Status"].asString());
  60. auto allComponentIds = value["ComponentIds"]["ComponentId"];
  61. for (auto value : allComponentIds)
  62. episodesObject.componentIds.push_back(value.asString());
  63. episodes_.push_back(episodesObject);
  64. }
  65. if(!value["CasterId"].isNull())
  66. casterId_ = value["CasterId"].asString();
  67. if(!value["ProgramName"].isNull())
  68. programName_ = value["ProgramName"].asString();
  69. if(!value["ProgramEffect"].isNull())
  70. programEffect_ = std::stoi(value["ProgramEffect"].asString());
  71. if(!value["Total"].isNull())
  72. total_ = std::stoi(value["Total"].asString());
  73. }
  74. int DescribeCasterProgramResult::getProgramEffect()const
  75. {
  76. return programEffect_;
  77. }
  78. int DescribeCasterProgramResult::getTotal()const
  79. {
  80. return total_;
  81. }
  82. std::vector<DescribeCasterProgramResult::Episode> DescribeCasterProgramResult::getEpisodes()const
  83. {
  84. return episodes_;
  85. }
  86. std::string DescribeCasterProgramResult::getCasterId()const
  87. {
  88. return casterId_;
  89. }
  90. std::string DescribeCasterProgramResult::getProgramName()const
  91. {
  92. return programName_;
  93. }