AWS SDK for C++

AWS SDK for C++ Version 1.11.929

Loading...
Searching...
No Matches
AbstractDocument.h
1
5#pragma once
6
7#include <aws/core/Core_EXPORTS.h>
8#include <aws/core/utils/Array.h>
9#include <aws/core/utils/DateTime.h>
10#include <aws/core/utils/memory/stl/AWSMap.h>
11#include <aws/core/utils/memory/stl/AWSString.h>
12#include <aws/core/utils/memory/stl/AWSVector.h>
13#include <aws/crt/Optional.h>
14#include <smithy/client/schema/Document.h>
15#include <smithy/client/schema/Schema.h>
16#include <smithy/client/schema/SerdeTraits.h>
17
18#include <cstdint>
19#include <memory>
20
21namespace smithy {
22namespace schema {
23
24// Internal to aws-cpp-sdk-core: the tagged storage and the protocol-independent behavior every
25// Document implementation shares. AsBlob and AsTimestamp are deliberately left pure -- how a String
26// or number node is reinterpreted depends on the protocol that built it, so the base stays abstract
27// and each leaf must answer. StoredBlob/StoredTimestamp give leaves the identity rule to build on.
28class AWS_CORE_LOCAL AbstractDocument : public Document {
29 public:
30 ShapeType GetType() const override { return m_type; }
31 bool IsNull() const override { return m_type == ShapeType::Null; }
32
33 Aws::Crt::Optional<bool> AsBoolean() const override;
34 Aws::Crt::Optional<Aws::String> AsString() const override;
35 Aws::Crt::Optional<int> AsInteger() const override;
36 Aws::Crt::Optional<int64_t> AsLong() const override;
37 Aws::Crt::Optional<double> AsDouble() const override;
38 Aws::Crt::Optional<float> AsFloat() const override;
39
40 std::shared_ptr<const Aws::Vector<std::shared_ptr<const Document>>> AsList() const override;
41 std::shared_ptr<const Aws::Map<Aws::String, std::shared_ptr<const Document>>> AsMap() const override;
42 std::shared_ptr<const Document> GetMember(const Aws::String& name) const override;
44
45 void Serialize(ShapeSerializer& serializer, const Schema& schema) const override;
46
47 // Storage mutators -- set m_type plus the matching field. Used only while a factory builds the
48 // node; it is held const afterward. Public surface is acceptable on an internal type.
49 void SetBoolean(bool value);
50 void SetInteger(int64_t value);
51 void SetDouble(double value);
55 // Null entries are replaced with Document::Null() so the tree has no dangling children.
56 void SetList(Aws::Vector<std::shared_ptr<const Document>> value);
57 void SetMap(Aws::Map<Aws::String, std::shared_ptr<const Document>> value);
58
59 protected:
60 // Identity coercion shared by every leaf: a node already holding the target type.
61 Aws::Crt::Optional<Aws::Utils::ByteBuffer> StoredBlob() const;
62 Aws::Crt::Optional<Aws::Utils::DateTime> StoredTimestamp() const;
63
64 ShapeType m_type = ShapeType::Null;
65 bool m_bool = false;
66 int64_t m_int = 0;
67 double m_double = 0.0;
71 // Null unless m_type is List/Map; shared with every AsList/AsMap caller.
72 std::shared_ptr<const Aws::Vector<std::shared_ptr<const Document>>> m_list;
73 std::shared_ptr<const Aws::Map<Aws::String, std::shared_ptr<const Document>>> m_map;
74};
75
76// Builds an empty JSON-flavored node for the JSON deserializer to fill through the storage setters.
77// The concrete type lives in Document.cpp alongside the protocol-agnostic one, so JSON's coercion
78// rules are visible next to the rules they differ from and neither type is nameable elsewhere.
79AWS_CORE_LOCAL std::shared_ptr<AbstractDocument> NewJsonDocument(TimestampFormatTrait::Format defaultStringTimestampFormat);
80
81} // namespace schema
82} // namespace smithy
void SetInteger(int64_t value)
ShapeType GetType() const override
std::shared_ptr< const Document > GetMember(const Aws::String &name) const override
Aws::Vector< Aws::String > GetMemberNames() const override
void SetTimestamp(Aws::Utils::DateTime value)
Aws::Crt::Optional< int64_t > AsLong() const override
Aws::Crt::Optional< Aws::Utils::DateTime > StoredTimestamp() const
Aws::Crt::Optional< Aws::Utils::ByteBuffer > StoredBlob() const
void SetBlob(Aws::Utils::ByteBuffer value)
Aws::Crt::Optional< bool > AsBoolean() const override
void SetList(Aws::Vector< std::shared_ptr< const Document > > value)
std::shared_ptr< const Aws::Vector< std::shared_ptr< const Document > > > m_list
std::shared_ptr< const Aws::Map< Aws::String, std::shared_ptr< const Document > > > m_map
Aws::Crt::Optional< double > AsDouble() const override
Aws::Crt::Optional< Aws::String > AsString() const override
std::shared_ptr< const Aws::Vector< std::shared_ptr< const Document > > > AsList() const override
void SetString(Aws::String value)
void Serialize(ShapeSerializer &serializer, const Schema &schema) const override
std::shared_ptr< const Aws::Map< Aws::String, std::shared_ptr< const Document > > > AsMap() const override
Aws::Crt::Optional< float > AsFloat() const override
Aws::Crt::Optional< int > AsInteger() const override
void SetMap(Aws::Map< Aws::String, std::shared_ptr< const Document > > value)
std::map< K, V, std::less< K >, Aws::Allocator< std::pair< const K, V > > > Map
Definition AWSMap.h:20
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition AWSString.h:97
std::vector< T, Aws::Allocator< T > > Vector
Definition AWSVector.h:17
AWS_CORE_LOCAL std::shared_ptr< AbstractDocument > NewJsonDocument(TimestampFormatTrait::Format defaultStringTimestampFormat)