Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

making the inheritance final


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
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
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 src/aws-cpp-sdk-core/include/smithy/client/schema/Schema.h
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
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
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
Loading