-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Schema types and ShapeSerializer interface #3837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pulimsr
wants to merge
5
commits into
main
Choose a base branch
from
schema-serde
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+287
−0
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6145212
headers for protocol shapes
pulimsr 030a0ea
Merge branch 'main' of github.com:aws/aws-sdk-cpp into schema-serde
pulimsr 9e6b107
Schema class and ShapeSerializer interface with PIMPL serializers
pulimsr 87d5452
Merge branch 'main' of github.com:aws/aws-sdk-cpp into schema-serde
pulimsr 6d7084f
making the inheritance for the shapeSerializer's final
pulimsr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
src/aws-cpp-sdk-core/include/smithy/client/schema/CborShapeSerializer.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| #pragma once | ||
|
|
||
| #include <aws/core/Core_EXPORTS.h> | ||
| #include <smithy/client/schema/ShapeSerializer.h> | ||
|
|
||
| #include <memory> | ||
|
|
||
| namespace smithy { | ||
| namespace schema { | ||
|
|
||
| class AWS_CORE_API CborShapeSerialize final : 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<Impl> m_impl; | ||
| }; | ||
|
|
||
| } // namespace schema | ||
| } // namespace smithy | ||
46 changes: 46 additions & 0 deletions
46
src/aws-cpp-sdk-core/include/smithy/client/schema/JsonShapeSerializer.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| #pragma once | ||
|
|
||
| #include <smithy/client/schema/ShapeSerializer.h> | ||
|
|
||
| #include <memory> | ||
|
|
||
| namespace smithy { | ||
| namespace schema { | ||
|
|
||
| class JsonShapeSerializer final : 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<Impl> m_impl; | ||
| }; | ||
|
|
||
| } // namespace schema | ||
| } // namespace smithy |
46 changes: 46 additions & 0 deletions
46
src/aws-cpp-sdk-core/include/smithy/client/schema/QueryShapeSerializer.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| #pragma once | ||
|
|
||
| #include <smithy/client/schema/ShapeSerializer.h> | ||
|
|
||
| #include <memory> | ||
|
|
||
| namespace smithy { | ||
| namespace schema { | ||
|
|
||
| class QueryShapeSerializer final : 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<Impl> m_impl; | ||
| }; | ||
|
|
||
| } // namespace schema | ||
| } // namespace smithy |
60 changes: 60 additions & 0 deletions
60
src/aws-cpp-sdk-core/include/smithy/client/schema/Schema.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| #pragma once | ||
|
|
||
| #include <aws/core/utils/memory/stl/AWSString.h> | ||
|
|
||
| #include <cstdint> | ||
|
|
||
| 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 |
42 changes: 42 additions & 0 deletions
42
src/aws-cpp-sdk-core/include/smithy/client/schema/ShapeSerializer.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #pragma once | ||
|
|
||
| #include <aws/core/utils/Array.h> | ||
| #include <aws/core/utils/DateTime.h> | ||
| #include <aws/core/utils/memory/stl/AWSString.h> | ||
| #include <smithy/client/schema/Schema.h> | ||
|
|
||
| #include <cstdint> | ||
|
|
||
| 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 |
46 changes: 46 additions & 0 deletions
46
src/aws-cpp-sdk-core/include/smithy/client/schema/XmlShapeSerializer.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| #pragma once | ||
|
|
||
| #include <smithy/client/schema/ShapeSerializer.h> | ||
|
|
||
| #include <memory> | ||
|
|
||
| namespace smithy { | ||
| namespace schema { | ||
|
|
||
| class XmlShapeSerializer final : 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<Impl> m_impl; | ||
| }; | ||
|
|
||
| } // namespace schema | ||
| } // namespace smithy |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
destructors need to be virtual or inheritance needs to be final
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
making the inheritance final