ValidateRoleSetResult.cc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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/qualitycheck/model/ValidateRoleSetResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Qualitycheck;
  19. using namespace AlibabaCloud::Qualitycheck::Model;
  20. ValidateRoleSetResult::ValidateRoleSetResult() :
  21. ServiceResult()
  22. {}
  23. ValidateRoleSetResult::ValidateRoleSetResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ValidateRoleSetResult::~ValidateRoleSetResult()
  29. {}
  30. void ValidateRoleSetResult::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 allDataNode = value["Data"]["SentenceResult"];
  37. for (auto valueDataSentenceResult : allDataNode)
  38. {
  39. SentenceResult dataObject;
  40. if(!valueDataSentenceResult["BeginTime"].isNull())
  41. dataObject.beginTime = std::stol(valueDataSentenceResult["BeginTime"].asString());
  42. if(!valueDataSentenceResult["ChannelId"].isNull())
  43. dataObject.channelId = std::stoi(valueDataSentenceResult["ChannelId"].asString());
  44. if(!valueDataSentenceResult["EndTime"].isNull())
  45. dataObject.endTime = std::stol(valueDataSentenceResult["EndTime"].asString());
  46. if(!valueDataSentenceResult["Text"].isNull())
  47. dataObject.text = valueDataSentenceResult["Text"].asString();
  48. if(!valueDataSentenceResult["EmotionValue"].isNull())
  49. dataObject.emotionValue = std::stoi(valueDataSentenceResult["EmotionValue"].asString());
  50. if(!valueDataSentenceResult["SilenceDuration"].isNull())
  51. dataObject.silenceDuration = std::stoi(valueDataSentenceResult["SilenceDuration"].asString());
  52. if(!valueDataSentenceResult["SpeechRate"].isNull())
  53. dataObject.speechRate = std::stoi(valueDataSentenceResult["SpeechRate"].asString());
  54. data_.push_back(dataObject);
  55. }
  56. if(!value["Success"].isNull())
  57. success_ = value["Success"].asString() == "true";
  58. if(!value["Code"].isNull())
  59. code_ = value["Code"].asString();
  60. if(!value["Message"].isNull())
  61. message_ = value["Message"].asString();
  62. }
  63. std::string ValidateRoleSetResult::getMessage()const
  64. {
  65. return message_;
  66. }
  67. std::vector<ValidateRoleSetResult::SentenceResult> ValidateRoleSetResult::getData()const
  68. {
  69. return data_;
  70. }
  71. std::string ValidateRoleSetResult::getCode()const
  72. {
  73. return code_;
  74. }
  75. bool ValidateRoleSetResult::getSuccess()const
  76. {
  77. return success_;
  78. }