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/DeleteMarkerEntry.h> |
17 | #include <aws/core/utils/xml/XmlSerializer.h> |
18 | #include <aws/core/utils/StringUtils.h> |
19 | #include <aws/core/utils/memory/stl/AWSStringStream.h> |
20 | |
21 | #include <utility> |
22 | |
23 | using namespace Aws::Utils::Xml; |
24 | using namespace Aws::Utils; |
25 | |
26 | namespace Aws |
27 | { |
28 | namespace S3 |
29 | { |
30 | namespace Model |
31 | { |
32 | |
33 | DeleteMarkerEntry::DeleteMarkerEntry() : |
34 | m_ownerHasBeenSet(false), |
35 | m_keyHasBeenSet(false), |
36 | m_versionIdHasBeenSet(false), |
37 | m_isLatest(false), |
38 | m_isLatestHasBeenSet(false), |
39 | m_lastModifiedHasBeenSet(false) |
40 | { |
41 | } |
42 | |
43 | DeleteMarkerEntry::DeleteMarkerEntry(const XmlNode& xmlNode) : |
44 | m_ownerHasBeenSet(false), |
45 | m_keyHasBeenSet(false), |
46 | m_versionIdHasBeenSet(false), |
47 | m_isLatest(false), |
48 | m_isLatestHasBeenSet(false), |
49 | m_lastModifiedHasBeenSet(false) |
50 | { |
51 | *this = xmlNode; |
52 | } |
53 | |
54 | DeleteMarkerEntry& DeleteMarkerEntry::operator =(const XmlNode& xmlNode) |
55 | { |
56 | XmlNode resultNode = xmlNode; |
57 | |
58 | if(!resultNode.IsNull()) |
59 | { |
60 | XmlNode ownerNode = resultNode.FirstChild("Owner" ); |
61 | if(!ownerNode.IsNull()) |
62 | { |
63 | m_owner = ownerNode; |
64 | m_ownerHasBeenSet = true; |
65 | } |
66 | XmlNode keyNode = resultNode.FirstChild("Key" ); |
67 | if(!keyNode.IsNull()) |
68 | { |
69 | m_key = Aws::Utils::Xml::DecodeEscapedXmlText(keyNode.GetText()); |
70 | m_keyHasBeenSet = true; |
71 | } |
72 | XmlNode versionIdNode = resultNode.FirstChild("VersionId" ); |
73 | if(!versionIdNode.IsNull()) |
74 | { |
75 | m_versionId = Aws::Utils::Xml::DecodeEscapedXmlText(versionIdNode.GetText()); |
76 | m_versionIdHasBeenSet = true; |
77 | } |
78 | XmlNode isLatestNode = resultNode.FirstChild("IsLatest" ); |
79 | if(!isLatestNode.IsNull()) |
80 | { |
81 | m_isLatest = StringUtils::ConvertToBool(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(isLatestNode.GetText()).c_str()).c_str()); |
82 | m_isLatestHasBeenSet = true; |
83 | } |
84 | XmlNode lastModifiedNode = resultNode.FirstChild("LastModified" ); |
85 | if(!lastModifiedNode.IsNull()) |
86 | { |
87 | m_lastModified = DateTime(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(lastModifiedNode.GetText()).c_str()).c_str(), DateFormat::ISO_8601); |
88 | m_lastModifiedHasBeenSet = true; |
89 | } |
90 | } |
91 | |
92 | return *this; |
93 | } |
94 | |
95 | void DeleteMarkerEntry::AddToNode(XmlNode& parentNode) const |
96 | { |
97 | Aws::StringStream ss; |
98 | if(m_ownerHasBeenSet) |
99 | { |
100 | XmlNode ownerNode = parentNode.CreateChildElement("Owner" ); |
101 | m_owner.AddToNode(ownerNode); |
102 | } |
103 | |
104 | if(m_keyHasBeenSet) |
105 | { |
106 | XmlNode keyNode = parentNode.CreateChildElement("Key" ); |
107 | keyNode.SetText(m_key); |
108 | } |
109 | |
110 | if(m_versionIdHasBeenSet) |
111 | { |
112 | XmlNode versionIdNode = parentNode.CreateChildElement("VersionId" ); |
113 | versionIdNode.SetText(m_versionId); |
114 | } |
115 | |
116 | if(m_isLatestHasBeenSet) |
117 | { |
118 | XmlNode isLatestNode = parentNode.CreateChildElement("IsLatest" ); |
119 | ss << std::boolalpha << m_isLatest; |
120 | isLatestNode.SetText(ss.str()); |
121 | ss.str("" ); |
122 | } |
123 | |
124 | if(m_lastModifiedHasBeenSet) |
125 | { |
126 | XmlNode lastModifiedNode = parentNode.CreateChildElement("LastModified" ); |
127 | lastModifiedNode.SetText(m_lastModified.ToGmtString(DateFormat::ISO_8601)); |
128 | } |
129 | |
130 | } |
131 | |
132 | } // namespace Model |
133 | } // namespace S3 |
134 | } // namespace Aws |
135 | |