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/Stats.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 | Stats::Stats() : |
34 | m_bytesScanned(0), |
35 | m_bytesScannedHasBeenSet(false), |
36 | m_bytesProcessed(0), |
37 | m_bytesProcessedHasBeenSet(false), |
38 | m_bytesReturned(0), |
39 | m_bytesReturnedHasBeenSet(false) |
40 | { |
41 | } |
42 | |
43 | Stats::Stats(const XmlNode& xmlNode) : |
44 | m_bytesScanned(0), |
45 | m_bytesScannedHasBeenSet(false), |
46 | m_bytesProcessed(0), |
47 | m_bytesProcessedHasBeenSet(false), |
48 | m_bytesReturned(0), |
49 | m_bytesReturnedHasBeenSet(false) |
50 | { |
51 | *this = xmlNode; |
52 | } |
53 | |
54 | Stats& Stats::operator =(const XmlNode& xmlNode) |
55 | { |
56 | XmlNode resultNode = xmlNode; |
57 | |
58 | if(!resultNode.IsNull()) |
59 | { |
60 | XmlNode bytesScannedNode = resultNode.FirstChild("BytesScanned" ); |
61 | if(!bytesScannedNode.IsNull()) |
62 | { |
63 | m_bytesScanned = StringUtils::ConvertToInt64(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(bytesScannedNode.GetText()).c_str()).c_str()); |
64 | m_bytesScannedHasBeenSet = true; |
65 | } |
66 | XmlNode bytesProcessedNode = resultNode.FirstChild("BytesProcessed" ); |
67 | if(!bytesProcessedNode.IsNull()) |
68 | { |
69 | m_bytesProcessed = StringUtils::ConvertToInt64(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(bytesProcessedNode.GetText()).c_str()).c_str()); |
70 | m_bytesProcessedHasBeenSet = true; |
71 | } |
72 | XmlNode bytesReturnedNode = resultNode.FirstChild("BytesReturned" ); |
73 | if(!bytesReturnedNode.IsNull()) |
74 | { |
75 | m_bytesReturned = StringUtils::ConvertToInt64(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(bytesReturnedNode.GetText()).c_str()).c_str()); |
76 | m_bytesReturnedHasBeenSet = true; |
77 | } |
78 | } |
79 | |
80 | return *this; |
81 | } |
82 | |
83 | void Stats::AddToNode(XmlNode& parentNode) const |
84 | { |
85 | Aws::StringStream ss; |
86 | if(m_bytesScannedHasBeenSet) |
87 | { |
88 | XmlNode bytesScannedNode = parentNode.CreateChildElement("BytesScanned" ); |
89 | ss << m_bytesScanned; |
90 | bytesScannedNode.SetText(ss.str()); |
91 | ss.str("" ); |
92 | } |
93 | |
94 | if(m_bytesProcessedHasBeenSet) |
95 | { |
96 | XmlNode bytesProcessedNode = parentNode.CreateChildElement("BytesProcessed" ); |
97 | ss << m_bytesProcessed; |
98 | bytesProcessedNode.SetText(ss.str()); |
99 | ss.str("" ); |
100 | } |
101 | |
102 | if(m_bytesReturnedHasBeenSet) |
103 | { |
104 | XmlNode bytesReturnedNode = parentNode.CreateChildElement("BytesReturned" ); |
105 | ss << m_bytesReturned; |
106 | bytesReturnedNode.SetText(ss.str()); |
107 | ss.str("" ); |
108 | } |
109 | |
110 | } |
111 | |
112 | } // namespace Model |
113 | } // namespace S3 |
114 | } // namespace Aws |
115 | |