/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include #include #include #include #include #include namespace Aws { namespace DynamoDB { namespace Model { class AttributeValue; class AttributeValueValue { public: virtual const Aws::String GetS() const { return {}; } virtual const Aws::String GetN() const { return {}; } virtual const Aws::Utils::ByteBuffer GetB() const { return {}; } virtual const Aws::Vector GetSS() const { return {}; } virtual void AddSItem(const Aws::String& ) { assert(false); } virtual const Aws::Vector GetNS() const { return {}; } virtual void AddNItem(const Aws::String& ) { assert(false); } virtual const Aws::Vector GetBS() const { return {}; } virtual void AddBItem(const Aws::Utils::ByteBuffer&) { assert(false); } virtual const Aws::Map> GetM() const { return {}; } virtual void AddMEntry(const Aws::String& , const std::shared_ptr& ) { assert(false); } virtual const Aws::Vector> GetL() const { return {}; } virtual void AddLItem(const std::shared_ptr& ) { assert(false); } virtual bool GetBool() const { return false; } virtual bool GetNull() const { return false; } virtual bool IsDefault() const = 0; virtual bool operator == (const AttributeValueValue& other) const = 0; virtual Aws::Utils::Json::JsonValue Jsonize() const = 0; virtual ValueType GetType() const = 0; }; /// String data type class AttributeValueString final : public AttributeValueValue { public: explicit AttributeValueString(const Aws::String& value) : m_s(value) {} explicit AttributeValueString(Aws::Utils::Json::JsonView jsonValue) : m_s(jsonValue.GetString("S")) {} const Aws::String GetS() const override { return m_s; } bool IsDefault() const override { return m_s.empty(); } bool operator == (const AttributeValueValue& other) const override { return GetType() == other.GetType() && m_s == other.GetS(); } Aws::Utils::Json::JsonValue Jsonize() const override; ValueType GetType() const override { return ValueType::STRING; } private: Aws::String m_s; }; /// Numeric data type class AttributeValueNumeric final : public AttributeValueValue { public: explicit AttributeValueNumeric(const Aws::String& value) : m_n(value) {} explicit AttributeValueNumeric(Aws::Utils::Json::JsonView jsonValue) : m_n(jsonValue.GetString("N")) {} const Aws::String GetN() const override { return m_n; } bool IsDefault() const override { return m_n.empty(); } bool operator == (const AttributeValueValue& other) const override { return GetType() == other.GetType() && m_n == other.GetN(); }; Aws::Utils::Json::JsonValue Jsonize() const override; ValueType GetType() const override { return ValueType::NUMBER; } private: Aws::String m_n; }; /// Binary data type class AttributeValueByteBuffer final : public AttributeValueValue { public: explicit AttributeValueByteBuffer(const Aws::Utils::ByteBuffer& value) : m_b(value) {} explicit AttributeValueByteBuffer(Aws::Utils::Json::JsonView jsonValue); const Aws::Utils::ByteBuffer GetB() const override { return m_b; } bool IsDefault() const override { return m_b.GetLength() == 0; } bool operator == (const AttributeValueValue& other) const override { return GetType() == other.GetType() && m_b == other.GetB(); } Aws::Utils::Json::JsonValue Jsonize() const override; ValueType GetType() const override { return ValueType::BYTEBUFFER; } private: Aws::Utils::ByteBuffer m_b; }; /// String set data type class AttributeValueStringSet final : public AttributeValueValue { public: explicit AttributeValueStringSet(const Aws::Vector& value) : m_sS(value) {} explicit AttributeValueStringSet(Aws::Utils::Json::JsonView jsonValue); const Aws::Vector GetSS() const override { return m_sS; } void AddSItem(const Aws::String& sItem) override { m_sS.push_back(sItem); } bool IsDefault() const override { return m_sS.empty(); } bool operator == (const AttributeValueValue& other) const override; Aws::Utils::Json::JsonValue Jsonize() const override; ValueType GetType() const override { return ValueType::STRING_SET; } private: Aws::Vector m_sS; }; /// Number set data type class AttributeValueNumberSet final : public AttributeValueValue { public: explicit AttributeValueNumberSet(const Aws::Vector& value) : m_nS(value) {} explicit AttributeValueNumberSet(Aws::Utils::Json::JsonView jsonValue); const Aws::Vector GetNS() const override { return m_nS; } void AddNItem(const Aws::String& nItem) override { m_nS.push_back(nItem); } bool IsDefault() const override { return m_nS.empty(); } bool operator == (const AttributeValueValue& other) const override; Aws::Utils::Json::JsonValue Jsonize() const override; ValueType GetType() const override { return ValueType::NUMBER_SET; } private: Aws::Vector m_nS; }; /// ByteByffer set data type class AttributeValueByteBufferSet final : public AttributeValueValue { public: explicit AttributeValueByteBufferSet(const Aws::Vector& value) : m_bS(value) {} explicit AttributeValueByteBufferSet(Aws::Utils::Json::JsonView jsonValue); const Aws::Vector GetBS() const override { return m_bS; } void AddBItem(const Aws::Utils::ByteBuffer& bItem) override { m_bS.push_back(bItem); } bool IsDefault() const override { return m_bS.empty(); } bool operator == (const AttributeValueValue& other) const override; Aws::Utils::Json::JsonValue Jsonize() const override; ValueType GetType() const override { return ValueType::BYTEBUFFER_SET; } private: Aws::Vector m_bS; }; /// Map Attribute Type class AttributeValueMap final : public AttributeValueValue { public: explicit AttributeValueMap(const Aws::Map>& value) : m_m(value) {} explicit AttributeValueMap(Aws::Utils::Json::JsonView jsonValue); const Aws::Map> GetM() const override{ return m_m; } void AddMEntry(const Aws::String& key, const std::shared_ptr& value) override; bool IsDefault() const override { return m_m.empty(); } bool operator == (const AttributeValueValue& other) const override; Aws::Utils::Json::JsonValue Jsonize() const override; ValueType GetType() const override { return ValueType::ATTRIBUTE_MAP; } private: Aws::Map> m_m; }; /// List Attribute Type class AttributeValueList final : public AttributeValueValue { public: explicit AttributeValueList(const Aws::Vector>& value) : m_l(value) {} explicit AttributeValueList(Aws::Utils::Json::JsonView jsonValue); const Aws::Vector> GetL() const override { return m_l; } void AddLItem(const std::shared_ptr& listItem) override { m_l.push_back(listItem); } bool IsDefault() const override { return m_l.empty(); } bool operator == (const AttributeValueValue& other) const override; Aws::Utils::Json::JsonValue Jsonize() const override; ValueType GetType() const override { return ValueType::ATTRIBUTE_LIST; } private: Aws::Vector> m_l; }; /// Bool type class AttributeValueBool final : public AttributeValueValue { public: explicit AttributeValueBool(bool value) : m_bool(value) {} explicit AttributeValueBool(Aws::Utils::Json::JsonView jsonValue) : m_bool(jsonValue.GetBool("BOOL")) {} bool GetBool() const override { return m_bool; } bool IsDefault() const override { return m_bool == false; } bool operator == (const AttributeValueValue& other) const override { return GetType() == other.GetType() && m_bool == other.GetBool(); } Aws::Utils::Json::JsonValue Jsonize() const override; ValueType GetType() const override { return ValueType::BOOL; } private: bool m_bool; }; /// NULL type class AttributeValueNull final : public AttributeValueValue { public: explicit AttributeValueNull(bool value) : m_null(value) {} explicit AttributeValueNull(Aws::Utils::Json::JsonView jsonValue) : m_null(jsonValue.GetBool("NULL")) {} bool GetNull() const override { return m_null; } bool IsDefault() const override { return m_null == false; } bool operator == (const AttributeValueValue& other) const override { return GetType() == other.GetType() && m_null == other.GetNull(); } Aws::Utils::Json::JsonValue Jsonize() const override; ValueType GetType() const override { return ValueType::NULLVALUE; } private: bool m_null; }; } // Model } // DynamoDB } // Aws