6#include "amqp_header.hpp"
8#include <azure/core/diagnostics/logger.hpp>
9#include <azure/core/internal/diagnostics/log.hpp>
10#include <azure/core/internal/unique_handle.hpp>
11#include <azure/core/uuid.hpp>
24namespace Azure {
namespace Core {
namespace Amqp {
namespace Models {
namespace _detail {
26 class AmqpValueFactory;
29namespace Azure {
namespace Core {
namespace Amqp {
namespace Models {
namespace _internal {
31 enum class TerminusDurability : std::uint32_t
39 enum class TerminusExpiryPolicy
48namespace Azure {
namespace Core {
namespace Amqp {
namespace Models {
50 enum class AmqpValueType
87 std::ostream& operator<<(std::ostream& os, AmqpValueType value);
268 explicit AmqpValue(std::string
const& value);
307 AmqpValue(Azure::Core::Uuid
const& value);
349 operator bool()
const;
357 operator std::uint8_t()
const;
365 operator std::int8_t()
const;
374 operator char()
const;
382 operator std::uint16_t()
const;
390 operator std::int16_t()
const;
398 operator std::uint32_t()
const;
406 operator std::int32_t()
const;
414 operator std::uint64_t()
const;
422 operator std::int64_t()
const;
430 operator float()
const;
438 operator double()
const;
446 operator char32_t()
const;
454 explicit operator std::string()
const;
462 operator Azure::Core::Uuid()
const;
548 AmqpValue(std::unique_ptr<Azure::Core::Amqp::Models::_detail::AmqpValueImpl>&& value);
549 std::unique_ptr<_detail::AmqpValueImpl> m_impl;
550 friend class _detail::AmqpValueFactory;
552 std::ostream& operator<<(std::ostream& os, AmqpValue
const& value);
556namespace Azure {
namespace Core {
namespace Amqp {
namespace Models {
namespace _detail {
563 template <
typename T,
typename ThisType>
class AmqpCollectionBase {
567 using initializer_type = std::initializer_list<typename T::value_type>;
569 AmqpCollectionBase(initializer_type
const& initializer) : m_value{initializer} {}
570 AmqpCollectionBase(T initializer) : m_value{initializer} {}
571 AmqpCollectionBase(){};
574 AmqpCollectionBase(
const AmqpCollectionBase& other) =
default;
577 AmqpCollectionBase& operator=(
const AmqpCollectionBase& other) =
default;
580 AmqpCollectionBase(AmqpCollectionBase&& other)
noexcept =
default;
583 AmqpCollectionBase& operator=(AmqpCollectionBase&& other) =
default;
585 ~AmqpCollectionBase() =
default;
590 explicit operator T
const &()
const {
return m_value; }
593 AmqpValue AsAmqpValue()
const;
596 inline typename T::size_type size()
const {
return m_value.size(); }
602 const typename T::value_type& operator[](
const typename T::size_type pos)
const noexcept
604 return m_value.operator[](pos);
606 void push_back(
typename T::value_type&& val) { m_value.push_back(std::move(val)); }
607 typename T::const_iterator begin() const noexcept {
return m_value.begin(); }
608 typename T::const_iterator end() const noexcept {
return m_value.end(); }
609 size_t find(T
const& val)
noexcept {
return m_value.find(val); }
610 typename T::value_type* data() noexcept {
return m_value.data(); }
611 const typename T::value_type* data() const noexcept {
return m_value.data(); }
612 const typename T::value_type& at(
const typename T::size_type pos)
const
614 return m_value.at(pos);
616 bool operator<(ThisType
const& that)
const {
return m_value < that.m_value; }
617 bool operator==(ThisType
const& that)
const {
return m_value == that.m_value; }
618 bool operator!=(ThisType
const& that)
const {
return m_value != that.m_value; }
620 bool empty() const noexcept {
return m_value.empty(); }
630 virtual operator _detail::AmqpValueImpl()
const;
634namespace Azure {
namespace Core {
namespace Amqp {
namespace Models {
639 class AmqpArray final :
public _detail::AmqpCollectionBase<std::vector<AmqpValue>, AmqpArray> {
645 AmqpArray(initializer_type
const& values);
673 std::ostream& operator<<(std::ostream& os,
AmqpArray const& value);
681 :
public _detail::AmqpCollectionBase<std::map<AmqpValue, AmqpValue>, AmqpMap> {
688 AmqpMap(std::initializer_list<std::map<AmqpValue, AmqpValue>::value_type>
const& values)
689 : AmqpCollectionBase(values)
722 decltype(m_value)::mapped_type&
operator[](
decltype(m_value)::key_type&& keyVal)
724 return m_value.operator[](std::move(keyVal));
733 template <
class... ValueTypes>
734 std::pair<
decltype(m_value)::iterator,
bool>
emplace(ValueTypes&&... values)
736 return m_value.emplace(std::forward<ValueTypes>(values)...);
739 std::ostream& operator<<(std::ostream& os, AmqpMap
const& value);
744 class AmqpList final :
public _detail::AmqpCollectionBase<std::vector<AmqpValue>, AmqpList> {
746 AmqpList() : AmqpCollectionBase(){};
749 AmqpList(std::initializer_list<std::vector<AmqpValue>::value_type>
const& values)
750 : AmqpCollectionBase(values)
775 std::ostream& operator<<(std::ostream& os,
AmqpList const& value);
784 :
public _detail::AmqpCollectionBase<std::vector<std::uint8_t>, AmqpBinaryData> {
791 AmqpBinaryData(std::vector<std::uint8_t>
const& values) : AmqpCollectionBase(values){};
824 std::ostream& operator<<(std::ostream& os, AmqpBinaryData
const& value);
833 class AmqpSymbol final :
public _detail::AmqpCollectionBase<std::string, AmqpSymbol> {
839 AmqpSymbol(std::string
const& values) : AmqpCollectionBase(values){};
842 AmqpSymbol(initializer_type
const& initializer) : AmqpCollectionBase(initializer) {}
845 AmqpSymbol(
const char*
const values) : AmqpCollectionBase(values){};
882 bool operator==(
const decltype(m_value)::value_type*
const that)
const
884 return m_value == that;
887 std::ostream& operator<<(std::ostream& os, AmqpSymbol
const& value);
896 std::chrono::milliseconds m_value;
938 operator _detail::AmqpValueImpl()
const;
949 operator std::chrono::milliseconds()
const {
return m_value; }
972 :
public _detail::AmqpCollectionBase<std::vector<AmqpValue>, AmqpComposite> {
1020 return m_value == that.m_value;
1047 operator _detail::AmqpValueImpl()
const override;
1144 explicit operator AmqpValue const()
const;
1167 operator _detail::AmqpValueImpl()
const;
1183 return m_descriptor < that.m_descriptor ? true
1184 : m_descriptor == that.m_descriptor ? m_value < that.m_value
Represents an AMQP array.
Definition amqp_value.hpp:639
AmqpArray(AmqpArray &&other) noexcept=default
Move constructor.
AmqpArray(const AmqpArray &other)=default
Copy constructor.
AmqpArray & operator=(const AmqpArray &other)=default
Copy assignment operator.
AmqpArray()
Construct a new AmqpArray object.
Definition amqp_value.hpp:642
virtual ~AmqpArray()=default
Destroy an array.
AmqpArray & operator=(AmqpArray &&other) noexcept=default
Move assignment operator.
An AMQP binary value, a sequence of octets.
Definition amqp_value.hpp:784
AmqpBinaryData(initializer_type const &values)
Construct a new AmqpBinaryData object with an initializer list.
Definition amqp_value.hpp:789
AmqpBinaryData(const AmqpBinaryData &other)=default
Copy constructor.
AmqpBinaryData & operator=(const AmqpBinaryData &other)=default
Copy assignment operator.
AmqpBinaryData(std::vector< std::uint8_t > const &values)
Construct a new AmqpBinaryData from a vector of bytes.
Definition amqp_value.hpp:791
AmqpBinaryData(AmqpBinaryData &&other) noexcept=default
Move Constructor.
AmqpBinaryData & operator=(std::vector< std::uint8_t > const &values)
Assign a vector of bytes to the current AmqpBinaryData.
Definition amqp_value.hpp:806
AmqpBinaryData & operator=(AmqpBinaryData &&other) noexcept=default
Move assignment operator.
An AmqpComposite represents a sequentially ordered list of values. The values of the composite may ha...
Definition amqp_value.hpp:972
AmqpComposite(const AmqpComposite &other)=default
Construct a new AmqpComposite object from another.
AmqpComposite & operator=(const AmqpComposite &other)=default
Copy assignment operator.
bool operator==(AmqpComposite const &that) const
Compare this AmqpComposite value with another.
Definition amqp_value.hpp:1016
AmqpComposite & operator=(AmqpComposite &&other) noexcept=default
Move assignment operator.
AmqpValue const & GetDescriptor() const
Returns the descriptor for this composite type.
Definition amqp_value.hpp:1035
AmqpComposite(AmqpComposite &&other) noexcept=default
Move constructor.
bool operator!=(AmqpComposite const &that) const
Compare this AmqpComposite value with another.
Definition amqp_value.hpp:1029
AmqpComposite()
Construct a new AmqpComposite object.
Definition amqp_value.hpp:975
An AmqpDescribed represents an AMQP described type.
Definition amqp_value.hpp:1061
AmqpDescribed(AmqpDescribed &&other) noexcept=default
Construct a new AmqpDescribed object by moving the contents of another AmqpDescribed object.
AmqpDescribed & operator=(const AmqpDescribed &other)=default
Copy assignment operator for AmqpDescribed.
AmqpValue const & GetDescriptor() const
Returns the descriptor for this composite type.
Definition amqp_value.hpp:1150
bool operator!=(AmqpDescribed const &that) const
Compare this AmqpDescribed value with another.
Definition amqp_value.hpp:1140
bool operator==(AmqpDescribed const &that) const
Compare this AmqpDescribed value with another.
Definition amqp_value.hpp:1127
bool operator<(AmqpDescribed const &that) const
Compare this AmqpDescribed value with another.
Definition amqp_value.hpp:1181
AmqpDescribed & operator=(AmqpDescribed &&other) noexcept=default
Move assignment operator for AmqpDescribed.
AmqpValue const & GetValue() const
Returns the descriptor for this composite type.
Definition amqp_value.hpp:1156
AmqpDescribed(const AmqpDescribed &other)=default
Copy constructor for AmqpDescribed.
AmqpValue AsAmqpValue() const
Convert this AmqpDescribed to an AmqpValue.
Definition amqp_value.cpp:1103
An AMQP List is a sequence of polymorphic values. It has the behavioral characteristics of an AMQP ar...
Definition amqp_value.hpp:744
AmqpList(const AmqpList &other)=default
Copy Constructor.
AmqpList & operator=(const AmqpList &other)=default
Copy assignment operator.
AmqpList & operator=(AmqpList &&other) noexcept=default
Move assignment operator.
AmqpList(std::initializer_list< std::vector< AmqpValue >::value_type > const &values)
Construct a new AmqpList object with an initializer list.
Definition amqp_value.hpp:749
AmqpList(AmqpList &&other) noexcept=default
Move Constructor.
An AmqpMap represents an AMQP "map" type.
Definition amqp_value.hpp:681
AmqpMap & operator=(AmqpMap &&other) noexcept=default
Move assignment operator.
AmqpMap(AmqpMap &&other) noexcept=default
Move Constructor.
std::pair< decltype(m_value)::iterator, bool > emplace(ValueTypes &&... values)
Insert a new key/value pair into the map.
Definition amqp_value.hpp:734
AmqpMap(const AmqpMap &other)=default
Copy Constructor.
AmqpMap(std::initializer_list< std::map< AmqpValue, AmqpValue >::value_type > const &values)
Construct a new AmqpArray object with an initializer list.
Definition amqp_value.hpp:688
AmqpMap & operator=(const AmqpMap &other)=default
Copy assignment operator.
AmqpMap()
Construct a new AmqpMap object.
Definition amqp_value.hpp:685
An AMQP symbol value. An AMQP Symbol is a string valued from a constrained domain,...
Definition amqp_value.hpp:833
AmqpSymbol(initializer_type const &initializer)
Construct a new AmqpSymbol object with an initializer list.
Definition amqp_value.hpp:842
AmqpSymbol & operator=(const AmqpSymbol &other)=default
Copy Assignment operator.
AmqpSymbol(const char *const values)
Construct a new AmqpSymbol object from a constant string value.
Definition amqp_value.hpp:845
AmqpSymbol(AmqpSymbol &&other) noexcept=default
Move constructor.
bool operator==(const decltype(m_value)::value_type *const that) const
Compare two AMQP symbols for equality.
Definition amqp_value.hpp:882
AmqpSymbol(const AmqpSymbol &other)=default
Copy constructor.
bool operator==(AmqpSymbol const &that) const
Compare two AMQP symbols for equality.
Definition amqp_value.hpp:876
AmqpSymbol(std::string const &values)
Construct a new AmqpSymbol object with an initializer list.
Definition amqp_value.hpp:839
AmqpSymbol & operator=(AmqpSymbol &&other) noexcept=default
Move Assignment operator.
An AMQP timestamp value.
Definition amqp_value.hpp:895
AmqpTimestamp(const AmqpTimestamp &other)=default
Copy constructor.
AmqpTimestamp(AmqpTimestamp &&other) noexcept=default
Move constructor.
bool operator<(AmqpTimestamp const &that)
Compare this AMQP Timestamp with another.
Definition amqp_value.hpp:955
AmqpTimestamp & operator=(AmqpTimestamp &&other) noexcept=default
Move Assignment operator.
AmqpValue AsAmqpValue() const
Convert this AmqpTimestamp to an AmqpValue.
Definition amqp_value.cpp:965
AmqpTimestamp & operator=(const AmqpTimestamp &other)=default
Copy Assignment operator.
Definition amqp_value.hpp:104
AmqpSymbol AsSymbol() const
convert the current AMQP Value to an AmqpSymbol.
Definition amqp_value.cpp:602
AmqpValueType GetType() const
Returns the underlying type of the AMQP value.
Definition amqp_value.cpp:694
static AmqpValue Deserialize(uint8_t const *data, size_t size)
Deserialize an AMQP value from an array of bytes.
Definition amqp_value.cpp:712
bool operator!=(AmqpValue const &that) const
Equality comparison operator.
Definition amqp_value.hpp:319
operator std::uint8_t() const
convert the current AMQP Value to an unsigned 8 bit integer.
Definition amqp_value.cpp:357
AmqpTimestamp AsTimestamp() const
convert the current AMQP Value to an AmqpTimestamp.
Definition amqp_value.cpp:608
AmqpMap AsMap() const
convert the current AMQP Value to an AmqpMap.
Definition amqp_value.cpp:598
AmqpBinaryData AsBinary() const
convert the current AMQP Value to an AmqpBinaryData.
Definition amqp_value.cpp:606
static std::vector< uint8_t > Serialize(AmqpValue const &value)
Serialize this AMQP value as an array of bytes.
Definition amqp_value.cpp:717
AmqpList AsList() const
convert the current AMQP Value to an AmqpList.
Definition amqp_value.cpp:605
AmqpDescribed AsDescribed() const
convert the current AMQP Value to an AMQP Described value.
Definition amqp_value.cpp:607
bool IsNull() const
Returns 'true' if the AMQP value is "null".
Definition amqp_value.cpp:1212
AmqpArray AsArray() const
convert the current AMQP Value to an AmqpArray.
Definition amqp_value.cpp:600
AmqpValue & operator=(AmqpValue const &that)
Copy an AMQP value to the current AMQP value.
Definition amqp_value.cpp:336
static size_t GetSerializedSize(AmqpValue const &value)
Returns the size (in bytes) of the serialized form of this value.
Definition amqp_value.cpp:721
AmqpComposite AsComposite() const
convert the current AMQP Value to an AMQP Composite value.
Definition amqp_value.cpp:604
bool operator<(AmqpValue const &that) const
Less Than comparison operator.
Definition amqp_value.cpp:536
AmqpValue() noexcept
Construct an AMQP null (empty) value.
Definition amqp_value.cpp:318
bool operator==(AmqpValue const &that) const
Equality comparison operator.
Definition amqp_value.cpp:499