DescribeCasterComponentsResult.cc 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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/DescribeCasterComponentsResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Live;
  19. using namespace AlibabaCloud::Live::Model;
  20. DescribeCasterComponentsResult::DescribeCasterComponentsResult() :
  21. ServiceResult()
  22. {}
  23. DescribeCasterComponentsResult::DescribeCasterComponentsResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeCasterComponentsResult::~DescribeCasterComponentsResult()
  29. {}
  30. void DescribeCasterComponentsResult::parse(const std::string &payload)
  31. {
  32. Json::Reader reader;
  33. Json::Value value;
  34. reader.parse(payload, value);
  35. setRequestId(value["RequestId"].asString());
  36. auto allComponentsNode = value["Components"]["Component"];
  37. for (auto valueComponentsComponent : allComponentsNode)
  38. {
  39. Component componentsObject;
  40. if(!valueComponentsComponent["ComponentId"].isNull())
  41. componentsObject.componentId = valueComponentsComponent["ComponentId"].asString();
  42. if(!valueComponentsComponent["ComponentName"].isNull())
  43. componentsObject.componentName = valueComponentsComponent["ComponentName"].asString();
  44. if(!valueComponentsComponent["LocationId"].isNull())
  45. componentsObject.locationId = valueComponentsComponent["LocationId"].asString();
  46. if(!valueComponentsComponent["ComponentType"].isNull())
  47. componentsObject.componentType = valueComponentsComponent["ComponentType"].asString();
  48. if(!valueComponentsComponent["Effect"].isNull())
  49. componentsObject.effect = valueComponentsComponent["Effect"].asString();
  50. auto componentLayerNode = value["ComponentLayer"];
  51. if(!componentLayerNode["HeightNormalized"].isNull())
  52. componentsObject.componentLayer.heightNormalized = std::stof(componentLayerNode["HeightNormalized"].asString());
  53. if(!componentLayerNode["WidthNormalized"].isNull())
  54. componentsObject.componentLayer.widthNormalized = std::stof(componentLayerNode["WidthNormalized"].asString());
  55. if(!componentLayerNode["PositionRefer"].isNull())
  56. componentsObject.componentLayer.positionRefer = componentLayerNode["PositionRefer"].asString();
  57. if(!componentLayerNode["Transparency"].isNull())
  58. componentsObject.componentLayer.transparency = std::stoi(componentLayerNode["Transparency"].asString());
  59. auto allPositionNormalizeds = componentLayerNode["PositionNormalizeds"]["Position"];
  60. for (auto value : allPositionNormalizeds)
  61. componentsObject.componentLayer.positionNormalizeds.push_back(value.asString());
  62. auto textLayerContentNode = value["TextLayerContent"];
  63. if(!textLayerContentNode["Text"].isNull())
  64. componentsObject.textLayerContent.text = textLayerContentNode["Text"].asString();
  65. if(!textLayerContentNode["Color"].isNull())
  66. componentsObject.textLayerContent.color = textLayerContentNode["Color"].asString();
  67. if(!textLayerContentNode["FontName"].isNull())
  68. componentsObject.textLayerContent.fontName = textLayerContentNode["FontName"].asString();
  69. if(!textLayerContentNode["SizeNormalized"].isNull())
  70. componentsObject.textLayerContent.sizeNormalized = std::stof(textLayerContentNode["SizeNormalized"].asString());
  71. if(!textLayerContentNode["BorderWidthNormalized"].isNull())
  72. componentsObject.textLayerContent.borderWidthNormalized = std::stof(textLayerContentNode["BorderWidthNormalized"].asString());
  73. if(!textLayerContentNode["BorderColor"].isNull())
  74. componentsObject.textLayerContent.borderColor = textLayerContentNode["BorderColor"].asString();
  75. auto imageLayerContentNode = value["ImageLayerContent"];
  76. if(!imageLayerContentNode["MaterialId"].isNull())
  77. componentsObject.imageLayerContent.materialId = imageLayerContentNode["MaterialId"].asString();
  78. auto captionLayerContentNode = value["CaptionLayerContent"];
  79. if(!captionLayerContentNode["LocationId"].isNull())
  80. componentsObject.captionLayerContent.locationId = captionLayerContentNode["LocationId"].asString();
  81. if(!captionLayerContentNode["PtsOffset"].isNull())
  82. componentsObject.captionLayerContent.ptsOffset = std::stoi(captionLayerContentNode["PtsOffset"].asString());
  83. if(!captionLayerContentNode["WordsCount"].isNull())
  84. componentsObject.captionLayerContent.wordsCount = std::stoi(captionLayerContentNode["WordsCount"].asString());
  85. if(!captionLayerContentNode["Color"].isNull())
  86. componentsObject.captionLayerContent.color = captionLayerContentNode["Color"].asString();
  87. if(!captionLayerContentNode["FontName"].isNull())
  88. componentsObject.captionLayerContent.fontName = captionLayerContentNode["FontName"].asString();
  89. if(!captionLayerContentNode["SourceLan"].isNull())
  90. componentsObject.captionLayerContent.sourceLan = captionLayerContentNode["SourceLan"].asString();
  91. if(!captionLayerContentNode["TargetLan"].isNull())
  92. componentsObject.captionLayerContent.targetLan = captionLayerContentNode["TargetLan"].asString();
  93. if(!captionLayerContentNode["ShowSourceLan"].isNull())
  94. componentsObject.captionLayerContent.showSourceLan = captionLayerContentNode["ShowSourceLan"].asString() == "true";
  95. if(!captionLayerContentNode["SizeNormalized"].isNull())
  96. componentsObject.captionLayerContent.sizeNormalized = std::stof(captionLayerContentNode["SizeNormalized"].asString());
  97. if(!captionLayerContentNode["BorderWidthNormalized"].isNull())
  98. componentsObject.captionLayerContent.borderWidthNormalized = std::stof(captionLayerContentNode["BorderWidthNormalized"].asString());
  99. if(!captionLayerContentNode["BorderColor"].isNull())
  100. componentsObject.captionLayerContent.borderColor = captionLayerContentNode["BorderColor"].asString();
  101. if(!captionLayerContentNode["WordCountPerLine"].isNull())
  102. componentsObject.captionLayerContent.wordCountPerLine = std::stoi(captionLayerContentNode["WordCountPerLine"].asString());
  103. if(!captionLayerContentNode["WordSpaceNormalized"].isNull())
  104. componentsObject.captionLayerContent.wordSpaceNormalized = std::stof(captionLayerContentNode["WordSpaceNormalized"].asString());
  105. if(!captionLayerContentNode["LineSpaceNormalized"].isNull())
  106. componentsObject.captionLayerContent.lineSpaceNormalized = std::stof(captionLayerContentNode["LineSpaceNormalized"].asString());
  107. components_.push_back(componentsObject);
  108. }
  109. if(!value["Total"].isNull())
  110. total_ = std::stoi(value["Total"].asString());
  111. }
  112. std::vector<DescribeCasterComponentsResult::Component> DescribeCasterComponentsResult::getComponents()const
  113. {
  114. return components_;
  115. }
  116. int DescribeCasterComponentsResult::getTotal()const
  117. {
  118. return total_;
  119. }