1 | /* |
---|---|
2 | * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. 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 | * A copy of the License is located at |
7 | * |
8 | * http://aws.amazon.com/apache2.0 |
9 | * |
10 | * or in the "license" file accompanying this file. This file is distributed |
11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
12 | * express or implied. See the License for the specific language governing |
13 | * permissions and limitations under the License. |
14 | */ |
15 | |
16 | #include <aws/s3/model/ListObjectsResult.h> |
17 | #include <aws/core/utils/xml/XmlSerializer.h> |
18 | #include <aws/core/AmazonWebServiceResult.h> |
19 | #include <aws/core/utils/StringUtils.h> |
20 | |
21 | #include <utility> |
22 | |
23 | using namespace Aws::S3::Model; |
24 | using namespace Aws::Utils::Xml; |
25 | using namespace Aws::Utils; |
26 | using namespace Aws; |
27 | |
28 | ListObjectsResult::ListObjectsResult() : |
29 | m_isTruncated(false), |
30 | m_maxKeys(0), |
31 | m_encodingType(EncodingType::NOT_SET) |
32 | { |
33 | } |
34 | |
35 | ListObjectsResult::ListObjectsResult(const Aws::AmazonWebServiceResult<XmlDocument>& result) : |
36 | m_isTruncated(false), |
37 | m_maxKeys(0), |
38 | m_encodingType(EncodingType::NOT_SET) |
39 | { |
40 | *this = result; |
41 | } |
42 | |
43 | ListObjectsResult& ListObjectsResult::operator =(const Aws::AmazonWebServiceResult<XmlDocument>& result) |
44 | { |
45 | const XmlDocument& xmlDocument = result.GetPayload(); |
46 | XmlNode resultNode = xmlDocument.GetRootElement(); |
47 | |
48 | if(!resultNode.IsNull()) |
49 | { |
50 | XmlNode isTruncatedNode = resultNode.FirstChild("IsTruncated"); |
51 | if(!isTruncatedNode.IsNull()) |
52 | { |
53 | m_isTruncated = StringUtils::ConvertToBool(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(isTruncatedNode.GetText()).c_str()).c_str()); |
54 | } |
55 | XmlNode markerNode = resultNode.FirstChild("Marker"); |
56 | if(!markerNode.IsNull()) |
57 | { |
58 | m_marker = Aws::Utils::Xml::DecodeEscapedXmlText(markerNode.GetText()); |
59 | } |
60 | XmlNode nextMarkerNode = resultNode.FirstChild("NextMarker"); |
61 | if(!nextMarkerNode.IsNull()) |
62 | { |
63 | m_nextMarker = Aws::Utils::Xml::DecodeEscapedXmlText(nextMarkerNode.GetText()); |
64 | } |
65 | XmlNode contentsNode = resultNode.FirstChild("Contents"); |
66 | if(!contentsNode.IsNull()) |
67 | { |
68 | XmlNode contentsMember = contentsNode; |
69 | while(!contentsMember.IsNull()) |
70 | { |
71 | m_contents.push_back(contentsMember); |
72 | contentsMember = contentsMember.NextNode("Contents"); |
73 | } |
74 | |
75 | } |
76 | XmlNode nameNode = resultNode.FirstChild("Name"); |
77 | if(!nameNode.IsNull()) |
78 | { |
79 | m_name = Aws::Utils::Xml::DecodeEscapedXmlText(nameNode.GetText()); |
80 | } |
81 | XmlNode prefixNode = resultNode.FirstChild("Prefix"); |
82 | if(!prefixNode.IsNull()) |
83 | { |
84 | m_prefix = Aws::Utils::Xml::DecodeEscapedXmlText(prefixNode.GetText()); |
85 | } |
86 | XmlNode delimiterNode = resultNode.FirstChild("Delimiter"); |
87 | if(!delimiterNode.IsNull()) |
88 | { |
89 | m_delimiter = Aws::Utils::Xml::DecodeEscapedXmlText(delimiterNode.GetText()); |
90 | } |
91 | XmlNode maxKeysNode = resultNode.FirstChild("MaxKeys"); |
92 | if(!maxKeysNode.IsNull()) |
93 | { |
94 | m_maxKeys = StringUtils::ConvertToInt32(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(maxKeysNode.GetText()).c_str()).c_str()); |
95 | } |
96 | XmlNode commonPrefixesNode = resultNode.FirstChild("CommonPrefixes"); |
97 | if(!commonPrefixesNode.IsNull()) |
98 | { |
99 | XmlNode commonPrefixesMember = commonPrefixesNode; |
100 | while(!commonPrefixesMember.IsNull()) |
101 | { |
102 | m_commonPrefixes.push_back(commonPrefixesMember); |
103 | commonPrefixesMember = commonPrefixesMember.NextNode("CommonPrefixes"); |
104 | } |
105 | |
106 | } |
107 | XmlNode encodingTypeNode = resultNode.FirstChild("EncodingType"); |
108 | if(!encodingTypeNode.IsNull()) |
109 | { |
110 | m_encodingType = EncodingTypeMapper::GetEncodingTypeForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(encodingTypeNode.GetText()).c_str()).c_str()); |
111 | } |
112 | } |
113 | |
114 | return *this; |
115 | } |
116 |