| 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/LifecycleExpiration.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 | LifecycleExpiration::LifecycleExpiration() : |
| 34 | m_dateHasBeenSet(false), |
| 35 | m_days(0), |
| 36 | m_daysHasBeenSet(false), |
| 37 | m_expiredObjectDeleteMarker(false), |
| 38 | m_expiredObjectDeleteMarkerHasBeenSet(false) |
| 39 | { |
| 40 | } |
| 41 | |
| 42 | LifecycleExpiration::LifecycleExpiration(const XmlNode& xmlNode) : |
| 43 | m_dateHasBeenSet(false), |
| 44 | m_days(0), |
| 45 | m_daysHasBeenSet(false), |
| 46 | m_expiredObjectDeleteMarker(false), |
| 47 | m_expiredObjectDeleteMarkerHasBeenSet(false) |
| 48 | { |
| 49 | *this = xmlNode; |
| 50 | } |
| 51 | |
| 52 | LifecycleExpiration& LifecycleExpiration::operator =(const XmlNode& xmlNode) |
| 53 | { |
| 54 | XmlNode resultNode = xmlNode; |
| 55 | |
| 56 | if(!resultNode.IsNull()) |
| 57 | { |
| 58 | XmlNode dateNode = resultNode.FirstChild("Date" ); |
| 59 | if(!dateNode.IsNull()) |
| 60 | { |
| 61 | m_date = DateTime(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(dateNode.GetText()).c_str()).c_str(), DateFormat::ISO_8601); |
| 62 | m_dateHasBeenSet = true; |
| 63 | } |
| 64 | XmlNode daysNode = resultNode.FirstChild("Days" ); |
| 65 | if(!daysNode.IsNull()) |
| 66 | { |
| 67 | m_days = StringUtils::ConvertToInt32(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(daysNode.GetText()).c_str()).c_str()); |
| 68 | m_daysHasBeenSet = true; |
| 69 | } |
| 70 | XmlNode expiredObjectDeleteMarkerNode = resultNode.FirstChild("ExpiredObjectDeleteMarker" ); |
| 71 | if(!expiredObjectDeleteMarkerNode.IsNull()) |
| 72 | { |
| 73 | m_expiredObjectDeleteMarker = StringUtils::ConvertToBool(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(expiredObjectDeleteMarkerNode.GetText()).c_str()).c_str()); |
| 74 | m_expiredObjectDeleteMarkerHasBeenSet = true; |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | return *this; |
| 79 | } |
| 80 | |
| 81 | void LifecycleExpiration::AddToNode(XmlNode& parentNode) const |
| 82 | { |
| 83 | Aws::StringStream ss; |
| 84 | if(m_dateHasBeenSet) |
| 85 | { |
| 86 | XmlNode dateNode = parentNode.CreateChildElement("Date" ); |
| 87 | dateNode.SetText(m_date.ToGmtString(DateFormat::ISO_8601)); |
| 88 | } |
| 89 | |
| 90 | if(m_daysHasBeenSet) |
| 91 | { |
| 92 | XmlNode daysNode = parentNode.CreateChildElement("Days" ); |
| 93 | ss << m_days; |
| 94 | daysNode.SetText(ss.str()); |
| 95 | ss.str("" ); |
| 96 | } |
| 97 | |
| 98 | if(m_expiredObjectDeleteMarkerHasBeenSet) |
| 99 | { |
| 100 | XmlNode expiredObjectDeleteMarkerNode = parentNode.CreateChildElement("ExpiredObjectDeleteMarker" ); |
| 101 | ss << std::boolalpha << m_expiredObjectDeleteMarker; |
| 102 | expiredObjectDeleteMarkerNode.SetText(ss.str()); |
| 103 | ss.str("" ); |
| 104 | } |
| 105 | |
| 106 | } |
| 107 | |
| 108 | } // namespace Model |
| 109 | } // namespace S3 |
| 110 | } // namespace Aws |
| 111 | |