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/DeletedObject.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
23using namespace Aws::Utils::Xml;
24using namespace Aws::Utils;
25
26namespace Aws
27{
28namespace S3
29{
30namespace Model
31{
32
33DeletedObject::DeletedObject() :
34 m_keyHasBeenSet(false),
35 m_versionIdHasBeenSet(false),
36 m_deleteMarker(false),
37 m_deleteMarkerHasBeenSet(false),
38 m_deleteMarkerVersionIdHasBeenSet(false)
39{
40}
41
42DeletedObject::DeletedObject(const XmlNode& xmlNode) :
43 m_keyHasBeenSet(false),
44 m_versionIdHasBeenSet(false),
45 m_deleteMarker(false),
46 m_deleteMarkerHasBeenSet(false),
47 m_deleteMarkerVersionIdHasBeenSet(false)
48{
49 *this = xmlNode;
50}
51
52DeletedObject& DeletedObject::operator =(const XmlNode& xmlNode)
53{
54 XmlNode resultNode = xmlNode;
55
56 if(!resultNode.IsNull())
57 {
58 XmlNode keyNode = resultNode.FirstChild("Key");
59 if(!keyNode.IsNull())
60 {
61 m_key = Aws::Utils::Xml::DecodeEscapedXmlText(keyNode.GetText());
62 m_keyHasBeenSet = true;
63 }
64 XmlNode versionIdNode = resultNode.FirstChild("VersionId");
65 if(!versionIdNode.IsNull())
66 {
67 m_versionId = Aws::Utils::Xml::DecodeEscapedXmlText(versionIdNode.GetText());
68 m_versionIdHasBeenSet = true;
69 }
70 XmlNode deleteMarkerNode = resultNode.FirstChild("DeleteMarker");
71 if(!deleteMarkerNode.IsNull())
72 {
73 m_deleteMarker = StringUtils::ConvertToBool(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(deleteMarkerNode.GetText()).c_str()).c_str());
74 m_deleteMarkerHasBeenSet = true;
75 }
76 XmlNode deleteMarkerVersionIdNode = resultNode.FirstChild("DeleteMarkerVersionId");
77 if(!deleteMarkerVersionIdNode.IsNull())
78 {
79 m_deleteMarkerVersionId = Aws::Utils::Xml::DecodeEscapedXmlText(deleteMarkerVersionIdNode.GetText());
80 m_deleteMarkerVersionIdHasBeenSet = true;
81 }
82 }
83
84 return *this;
85}
86
87void DeletedObject::AddToNode(XmlNode& parentNode) const
88{
89 Aws::StringStream ss;
90 if(m_keyHasBeenSet)
91 {
92 XmlNode keyNode = parentNode.CreateChildElement("Key");
93 keyNode.SetText(m_key);
94 }
95
96 if(m_versionIdHasBeenSet)
97 {
98 XmlNode versionIdNode = parentNode.CreateChildElement("VersionId");
99 versionIdNode.SetText(m_versionId);
100 }
101
102 if(m_deleteMarkerHasBeenSet)
103 {
104 XmlNode deleteMarkerNode = parentNode.CreateChildElement("DeleteMarker");
105 ss << std::boolalpha << m_deleteMarker;
106 deleteMarkerNode.SetText(ss.str());
107 ss.str("");
108 }
109
110 if(m_deleteMarkerVersionIdHasBeenSet)
111 {
112 XmlNode deleteMarkerVersionIdNode = parentNode.CreateChildElement("DeleteMarkerVersionId");
113 deleteMarkerVersionIdNode.SetText(m_deleteMarkerVersionId);
114 }
115
116}
117
118} // namespace Model
119} // namespace S3
120} // namespace Aws
121