QueryFaceResult.cc 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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/linkface/model/QueryFaceResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::LinkFace;
  19. using namespace AlibabaCloud::LinkFace::Model;
  20. QueryFaceResult::QueryFaceResult() :
  21. ServiceResult()
  22. {}
  23. QueryFaceResult::QueryFaceResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. QueryFaceResult::~QueryFaceResult()
  29. {}
  30. void QueryFaceResult::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 dataNode = value["Data"];
  37. auto allUserFaceMetas = value["UserFaceMetas"]["UserFaceMetasItem"];
  38. for (auto value : allUserFaceMetas)
  39. {
  40. Data::UserFaceMetasItem userFaceMetasItemObject;
  41. if(!value["ClientTag"].isNull())
  42. userFaceMetasItemObject.clientTag = value["ClientTag"].asString();
  43. if(!value["Index"].isNull())
  44. userFaceMetasItemObject.index = std::stoi(value["Index"].asString());
  45. if(!value["FaceUrl"].isNull())
  46. userFaceMetasItemObject.faceUrl = value["FaceUrl"].asString();
  47. if(!value["UserInfo"].isNull())
  48. userFaceMetasItemObject.userInfo = value["UserInfo"].asString();
  49. data_.userFaceMetas.push_back(userFaceMetasItemObject);
  50. }
  51. auto allGroupIds = dataNode["GroupIds"]["GroupIds"];
  52. for (auto value : allGroupIds)
  53. data_.groupIds.push_back(value.asString());
  54. if(!value["Code"].isNull())
  55. code_ = std::stoi(value["Code"].asString());
  56. if(!value["Message"].isNull())
  57. message_ = value["Message"].asString();
  58. if(!value["Success"].isNull())
  59. success_ = value["Success"].asString() == "true";
  60. }
  61. std::string QueryFaceResult::getMessage()const
  62. {
  63. return message_;
  64. }
  65. QueryFaceResult::Data QueryFaceResult::getData()const
  66. {
  67. return data_;
  68. }
  69. int QueryFaceResult::getCode()const
  70. {
  71. return code_;
  72. }
  73. bool QueryFaceResult::getSuccess()const
  74. {
  75. return success_;
  76. }