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/CSVOutput.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
33CSVOutput::CSVOutput() :
34 m_quoteFields(QuoteFields::NOT_SET),
35 m_quoteFieldsHasBeenSet(false),
36 m_quoteEscapeCharacterHasBeenSet(false),
37 m_recordDelimiterHasBeenSet(false),
38 m_fieldDelimiterHasBeenSet(false),
39 m_quoteCharacterHasBeenSet(false)
40{
41}
42
43CSVOutput::CSVOutput(const XmlNode& xmlNode) :
44 m_quoteFields(QuoteFields::NOT_SET),
45 m_quoteFieldsHasBeenSet(false),
46 m_quoteEscapeCharacterHasBeenSet(false),
47 m_recordDelimiterHasBeenSet(false),
48 m_fieldDelimiterHasBeenSet(false),
49 m_quoteCharacterHasBeenSet(false)
50{
51 *this = xmlNode;
52}
53
54CSVOutput& CSVOutput::operator =(const XmlNode& xmlNode)
55{
56 XmlNode resultNode = xmlNode;
57
58 if(!resultNode.IsNull())
59 {
60 XmlNode quoteFieldsNode = resultNode.FirstChild("QuoteFields");
61 if(!quoteFieldsNode.IsNull())
62 {
63 m_quoteFields = QuoteFieldsMapper::GetQuoteFieldsForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(quoteFieldsNode.GetText()).c_str()).c_str());
64 m_quoteFieldsHasBeenSet = true;
65 }
66 XmlNode quoteEscapeCharacterNode = resultNode.FirstChild("QuoteEscapeCharacter");
67 if(!quoteEscapeCharacterNode.IsNull())
68 {
69 m_quoteEscapeCharacter = Aws::Utils::Xml::DecodeEscapedXmlText(quoteEscapeCharacterNode.GetText());
70 m_quoteEscapeCharacterHasBeenSet = true;
71 }
72 XmlNode recordDelimiterNode = resultNode.FirstChild("RecordDelimiter");
73 if(!recordDelimiterNode.IsNull())
74 {
75 m_recordDelimiter = Aws::Utils::Xml::DecodeEscapedXmlText(recordDelimiterNode.GetText());
76 m_recordDelimiterHasBeenSet = true;
77 }
78 XmlNode fieldDelimiterNode = resultNode.FirstChild("FieldDelimiter");
79 if(!fieldDelimiterNode.IsNull())
80 {
81 m_fieldDelimiter = Aws::Utils::Xml::DecodeEscapedXmlText(fieldDelimiterNode.GetText());
82 m_fieldDelimiterHasBeenSet = true;
83 }
84 XmlNode quoteCharacterNode = resultNode.FirstChild("QuoteCharacter");
85 if(!quoteCharacterNode.IsNull())
86 {
87 m_quoteCharacter = Aws::Utils::Xml::DecodeEscapedXmlText(quoteCharacterNode.GetText());
88 m_quoteCharacterHasBeenSet = true;
89 }
90 }
91
92 return *this;
93}
94
95void CSVOutput::AddToNode(XmlNode& parentNode) const
96{
97 Aws::StringStream ss;
98 if(m_quoteFieldsHasBeenSet)
99 {
100 XmlNode quoteFieldsNode = parentNode.CreateChildElement("QuoteFields");
101 quoteFieldsNode.SetText(QuoteFieldsMapper::GetNameForQuoteFields(m_quoteFields));
102 }
103
104 if(m_quoteEscapeCharacterHasBeenSet)
105 {
106 XmlNode quoteEscapeCharacterNode = parentNode.CreateChildElement("QuoteEscapeCharacter");
107 quoteEscapeCharacterNode.SetText(m_quoteEscapeCharacter);
108 }
109
110 if(m_recordDelimiterHasBeenSet)
111 {
112 XmlNode recordDelimiterNode = parentNode.CreateChildElement("RecordDelimiter");
113 recordDelimiterNode.SetText(m_recordDelimiter);
114 }
115
116 if(m_fieldDelimiterHasBeenSet)
117 {
118 XmlNode fieldDelimiterNode = parentNode.CreateChildElement("FieldDelimiter");
119 fieldDelimiterNode.SetText(m_fieldDelimiter);
120 }
121
122 if(m_quoteCharacterHasBeenSet)
123 {
124 XmlNode quoteCharacterNode = parentNode.CreateChildElement("QuoteCharacter");
125 quoteCharacterNode.SetText(m_quoteCharacter);
126 }
127
128}
129
130} // namespace Model
131} // namespace S3
132} // namespace Aws
133