AWS SDK for C++  0.12.9
AWS SDK for C++
XmlSerializer.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010-2016 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 #pragma once
17 
18 #include <aws/core/Core_EXPORTS.h>
19 
20 #include <aws/core/utils/Outcome.h>
23 
24 namespace Aws
25 {
26  namespace External
27  {
28  namespace tinyxml2
29  {
30  class XMLNode;
31 
32  class XMLDocument;
33  } // namespace tinyxml2
34  } // namespace External
35 } // namespace Aws
36 
37 namespace Aws
38 {
39  template<typename PAYLOAD_TYPE>
40  class AmazonWebServiceResult;
41  namespace Client
42  {
43  enum class CoreErrors;
44  template<typename ERROR_TYPE>
45  class AWSError;
46  class AWSXMLClient;
47  } // namespace Client
48  namespace Utils
49  {
50  namespace Xml
51  {
56 
57  class XmlDocument;
58 
63  {
64  public:
68  XmlNode(const XmlNode& other);
72  XmlNode& operator=(const XmlNode& other);
76  const Aws::String GetName() const;
80  void SetName(const Aws::String& name);
84  const Aws::String GetAttributeValue(const Aws::String& name) const;
88  void SetAttributeValue(const Aws::String& name, const Aws::String& value);
92  Aws::String GetText() const;
96  void SetText(const Aws::String& textValue);
100  bool HasNextNode() const;
104  XmlNode NextNode() const;
108  XmlNode NextNode(const char* name) const;
112  XmlNode NextNode(const Aws::String& name) const;
116  XmlNode FirstChild() const;
120  XmlNode FirstChild(const char* name) const;
124  XmlNode FirstChild(const Aws::String& name) const;
128  bool HasChildren() const;
132  XmlNode Parent() const;
136  XmlNode CreateChildElement(const Aws::String& name);
140  XmlNode CreateSiblingElement(const Aws::String& name);
144  bool IsNull();
145 
146  private:
147  XmlNode(Aws::External::tinyxml2::XMLNode* node, const XmlDocument& document) :
148  m_node(node), m_doc(&document)
149  {
150  }
151 
152  //we do not own these.... I just had to change it from ref because the compiler was
153  //confused about which assignment operator to call. Do not... I repeat... do not delete
154  //these pointers in your destructor.
156  const XmlDocument* m_doc;
157 
158  friend class XmlDocument;
159  };
160 
166  {
167  public:
171  XmlDocument(XmlDocument&& doc);
172  XmlDocument(const XmlDocument& other) = delete;
173 
174  ~XmlDocument();
175 
179  XmlNode GetRootElement() const;
183  Aws::String ConvertToString() const;
188  bool WasParseSuccessful() const;
192  Aws::String GetErrorMessage() const;
196  static XmlDocument CreateFromXmlStream(Aws::IOStream&);
200  static XmlDocument CreateFromXmlString(const Aws::String&);
204  static XmlDocument CreateWithRootNode(const Aws::String&);
205 
206  private:
207  XmlDocument();
208 
210 
211  friend class XmlNode;
212 
213  //allow outcome call the default constructor to handle it's error case.
214  friend class Aws::Utils::Outcome<Aws::AmazonWebServiceResult<Aws::Utils::Xml::XmlDocument>, Aws::Client::AWSError<Aws::Client::CoreErrors>>;
215  friend class Aws::AmazonWebServiceResult<Aws::Utils::Xml::XmlDocument>;
216  friend class Client::AWSXMLClient;
217  };
218 
219  } // namespace Xml
220  } // namespace Utils
221 } // namespace Aws
222 
std::basic_iostream< char, std::char_traits< char > > IOStream
Definition: AWSStreamFwd.h:32
AWS_CORE_API Aws::String DecodeEscapedXmlText(const Aws::String &textToDecode)
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition: AWSString.h:97
#define AWS_CORE_API
Definition: Core_EXPORTS.h:30
JSON (JavaScript Object Notation).