diff --git a/src/aws-cpp-sdk-core/include/smithy/client/schema/CborShapeSerializer.h b/src/aws-cpp-sdk-core/include/smithy/client/schema/CborShapeSerializer.h new file mode 100644 index 00000000000..13636bc3177 --- /dev/null +++ b/src/aws-cpp-sdk-core/include/smithy/client/schema/CborShapeSerializer.h @@ -0,0 +1,47 @@ +#pragma once + +#include +#include + +#include + +namespace smithy { +namespace schema { + +class AWS_CORE_API CborShapeSerializer : public ShapeSerializer { + public: + CborShapeSerializer(); + ~CborShapeSerializer(); + + void BeginStructure(const Schema& schema) override; + void EndStructure() override; + + void WriteBoolean(const Schema& schema, bool value) override; + void WriteInteger(const Schema& schema, int value) override; + void WriteLong(const Schema& schema, int64_t value) override; + void WriteDouble(const Schema& schema, double value) override; + void WriteString(const Schema& schema, const Aws::String& value) override; + void WriteTimestamp(const Schema& schema, const Aws::Utils::DateTime& value) override; + void WriteBlob(const Schema& schema, const Aws::Utils::ByteBuffer& value) override; + void WriteEnum(const Schema& schema, int value) override; + void WriteNull(const Schema& schema) override; + + void BeginList(const Schema& schema, size_t count) override; + void EndList() override; + + void BeginMap(const Schema& schema, size_t count) override; + void WriteMapKey(const Aws::String& key) override; + void EndMap() override; + + void BeginNestedStructure(const Schema& schema) override; + void EndNestedStructure() override; + + Aws::String GetPayload() const; + + private: + struct Impl; + std::unique_ptr m_impl; +}; + +} // namespace schema +} // namespace smithy diff --git a/src/aws-cpp-sdk-core/include/smithy/client/schema/JsonShapeSerializer.h b/src/aws-cpp-sdk-core/include/smithy/client/schema/JsonShapeSerializer.h new file mode 100644 index 00000000000..a2063a8bdd9 --- /dev/null +++ b/src/aws-cpp-sdk-core/include/smithy/client/schema/JsonShapeSerializer.h @@ -0,0 +1,46 @@ +#pragma once + +#include + +#include + +namespace smithy { +namespace schema { + +class JsonShapeSerializer : public ShapeSerializer { + public: + JsonShapeSerializer(); + ~JsonShapeSerializer(); + + void BeginStructure(const Schema& schema) override; + void EndStructure() override; + + void WriteBoolean(const Schema& schema, bool value) override; + void WriteInteger(const Schema& schema, int value) override; + void WriteLong(const Schema& schema, int64_t value) override; + void WriteDouble(const Schema& schema, double value) override; + void WriteString(const Schema& schema, const Aws::String& value) override; + void WriteTimestamp(const Schema& schema, const Aws::Utils::DateTime& value) override; + void WriteBlob(const Schema& schema, const Aws::Utils::ByteBuffer& value) override; + void WriteEnum(const Schema& schema, int value) override; + void WriteNull(const Schema& schema) override; + + void BeginList(const Schema& schema, size_t count) override; + void EndList() override; + + void BeginMap(const Schema& schema, size_t count) override; + void WriteMapKey(const Aws::String& key) override; + void EndMap() override; + + void BeginNestedStructure(const Schema& schema) override; + void EndNestedStructure() override; + + Aws::String GetPayload() const; + + private: + struct Impl; + std::unique_ptr m_impl; +}; + +} // namespace schema +} // namespace smithy diff --git a/src/aws-cpp-sdk-core/include/smithy/client/schema/QueryShapeSerializer.h b/src/aws-cpp-sdk-core/include/smithy/client/schema/QueryShapeSerializer.h new file mode 100644 index 00000000000..d31668e2695 --- /dev/null +++ b/src/aws-cpp-sdk-core/include/smithy/client/schema/QueryShapeSerializer.h @@ -0,0 +1,46 @@ +#pragma once + +#include + +#include + +namespace smithy { +namespace schema { + +class QueryShapeSerializer : public ShapeSerializer { + public: + QueryShapeSerializer(const Aws::String& action, const Aws::String& version); + ~QueryShapeSerializer(); + + void BeginStructure(const Schema& schema) override; + void EndStructure() override; + + void WriteBoolean(const Schema& schema, bool value) override; + void WriteInteger(const Schema& schema, int value) override; + void WriteLong(const Schema& schema, int64_t value) override; + void WriteDouble(const Schema& schema, double value) override; + void WriteString(const Schema& schema, const Aws::String& value) override; + void WriteTimestamp(const Schema& schema, const Aws::Utils::DateTime& value) override; + void WriteBlob(const Schema& schema, const Aws::Utils::ByteBuffer& value) override; + void WriteEnum(const Schema& schema, int value) override; + void WriteNull(const Schema& schema) override; + + void BeginList(const Schema& schema, size_t count) override; + void EndList() override; + + void BeginMap(const Schema& schema, size_t count) override; + void WriteMapKey(const Aws::String& key) override; + void EndMap() override; + + void BeginNestedStructure(const Schema& schema) override; + void EndNestedStructure() override; + + Aws::String GetPayload() const; + + private: + struct Impl; + std::unique_ptr m_impl; +}; + +} // namespace schema +} // namespace smithy diff --git a/src/aws-cpp-sdk-core/include/smithy/client/schema/Schema.h b/src/aws-cpp-sdk-core/include/smithy/client/schema/Schema.h new file mode 100644 index 00000000000..a8a8cacb3a6 --- /dev/null +++ b/src/aws-cpp-sdk-core/include/smithy/client/schema/Schema.h @@ -0,0 +1,60 @@ +#pragma once + +#include + +#include + +namespace smithy { +namespace schema { + +enum class ShapeType : uint8_t { + Boolean, + Byte, + Short, + Integer, + Long, + Float, + Double, + BigInteger, + BigDecimal, + String, + Enum, + IntEnum, + Blob, + Timestamp, + Document, + List, + Map, + Structure, + Union, + Operation, + Resource, + Service +}; + +class Schema { + public: + Schema() = default; + + ShapeType GetType() const { return m_type; } + const char* GetId() const { return m_id; } + const char* GetMemberName() const { return m_memberName; } + int GetMemberIndex() const { return m_memberIndex; } + bool IsMember() const { return m_memberName != nullptr; } + + const Schema* GetMember(const char* name) const; + const Schema* GetMember(int index) const; + + uint16_t GetMemberCount() const { return m_memberCount; } + + private: + const char* m_id = nullptr; + ShapeType m_type = ShapeType::Structure; + const char* m_memberName = nullptr; + int m_memberIndex = 0; + const Schema* m_members = nullptr; + uint16_t m_memberCount = 0; +}; + +} // namespace schema +} // namespace smithy diff --git a/src/aws-cpp-sdk-core/include/smithy/client/schema/ShapeSerializer.h b/src/aws-cpp-sdk-core/include/smithy/client/schema/ShapeSerializer.h new file mode 100644 index 00000000000..41279e7f5a9 --- /dev/null +++ b/src/aws-cpp-sdk-core/include/smithy/client/schema/ShapeSerializer.h @@ -0,0 +1,42 @@ +#pragma once + +#include +#include +#include +#include + +#include + +namespace smithy { +namespace schema { + +class ShapeSerializer { + public: + virtual ~ShapeSerializer() = default; + + virtual void BeginStructure(const Schema& schema) = 0; + virtual void EndStructure() = 0; + + virtual void WriteBoolean(const Schema& schema, bool value) = 0; + virtual void WriteInteger(const Schema& schema, int value) = 0; + virtual void WriteLong(const Schema& schema, int64_t value) = 0; + virtual void WriteDouble(const Schema& schema, double value) = 0; + virtual void WriteString(const Schema& schema, const Aws::String& value) = 0; + virtual void WriteTimestamp(const Schema& schema, const Aws::Utils::DateTime& value) = 0; + virtual void WriteBlob(const Schema& schema, const Aws::Utils::ByteBuffer& value) = 0; + virtual void WriteEnum(const Schema& schema, int value) = 0; + virtual void WriteNull(const Schema& schema) = 0; + + virtual void BeginList(const Schema& schema, size_t count) = 0; + virtual void EndList() = 0; + + virtual void BeginMap(const Schema& schema, size_t count) = 0; + virtual void WriteMapKey(const Aws::String& key) = 0; + virtual void EndMap() = 0; + + virtual void BeginNestedStructure(const Schema& schema) = 0; + virtual void EndNestedStructure() = 0; +}; + +} // namespace schema +} // namespace smithy diff --git a/src/aws-cpp-sdk-core/include/smithy/client/schema/XmlShapeSerializer.h b/src/aws-cpp-sdk-core/include/smithy/client/schema/XmlShapeSerializer.h new file mode 100644 index 00000000000..9f35230dc7e --- /dev/null +++ b/src/aws-cpp-sdk-core/include/smithy/client/schema/XmlShapeSerializer.h @@ -0,0 +1,46 @@ +#pragma once + +#include + +#include + +namespace smithy { +namespace schema { + +class XmlShapeSerializer : public ShapeSerializer { + public: + XmlShapeSerializer(); + ~XmlShapeSerializer(); + + void BeginStructure(const Schema& schema) override; + void EndStructure() override; + + void WriteBoolean(const Schema& schema, bool value) override; + void WriteInteger(const Schema& schema, int value) override; + void WriteLong(const Schema& schema, int64_t value) override; + void WriteDouble(const Schema& schema, double value) override; + void WriteString(const Schema& schema, const Aws::String& value) override; + void WriteTimestamp(const Schema& schema, const Aws::Utils::DateTime& value) override; + void WriteBlob(const Schema& schema, const Aws::Utils::ByteBuffer& value) override; + void WriteEnum(const Schema& schema, int value) override; + void WriteNull(const Schema& schema) override; + + void BeginList(const Schema& schema, size_t count) override; + void EndList() override; + + void BeginMap(const Schema& schema, size_t count) override; + void WriteMapKey(const Aws::String& key) override; + void EndMap() override; + + void BeginNestedStructure(const Schema& schema) override; + void EndNestedStructure() override; + + Aws::String GetPayload() const; + + private: + struct Impl; + std::unique_ptr m_impl; +}; + +} // namespace schema +} // namespace smithy