mirror of
https://github.com/corda/corda.git
synced 2024-12-18 20:47:57 +00:00
NOTICK - Break up the Property Reader Class into multiple files
As having them all live in a single PropertyReader header / source file was getting far too big. Additionally, sue some of our aliased types to shorted lines (sVec, sList, uPtr etc)
This commit is contained in:
parent
eb8eaba1d7
commit
19adbffffb
@ -3,6 +3,8 @@
|
||||
/******************************************************************************/
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
/******************************************************************************/
|
||||
@ -13,6 +15,11 @@ using uPtr = std::unique_ptr<T>;
|
||||
template<typename T>
|
||||
using sPtr = std::shared_ptr<T>;
|
||||
|
||||
template<typename T>
|
||||
using sVec = std::vector<T>;
|
||||
|
||||
template<typename T>
|
||||
using sList = std::list<T>;
|
||||
|
||||
template<typename T>
|
||||
using upStrMap_t = std::map<std::string, uPtr<T>>;
|
||||
|
@ -4,21 +4,27 @@ include_directories (reader)
|
||||
include_directories (.)
|
||||
|
||||
set (amqp_sources
|
||||
descriptors/AMQPDescriptors.cxx
|
||||
descriptors/AMQPDescriptorRegistory.cxx
|
||||
schema/Schema.cxx
|
||||
schema/Field.cxx
|
||||
schema/Envelope.cxx
|
||||
schema/Composite.cxx
|
||||
schema/Descriptor.cxx
|
||||
schema/restricted-types/Restricted.cxx
|
||||
schema/restricted-types/List.cxx
|
||||
schema/AMQPTypeNotation.cxx
|
||||
CompositeFactory.cxx
|
||||
descriptors/AMQPDescriptors.cxx
|
||||
descriptors/AMQPDescriptorRegistory.cxx
|
||||
schema/Schema.cxx
|
||||
schema/Field.cxx
|
||||
schema/Envelope.cxx
|
||||
schema/Composite.cxx
|
||||
schema/Descriptor.cxx
|
||||
schema/restricted-types/Restricted.cxx
|
||||
schema/restricted-types/List.cxx
|
||||
schema/AMQPTypeNotation.cxx
|
||||
reader/Reader.cxx
|
||||
reader/PropertyReader.cxx
|
||||
reader/RestrictedReader.cxx
|
||||
reader/CompositeReader.cxx
|
||||
CompositeFactory.cxx
|
||||
reader/PropertyReader.cxx
|
||||
reader/property-readers/StringPropertyReader.cxx
|
||||
reader/property-readers/IntPropertyReader.cxx
|
||||
reader/property-readers/DoublePropertyReader.cxx
|
||||
reader/property-readers/LongPropertyReader.cxx
|
||||
reader/property-readers/BoolPropertyReader.cxx
|
||||
reader/restricted-readers/ListReader.cxx
|
||||
)
|
||||
|
||||
ADD_LIBRARY ( amqp ${amqp_sources} )
|
||||
|
@ -12,9 +12,10 @@
|
||||
|
||||
#include "amqp/reader/IReader.h"
|
||||
#include "reader/Reader.h"
|
||||
#include "reader/PropertyReader.h"
|
||||
#include "amqp/reader/PropertyReader.h"
|
||||
#include "reader/CompositeReader.h"
|
||||
#include "reader/RestrictedReader.h"
|
||||
#include "reader/restricted-readers/ListReader.h"
|
||||
|
||||
#include "schema/restricted-types/List.h"
|
||||
|
||||
|
@ -11,41 +11,42 @@
|
||||
#include "amqp/schema/Schema.h"
|
||||
#include "amqp/schema/Envelope.h"
|
||||
#include "amqp/schema/Composite.h"
|
||||
#include "amqp/reader/PropertyReader.h"
|
||||
#include "amqp/reader/CompositeReader.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
namespace amqp::internal {
|
||||
|
||||
class CompositeFactory : public ICompositeFactory<schema::SchemaMap::const_iterator> {
|
||||
private :
|
||||
using CompositePtr = uPtr<amqp::internal::schema::Composite>;
|
||||
using EnvelopePtr = uPtr<amqp::internal::schema::Envelope>;
|
||||
class CompositeFactory
|
||||
: public ICompositeFactory<schema::SchemaMap::const_iterator>
|
||||
{
|
||||
private :
|
||||
using CompositePtr = uPtr<schema::Composite>;
|
||||
using EnvelopePtr = uPtr<schema::Envelope>;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
spStrMap_t<reader::Reader> m_readersByType;
|
||||
spStrMap_t<reader::Reader> m_readersByDescriptor;
|
||||
spStrMap_t<reader::Reader> m_readersByType;
|
||||
spStrMap_t<reader::Reader> m_readersByDescriptor;
|
||||
|
||||
public :
|
||||
CompositeFactory() = default;
|
||||
public :
|
||||
CompositeFactory() = default;
|
||||
|
||||
void process(const SchemaType &) override;
|
||||
void process (const SchemaType &) override;
|
||||
|
||||
const std::shared_ptr<ReaderType> byType(const std::string &) override;
|
||||
const std::shared_ptr<ReaderType> byType (
|
||||
const std::string &) override;
|
||||
|
||||
const std::shared_ptr<ReaderType> byDescriptor(const std::string &) override;
|
||||
const std::shared_ptr<ReaderType> byDescriptor (
|
||||
const std::string &) override;
|
||||
|
||||
private :
|
||||
std::shared_ptr<reader::Reader> process(const amqp::internal::schema::AMQPTypeNotation &);
|
||||
private :
|
||||
std::shared_ptr<reader::Reader> process (
|
||||
const schema::AMQPTypeNotation &);
|
||||
|
||||
std::shared_ptr<reader::Reader>
|
||||
processComposite(const amqp::internal::schema::AMQPTypeNotation &);
|
||||
std::shared_ptr<reader::Reader> processComposite (
|
||||
const schema::AMQPTypeNotation &);
|
||||
|
||||
std::shared_ptr<reader::Reader>
|
||||
processRestricted(const amqp::internal::schema::AMQPTypeNotation &);
|
||||
std::shared_ptr<reader::Reader> processRestricted (
|
||||
const schema::AMQPTypeNotation &);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -6,19 +6,16 @@
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
namespace amqp {
|
||||
namespace internal {
|
||||
namespace amqp::internal {
|
||||
|
||||
|
||||
const uint64_t DESCRIPTOR_TOP_32BITS = 0xc562L << (32 + 16);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
namespace amqp {
|
||||
namespace internal {
|
||||
namespace amqp::internal {
|
||||
|
||||
const int ENVELOPE = 1;
|
||||
const int SCHEMA = 2;
|
||||
@ -33,7 +30,6 @@ namespace internal {
|
||||
const int TRANSFORM_ELEMENT_KEY = 11;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
@ -134,7 +130,7 @@ amqp::stripCorda (uint64_t id) {
|
||||
/******************************************************************************/
|
||||
|
||||
std::string
|
||||
amqp::describedToString(uint64_t val_) {
|
||||
amqp::describedToString (uint64_t val_) {
|
||||
switch (val_) {
|
||||
case (1L | internal::DESCRIPTOR_TOP_32BITS) : return "ENVELOPE";
|
||||
case (2L | internal::DESCRIPTOR_TOP_32BITS) : return "SCHEMA";
|
||||
@ -154,7 +150,7 @@ amqp::describedToString(uint64_t val_) {
|
||||
/******************************************************************************/
|
||||
|
||||
std::string
|
||||
amqp::describedToString(uint32_t val_) {
|
||||
amqp::describedToString (uint32_t val_) {
|
||||
return describedToString(val_ | internal::DESCRIPTOR_TOP_32BITS);
|
||||
}
|
||||
|
||||
|
@ -28,13 +28,13 @@
|
||||
namespace {
|
||||
|
||||
/**
|
||||
* Look up a described type by its ID in the AMQPDescriptorRegistory and
|
||||
* return the coresponding schema type. Specialised below to avoid
|
||||
* Look up a described type by its ID in the AMQPDescriptorRegistry and
|
||||
* return the corresponding schema type. Specialised below to avoid
|
||||
* the cast and re-owning of the unigue pointer when we're happy
|
||||
* with a simple std::unique_ptr<AMQPDescribed>
|
||||
* with a simple uPtr<AMQPDescribed>
|
||||
*/
|
||||
template<class T>
|
||||
std::unique_ptr<T>
|
||||
uPtr<T>
|
||||
dispatchDescribed (pn_data_t * data_) {
|
||||
proton::is_described(data_);
|
||||
proton::auto_enter p (data_);
|
||||
@ -42,7 +42,7 @@ namespace {
|
||||
|
||||
auto id = pn_data_get_ulong(data_);
|
||||
|
||||
return std::unique_ptr<T> (
|
||||
return uPtr<T> (
|
||||
static_cast<T *>(amqp::AMQPDescriptorRegistory[id]->build(data_).release()));
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ namespace {
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::AMQPDescribed>
|
||||
uPtr<amqp::AMQPDescribed>
|
||||
amqp::internal::
|
||||
EnvelopeDescriptor::build(pn_data_t * data_) const {
|
||||
DBG ("ENVELOPE" << std::endl); // NOLINT
|
||||
@ -120,7 +120,7 @@ EnvelopeDescriptor::build(pn_data_t * data_) const {
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::AMQPDescribed>
|
||||
uPtr<amqp::AMQPDescribed>
|
||||
amqp::internal::
|
||||
SchemaDescriptor::build(pn_data_t * data_) const {
|
||||
DBG ("SCHEMA" << std::endl); // NOLINT
|
||||
@ -156,7 +156,7 @@ SchemaDescriptor::build(pn_data_t * data_) const {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
std::unique_ptr<amqp::AMQPDescribed>
|
||||
uPtr<amqp::AMQPDescribed>
|
||||
amqp::internal::
|
||||
ObjectDescriptor::build(pn_data_t * data_) const {
|
||||
DBG ("DESCRIPTOR" << std::endl); // NOLINT
|
||||
@ -176,7 +176,7 @@ ObjectDescriptor::build(pn_data_t * data_) const {
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::AMQPDescribed>
|
||||
uPtr<amqp::AMQPDescribed>
|
||||
amqp::internal::
|
||||
FieldDescriptor::build(pn_data_t * data_) const {
|
||||
DBG ("FIELD" << std::endl); // NOLINT
|
||||
@ -186,12 +186,12 @@ FieldDescriptor::build(pn_data_t * data_) const {
|
||||
proton::auto_enter ae (data_);
|
||||
|
||||
/* name: String */
|
||||
auto name = proton::get_string(data_);
|
||||
auto name = proton::get_string (data_);
|
||||
|
||||
pn_data_next(data_);
|
||||
|
||||
/* type: String */
|
||||
auto type = proton::get_string(data_);
|
||||
auto type = proton::get_string (data_);
|
||||
|
||||
pn_data_next(data_);
|
||||
|
||||
@ -207,18 +207,18 @@ FieldDescriptor::build(pn_data_t * data_) const {
|
||||
pn_data_next(data_);
|
||||
|
||||
/* default: String? */
|
||||
auto def = proton::get_string(data_, true);
|
||||
auto def = proton::get_string (data_, true);
|
||||
|
||||
pn_data_next(data_);
|
||||
|
||||
/* label: String? */
|
||||
auto label = proton::get_string(data_, true);
|
||||
auto label = proton::get_string (data_, true);
|
||||
|
||||
pn_data_next(data_);
|
||||
|
||||
/* mandatory: Boolean - copes with the Kotlin concept of nullability.
|
||||
If something is mandatory then it cannot be null */
|
||||
auto mandatory = proton::get_boolean(data_);
|
||||
auto mandatory = proton::get_boolean (data_);
|
||||
|
||||
pn_data_next(data_);
|
||||
|
||||
@ -235,9 +235,9 @@ FieldDescriptor::build(pn_data_t * data_) const {
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::AMQPDescribed>
|
||||
uPtr<amqp::AMQPDescribed>
|
||||
amqp::internal::
|
||||
CompositeDescriptor::build(pn_data_t * data_) const {
|
||||
CompositeDescriptor::build (pn_data_t * data_) const {
|
||||
DBG ("COMPOSITE" << std::endl); // NOLINT
|
||||
|
||||
validateAndNext(data_);
|
||||
@ -250,7 +250,7 @@ CompositeDescriptor::build(pn_data_t * data_) const {
|
||||
pn_data_next(data_);
|
||||
|
||||
/* Label Name - Nullable String */
|
||||
auto label = proton::get_string(data_, true);
|
||||
auto label = proton::get_string (data_, true);
|
||||
|
||||
pn_data_next(data_);
|
||||
|
||||
@ -271,11 +271,11 @@ CompositeDescriptor::build(pn_data_t * data_) const {
|
||||
pn_data_next(data_);
|
||||
|
||||
/* fields: List<Described>*/
|
||||
std::vector<std::unique_ptr<schema::Field>> fields;
|
||||
std::vector<uPtr<schema::Field>> fields;
|
||||
fields.reserve (pn_data_get_list (data_));
|
||||
{
|
||||
proton::auto_list_enter p2 (data_);
|
||||
while (pn_data_next(data_)) {
|
||||
while (pn_data_next (data_)) {
|
||||
fields.emplace_back (dispatchDescribed<schema::Field>(data_));
|
||||
}
|
||||
}
|
||||
@ -301,9 +301,9 @@ CompositeDescriptor::build(pn_data_t * data_) const {
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::AMQPDescribed>
|
||||
uPtr<amqp::AMQPDescribed>
|
||||
amqp::internal::
|
||||
RestrictedDescriptor::build(pn_data_t * data_) const {
|
||||
RestrictedDescriptor::build (pn_data_t * data_) const {
|
||||
DBG ("RESTRICTED" << std::endl); // NOLINT
|
||||
validateAndNext(data_);
|
||||
|
||||
@ -322,8 +322,8 @@ RestrictedDescriptor::build(pn_data_t * data_) const {
|
||||
|
||||
pn_data_next (data_);
|
||||
|
||||
auto source = proton::readAndNext<std::string>(data_);
|
||||
auto descriptor = dispatchDescribed<schema::Descriptor>(data_);
|
||||
auto source = proton::readAndNext<std::string> (data_);
|
||||
auto descriptor = dispatchDescribed<schema::Descriptor> (data_);
|
||||
|
||||
// SKIP the choices section **FOR NOW**
|
||||
|
||||
@ -337,62 +337,62 @@ RestrictedDescriptor::build(pn_data_t * data_) const {
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::AMQPDescribed>
|
||||
uPtr<amqp::AMQPDescribed>
|
||||
amqp::internal::
|
||||
ChoiceDescriptor::build(pn_data_t * data_) const {
|
||||
ChoiceDescriptor::build (pn_data_t * data_) const {
|
||||
validateAndNext(data_);
|
||||
|
||||
DBG ("CHOICE " << data_ << std::endl); // NOLINT
|
||||
|
||||
return std::unique_ptr<amqp::AMQPDescribed> (nullptr);
|
||||
return uPtr<amqp::AMQPDescribed> (nullptr);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::AMQPDescribed>
|
||||
uPtr<amqp::AMQPDescribed>
|
||||
amqp::internal::
|
||||
ReferencedObjectDescriptor::build(pn_data_t * data_) const {
|
||||
validateAndNext(data_);
|
||||
ReferencedObjectDescriptor::build (pn_data_t * data_) const {
|
||||
validateAndNext (data_);
|
||||
|
||||
DBG ("REFERENCED OBJECT " << data_ << std::endl); // NOLINT
|
||||
|
||||
return std::unique_ptr<amqp::AMQPDescribed> (nullptr);
|
||||
return uPtr<amqp::AMQPDescribed> (nullptr);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::AMQPDescribed>
|
||||
uPtr<amqp::AMQPDescribed>
|
||||
amqp::internal::
|
||||
TransformSchemaDescriptor::build(pn_data_t * data_) const {
|
||||
validateAndNext(data_);
|
||||
TransformSchemaDescriptor::build (pn_data_t * data_) const {
|
||||
validateAndNext (data_);
|
||||
|
||||
DBG ("TRANSFORM SCHEMA " << data_ << std::endl); // NOLINT
|
||||
|
||||
return std::unique_ptr<amqp::AMQPDescribed> (nullptr);
|
||||
return uPtr<amqp::AMQPDescribed> (nullptr);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::AMQPDescribed>
|
||||
uPtr<amqp::AMQPDescribed>
|
||||
amqp::internal::
|
||||
TransformElementDescriptor::build(pn_data_t * data_) const {
|
||||
validateAndNext(data_);
|
||||
TransformElementDescriptor::build (pn_data_t * data_) const {
|
||||
validateAndNext (data_);
|
||||
|
||||
DBG ("TRANSFORM ELEMENT " << data_ << std::endl); // NOLINT
|
||||
|
||||
return std::unique_ptr<amqp::AMQPDescribed> (nullptr);
|
||||
return uPtr<amqp::AMQPDescribed> (nullptr);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::AMQPDescribed>
|
||||
uPtr<amqp::AMQPDescribed>
|
||||
amqp::internal::
|
||||
TransformElementKeyDescriptor::build(pn_data_t * data_) const {
|
||||
validateAndNext(data_);
|
||||
TransformElementKeyDescriptor::build (pn_data_t * data_) const {
|
||||
validateAndNext (data_);
|
||||
|
||||
DBG ("TRANSFORM ELEMENT KEY" << data_ << std::endl); // NOLINT
|
||||
|
||||
return std::unique_ptr<amqp::AMQPDescribed> (nullptr);
|
||||
return uPtr<amqp::AMQPDescribed> (nullptr);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -27,7 +27,7 @@ CompositeReader::m_name { // NOLINT
|
||||
amqp::internal::reader::
|
||||
CompositeReader::CompositeReader (
|
||||
std::string type_,
|
||||
std::vector<std::weak_ptr<Reader>> & readers_
|
||||
sVec<std::weak_ptr<Reader>> & readers_
|
||||
) : m_readers (readers_)
|
||||
, m_type (std::move (type_))
|
||||
{
|
||||
@ -78,7 +78,7 @@ CompositeReader::readString (pn_data_t * data_) const {
|
||||
/******************************************************************************/
|
||||
|
||||
|
||||
std::vector<std::unique_ptr<amqp::reader::IValue>>
|
||||
sVec<uPtr<amqp::reader::IValue>>
|
||||
amqp::internal::reader::
|
||||
CompositeReader::_dump (
|
||||
pn_data_t * data_,
|
||||
@ -88,14 +88,14 @@ CompositeReader::_dump (
|
||||
proton::is_described (data_);
|
||||
proton::auto_enter ae (data_);
|
||||
|
||||
const auto & it = schema_.fromDescriptor(proton::get_symbol<std::string>(data_));
|
||||
auto & fields = dynamic_cast<amqp::internal::schema::Composite &>(*(it->second.get())).fields();
|
||||
const auto & it = schema_.fromDescriptor (proton::get_symbol<std::string>(data_));
|
||||
auto & fields = dynamic_cast<schema::Composite &>(*(it->second.get())).fields();
|
||||
|
||||
assert (fields.size() == m_readers.size());
|
||||
|
||||
pn_data_next (data_);
|
||||
|
||||
std::vector<std::unique_ptr<amqp::reader::IValue>> read;
|
||||
sVec<uPtr<amqp::reader::IValue>> read;
|
||||
read.reserve (fields.size());
|
||||
|
||||
proton::is_list (data_);
|
||||
@ -120,14 +120,14 @@ CompositeReader::_dump (
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue>
|
||||
uPtr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
CompositeReader::dump (
|
||||
const std::string & name_,
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_) const
|
||||
{
|
||||
return std::make_unique<TypedPair<std::vector<std::unique_ptr<amqp::reader::IValue>>>> (
|
||||
return std::make_unique<TypedPair<sVec<uPtr<amqp::reader::IValue>>>> (
|
||||
name_,
|
||||
_dump(data_, schema_));
|
||||
}
|
||||
@ -137,13 +137,13 @@ CompositeReader::dump (
|
||||
/**
|
||||
*
|
||||
*/
|
||||
std::unique_ptr<amqp::reader::IValue>
|
||||
uPtr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
CompositeReader::dump (
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_) const
|
||||
{
|
||||
return std::make_unique<TypedSingle<std::vector<std::unique_ptr<amqp::reader::IValue>>>> (
|
||||
return std::make_unique<TypedSingle<sVec<uPtr<amqp::reader::IValue>>>> (
|
||||
_dump (data_, schema_));
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,11 @@
|
||||
#include "PropertyReader.h"
|
||||
|
||||
#include "amqp/reader/property-readers/IntPropertyReader.h"
|
||||
#include "amqp/reader/property-readers/BoolPropertyReader.h"
|
||||
#include "amqp/reader/property-readers/LongPropertyReader.h"
|
||||
#include "amqp/reader/property-readers/StringPropertyReader.h"
|
||||
#include "amqp/reader/property-readers/DoublePropertyReader.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
@ -52,68 +58,6 @@ namespace {
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
const std::string
|
||||
amqp::internal::reader::
|
||||
StringPropertyReader::m_name { // NOLINT
|
||||
"String Reader"
|
||||
};
|
||||
|
||||
const std::string
|
||||
amqp::internal::reader::
|
||||
StringPropertyReader::m_type { // NOLINT
|
||||
"string"
|
||||
};
|
||||
|
||||
const std::string
|
||||
amqp::internal::reader::
|
||||
IntPropertyReader::m_name { // NOLINT
|
||||
"Int Reader"
|
||||
};
|
||||
|
||||
const std::string
|
||||
amqp::internal::reader::
|
||||
IntPropertyReader::m_type { // NOLINT
|
||||
"int"
|
||||
};
|
||||
|
||||
const std::string
|
||||
amqp::internal::reader::
|
||||
BoolPropertyReader::m_name { // NOLINT
|
||||
"Bool Reader"
|
||||
};
|
||||
|
||||
const std::string
|
||||
amqp::internal::reader::
|
||||
BoolPropertyReader::m_type { // NOLINT
|
||||
"bool"
|
||||
};
|
||||
|
||||
const std::string
|
||||
amqp::internal::reader::
|
||||
LongPropertyReader::m_name { // NOLINT
|
||||
"Long Reader"
|
||||
};
|
||||
|
||||
const std::string
|
||||
amqp::internal::reader::
|
||||
LongPropertyReader::m_type { // NOLINT
|
||||
"long"
|
||||
};
|
||||
|
||||
const std::string
|
||||
amqp::internal::reader::
|
||||
DoublePropertyReader::m_name { // NOLINT
|
||||
"Double Reader"
|
||||
};
|
||||
|
||||
const std::string
|
||||
amqp::internal::reader::
|
||||
DoublePropertyReader::m_type { // NOLINT
|
||||
"double"
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* Static factory method
|
||||
*/
|
||||
@ -131,235 +75,6 @@ PropertyReader::make (const std::string & type_) {
|
||||
return propertyMap[type_]();
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* StringPropertyReader
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
std::any
|
||||
amqp::internal::reader::
|
||||
StringPropertyReader::read (pn_data_t * data_) const {
|
||||
return std::any ("hello");
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
StringPropertyReader::readString (pn_data_t * data_) const {
|
||||
return proton::readAndNext<std::string> (data_);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
StringPropertyReader::dump (
|
||||
const std::string & name_,
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_) const
|
||||
{
|
||||
return std::make_unique<TypedPair<std::string>> (
|
||||
name_,
|
||||
"\"" + proton::readAndNext<std::string> (data_) + "\"");
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
StringPropertyReader::dump (
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_) const
|
||||
{
|
||||
return std::make_unique<TypedSingle<std::string>> (
|
||||
"\"" + proton::readAndNext<std::string> (data_) + "\"");
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* IntPropertyReader
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
std::any
|
||||
amqp::internal::reader::
|
||||
IntPropertyReader::read (pn_data_t * data_) const {
|
||||
return std::any (1);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
IntPropertyReader::readString (pn_data_t * data_) const {
|
||||
return std::to_string (proton::readAndNext<int> (data_));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
IntPropertyReader::dump (
|
||||
const std::string & name_,
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_) const
|
||||
{
|
||||
return std::make_unique<TypedPair<std::string>> (
|
||||
name_,
|
||||
std::to_string (proton::readAndNext<int> (data_)));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
IntPropertyReader::dump (
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_) const
|
||||
{
|
||||
return std::make_unique<TypedSingle<std::string>> (
|
||||
std::to_string (proton::readAndNext<int> (data_)));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* BoolPropertyReader
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
std::any
|
||||
amqp::internal::reader::
|
||||
BoolPropertyReader::read (pn_data_t * data_) const {
|
||||
return std::any (true);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
BoolPropertyReader::readString (pn_data_t * data_) const {
|
||||
return std::to_string (proton::readAndNext<bool> (data_));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
BoolPropertyReader::dump (
|
||||
const std::string & name_,
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_) const
|
||||
{
|
||||
return std::make_unique<TypedPair<std::string>> (
|
||||
name_,
|
||||
std::to_string (proton::readAndNext<bool> (data_)));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
BoolPropertyReader::dump (
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_) const
|
||||
{
|
||||
return std::make_unique<TypedSingle<std::string>> (
|
||||
std::to_string (proton::readAndNext<bool> (data_)));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* LongPropertyReader
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
std::any
|
||||
amqp::internal::reader::
|
||||
LongPropertyReader::read (pn_data_t * data_) const {
|
||||
return std::any (10L);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
LongPropertyReader::readString (pn_data_t * data_) const {
|
||||
return std::to_string (proton::readAndNext<long> (data_));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
LongPropertyReader::dump (
|
||||
const std::string & name_,
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_) const
|
||||
{
|
||||
return std::make_unique<TypedPair<std::string>> (
|
||||
name_,
|
||||
std::to_string (proton::readAndNext<long> (data_)));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
LongPropertyReader::dump (
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_) const
|
||||
{
|
||||
return std::make_unique<TypedSingle<std::string>> (
|
||||
std::to_string (proton::readAndNext<long> (data_)));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* DoublePropertyReader
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
std::any
|
||||
amqp::internal::reader::
|
||||
DoublePropertyReader::read (pn_data_t * data_) const {
|
||||
return std::any (10.0);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
DoublePropertyReader::readString (pn_data_t * data_) const {
|
||||
return std::to_string (proton::readAndNext<double> (data_));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
DoublePropertyReader::dump (
|
||||
const std::string & name_,
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_) const
|
||||
{
|
||||
return std::make_unique<TypedPair<std::string>> (
|
||||
name_,
|
||||
std::to_string (proton::readAndNext<double> (data_)));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
DoublePropertyReader::dump (
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_) const
|
||||
{
|
||||
return std::make_unique<TypedSingle<std::string>> (
|
||||
std::to_string (proton::readAndNext<double> (data_)));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#include <iostream>
|
||||
#include "Reader.h"
|
||||
|
||||
#include "amqp/schema/Field.h"
|
||||
@ -13,7 +12,7 @@ namespace amqp::internal::reader {
|
||||
|
||||
class PropertyReader : public Reader {
|
||||
private :
|
||||
using FieldPtr = std::unique_ptr<internal::schema::Field>;
|
||||
using FieldPtr = uPtr<internal::schema::Field>;
|
||||
|
||||
public :
|
||||
/**
|
||||
@ -41,163 +40,9 @@ namespace amqp::internal::reader {
|
||||
) const override = 0;
|
||||
|
||||
const std::string & name() const override = 0;
|
||||
|
||||
const std::string & type() const override = 0;
|
||||
};
|
||||
|
||||
|
||||
class StringPropertyReader : public PropertyReader {
|
||||
private :
|
||||
static const std::string m_name;
|
||||
static const std::string m_type;
|
||||
|
||||
public :
|
||||
std::string readString (pn_data_t *) const override;
|
||||
|
||||
std::any read (pn_data_t *) const override;
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue> dump(
|
||||
const std::string &,
|
||||
pn_data_t *,
|
||||
const SchemaType &
|
||||
) const override;
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue> dump(
|
||||
pn_data_t *,
|
||||
const SchemaType &
|
||||
) const override;
|
||||
|
||||
const std::string & name() const override {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
const std::string & type() const override {
|
||||
return m_type;
|
||||
}
|
||||
};
|
||||
|
||||
class IntPropertyReader : public PropertyReader {
|
||||
private :
|
||||
static const std::string m_name;
|
||||
static const std::string m_type;
|
||||
|
||||
public :
|
||||
~IntPropertyReader() override = default;
|
||||
|
||||
std::string readString (pn_data_t *) const override;
|
||||
|
||||
std::any read (pn_data_t *) const override;
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue> dump(
|
||||
const std::string &,
|
||||
pn_data_t *,
|
||||
const SchemaType &
|
||||
) const override;
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue> dump(
|
||||
pn_data_t *,
|
||||
const SchemaType &
|
||||
) const override;
|
||||
|
||||
const std::string & name() const override {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
const std::string & type() const override {
|
||||
return m_type;
|
||||
}
|
||||
};
|
||||
|
||||
class BoolPropertyReader : public PropertyReader {
|
||||
private :
|
||||
static const std::string m_name;
|
||||
static const std::string m_type;
|
||||
|
||||
public :
|
||||
std::string readString (pn_data_t *) const override;
|
||||
|
||||
std::any read (pn_data_t *) const override;
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue> dump(
|
||||
const std::string &,
|
||||
pn_data_t *,
|
||||
const SchemaType &
|
||||
) const override;
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue> dump(
|
||||
pn_data_t *,
|
||||
const SchemaType &
|
||||
) const override;
|
||||
|
||||
const std::string & name() const override {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
const std::string & type() const override {
|
||||
return m_type;
|
||||
}
|
||||
};
|
||||
|
||||
class LongPropertyReader : public PropertyReader {
|
||||
private :
|
||||
static const std::string m_name;
|
||||
static const std::string m_type;
|
||||
|
||||
public :
|
||||
std::string readString (pn_data_t *) const override;
|
||||
|
||||
std::any read (pn_data_t *) const override;
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue> dump(
|
||||
const std::string &,
|
||||
pn_data_t *,
|
||||
const SchemaType &
|
||||
) const override;
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue> dump(
|
||||
pn_data_t *,
|
||||
const SchemaType &
|
||||
) const override;
|
||||
|
||||
const std::string & name() const override {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
const std::string & type() const override {
|
||||
return m_type;
|
||||
}
|
||||
};
|
||||
|
||||
class DoublePropertyReader : public PropertyReader {
|
||||
private :
|
||||
static const std::string m_name;
|
||||
static const std::string m_type;
|
||||
|
||||
public :
|
||||
std::string readString (pn_data_t *) const override;
|
||||
|
||||
std::any read (pn_data_t *) const override;
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue> dump(
|
||||
const std::string &,
|
||||
pn_data_t *,
|
||||
const SchemaType &
|
||||
) const override;
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue> dump(
|
||||
pn_data_t *,
|
||||
const SchemaType &
|
||||
) const override;
|
||||
|
||||
const std::string & name() const override {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
const std::string & type() const override {
|
||||
return m_type;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -51,7 +51,7 @@ namespace {
|
||||
|
||||
template<class Auto, class T>
|
||||
std::string
|
||||
dumpPair(const std::string & name_, const T & begin_, const T & end_) {
|
||||
dumpPair (const std::string & name_, const T & begin_, const T & end_) {
|
||||
std::stringstream rtn;
|
||||
{
|
||||
Auto am (name_, rtn);
|
||||
@ -67,7 +67,7 @@ namespace {
|
||||
|
||||
template<class Auto, class T>
|
||||
std::string
|
||||
dumpSingle(const T & begin_, const T & end_) {
|
||||
dumpSingle (const T & begin_, const T & end_) {
|
||||
std::stringstream rtn;
|
||||
{
|
||||
Auto am (rtn);
|
||||
@ -92,28 +92,28 @@ namespace {
|
||||
template<>
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
TypedPair<std::vector<std::unique_ptr<amqp::internal::reader::Pair>>>::dump() const {
|
||||
TypedPair<sVec<uPtr<amqp::internal::reader::Pair>>>::dump() const {
|
||||
return ::dumpPair<AutoMap> (m_property, m_value.begin(), m_value.end());
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
TypedPair<std::list<std::unique_ptr<amqp::internal::reader::Pair>>>::dump() const {
|
||||
TypedPair<sList<uPtr<amqp::internal::reader::Pair>>>::dump() const {
|
||||
return ::dumpPair<AutoMap> (m_property, m_value.begin(), m_value.end());
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
TypedPair<std::vector<std::unique_ptr<amqp::reader::IValue>>>::dump() const {
|
||||
TypedPair<sVec<uPtr<amqp::reader::IValue>>>::dump() const {
|
||||
return ::dumpPair<AutoMap> (m_property, m_value.begin(), m_value.end());
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
TypedPair<std::list<std::unique_ptr<amqp::reader::IValue>>>::dump() const {
|
||||
TypedPair<sList<uPtr<amqp::reader::IValue>>>::dump() const {
|
||||
return ::dumpPair<AutoList> (m_property, m_value.begin(), m_value.end());
|
||||
}
|
||||
|
||||
@ -126,28 +126,28 @@ TypedPair<std::list<std::unique_ptr<amqp::reader::IValue>>>::dump() const {
|
||||
template<>
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
TypedSingle<std::list<std::unique_ptr<amqp::reader::IValue>>>::dump() const {
|
||||
TypedSingle<sList<uPtr<amqp::reader::IValue>>>::dump() const {
|
||||
return ::dumpSingle<AutoList> (m_value.begin(), m_value.end());
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
TypedSingle<std::vector<std::unique_ptr<amqp::reader::IValue>>>::dump() const {
|
||||
TypedSingle<sVec<uPtr<amqp::reader::IValue>>>::dump() const {
|
||||
return ::dumpSingle<AutoMap> (m_value.begin(), m_value.end());
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
TypedSingle<std::list<std::unique_ptr<amqp::internal::reader::Single>>>::dump() const {
|
||||
TypedSingle<sList<uPtr<amqp::internal::reader::Single>>>::dump() const {
|
||||
return ::dumpSingle<AutoList> (m_value.begin(), m_value.end());
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
TypedSingle<std::vector<std::unique_ptr<amqp::internal::reader::Single>>>::dump() const {
|
||||
TypedSingle<sVec<uPtr<amqp::internal::reader::Single>>>::dump() const {
|
||||
return ::dumpSingle<AutoMap> (m_value.begin(), m_value.end());
|
||||
}
|
||||
|
||||
|
@ -41,11 +41,11 @@ namespace amqp::internal::reader {
|
||||
{ }
|
||||
|
||||
explicit TypedSingle (T && value_)
|
||||
: Single()
|
||||
, m_value { std::move (value_) }
|
||||
: Single()
|
||||
, m_value { std::move (value_) }
|
||||
{ }
|
||||
|
||||
explicit TypedSingle (const TypedSingle && value_) noexcept
|
||||
TypedSingle (const TypedSingle && value_) noexcept
|
||||
: Single()
|
||||
, m_value { std::move (value_.m_value) }
|
||||
{ }
|
||||
@ -73,7 +73,6 @@ namespace amqp::internal::reader {
|
||||
{ }
|
||||
|
||||
std::string dump() const override = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -93,7 +92,7 @@ namespace amqp::internal::reader {
|
||||
, m_value (std::move (value_))
|
||||
{ }
|
||||
|
||||
explicit TypedPair (TypedPair && pair_) noexcept
|
||||
TypedPair (TypedPair && pair_) noexcept
|
||||
: Pair (std::move (pair_.m_property))
|
||||
, m_value (std::move (pair_.m_value))
|
||||
{ }
|
||||
@ -130,26 +129,26 @@ TypedSingle<std::string>::dump() const {
|
||||
template<>
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
TypedSingle<std::vector<std::unique_ptr<amqp::reader::IValue>>>::dump() const;
|
||||
TypedSingle<sVec<uPtr<amqp::reader::IValue>>>::dump() const;
|
||||
|
||||
template<>
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
TypedSingle<std::list<std::unique_ptr<amqp::reader::IValue>>>::dump() const;
|
||||
TypedSingle<sList<uPtr<amqp::reader::IValue>>>::dump() const;
|
||||
|
||||
template<>
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
TypedSingle<std::vector<std::unique_ptr<amqp::internal::reader::Single>>>::dump() const;
|
||||
TypedSingle<sVec<uPtr<amqp::internal::reader::Single>>>::dump() const;
|
||||
|
||||
template<>
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
TypedSingle<std::list<std::unique_ptr<amqp::internal::reader::Single>>>::dump() const;
|
||||
TypedSingle<sList<uPtr<amqp::internal::reader::Single>>>::dump() const;
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* amqp::interanel::reader::TypedPair
|
||||
* amqp::internal::reader::TypedPair
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
@ -170,23 +169,23 @@ TypedPair<std::string>::dump() const {
|
||||
template<>
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
TypedPair<std::vector<std::unique_ptr<amqp::reader::IValue>>>::dump() const;
|
||||
TypedPair<sVec<uPtr<amqp::reader::IValue>>>::dump() const;
|
||||
|
||||
template<>
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
TypedPair<std::list<std::unique_ptr<amqp::reader::IValue>>>::dump() const;
|
||||
TypedPair<sList<uPtr<amqp::reader::IValue>>>::dump() const;
|
||||
|
||||
|
||||
template<>
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
TypedPair<std::vector<std::unique_ptr<amqp::internal::reader::Pair>>>::dump() const;
|
||||
TypedPair<sVec<uPtr<amqp::internal::reader::Pair>>>::dump() const;
|
||||
|
||||
template<>
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
TypedPair<std::list<std::unique_ptr<amqp::internal::reader::Pair>>>::dump() const;
|
||||
TypedPair<sList<uPtr<amqp::internal::reader::Pair>>>::dump() const;
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
@ -197,7 +196,7 @@ TypedPair<std::list<std::unique_ptr<amqp::internal::reader::Pair>>>::dump() cons
|
||||
|
||||
namespace amqp::internal::reader {
|
||||
|
||||
using IReader = amqp::reader::IReader<amqp::internal::schema::SchemaMap::const_iterator>;
|
||||
using IReader = amqp::reader::IReader<schema::SchemaMap::const_iterator>;
|
||||
|
||||
class Reader : public IReader {
|
||||
public :
|
||||
@ -209,12 +208,12 @@ namespace amqp::internal::reader {
|
||||
std::any read (struct pn_data_t *) const override = 0;
|
||||
std::string readString (struct pn_data_t *) const override = 0;
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue> dump(
|
||||
uPtr<amqp::reader::IValue> dump(
|
||||
const std::string &,
|
||||
pn_data_t *,
|
||||
const SchemaType &) const override = 0;
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue> dump(
|
||||
uPtr<amqp::reader::IValue> dump(
|
||||
pn_data_t *,
|
||||
const SchemaType &) const override = 0;
|
||||
};
|
||||
|
@ -26,7 +26,7 @@ RestrictedReader::m_name { // NOLINT
|
||||
|
||||
std::any
|
||||
amqp::internal::reader::
|
||||
RestrictedReader::read(pn_data_t *) const {
|
||||
RestrictedReader::read (pn_data_t *) const {
|
||||
return std::any(1);
|
||||
}
|
||||
|
||||
@ -34,70 +34,12 @@ RestrictedReader::read(pn_data_t *) const {
|
||||
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
RestrictedReader::readString(pn_data_t * data_) const {
|
||||
RestrictedReader::readString (pn_data_t * data_) const {
|
||||
return "hello";
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::list<std::unique_ptr<amqp::reader::IValue>>
|
||||
amqp::internal::reader::
|
||||
ListReader::dump_(
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_
|
||||
) const {
|
||||
proton::is_described (data_);
|
||||
|
||||
std::list<std::unique_ptr<amqp::reader::IValue>> read;
|
||||
|
||||
{
|
||||
proton::auto_enter ae (data_);
|
||||
auto it = schema_.fromDescriptor (proton::readAndNext<std::string>(data_));
|
||||
|
||||
{
|
||||
proton::auto_list_enter ale (data_, true);
|
||||
|
||||
for (size_t i { 0 } ; i < ale.elements() ; ++i) {
|
||||
read.emplace_back (m_reader.lock()->dump (data_, schema_));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return read;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
ListReader::dump (
|
||||
const std::string & name_,
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_
|
||||
) const {
|
||||
proton::auto_next an (data_);
|
||||
|
||||
return std::make_unique<TypedPair<std::list<std::unique_ptr<amqp::reader::IValue>>>>(
|
||||
name_,
|
||||
dump_ (data_, schema_));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
ListReader::dump(
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_
|
||||
) const {
|
||||
proton::auto_next an (data_);
|
||||
|
||||
return std::make_unique<amqp::internal::reader::TypedSingle<std::list<std::unique_ptr<amqp::reader::IValue>>>>(
|
||||
dump_ (data_, schema_));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
const std::string &
|
||||
amqp::internal::reader::
|
||||
RestrictedReader::name() const {
|
||||
@ -112,17 +54,4 @@ RestrictedReader::type() const {
|
||||
return m_type;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
amqp::internal::schema::Restricted::RestrictedTypes
|
||||
amqp::internal::reader::
|
||||
ListReader::restrictedType() const {
|
||||
return internal::schema::Restricted::RestrictedTypes::List;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -43,40 +43,4 @@ namespace amqp::internal::reader {
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
namespace amqp::internal::reader {
|
||||
|
||||
class ListReader : public RestrictedReader {
|
||||
private :
|
||||
// How to read the underlying types
|
||||
std::weak_ptr<Reader> m_reader;
|
||||
|
||||
std::list<std::unique_ptr<amqp::reader::IValue>> dump_(
|
||||
pn_data_t *,
|
||||
const SchemaType &) const;
|
||||
|
||||
public :
|
||||
ListReader (
|
||||
const std::string & type_,
|
||||
std::weak_ptr<Reader> reader_
|
||||
) : RestrictedReader (type_)
|
||||
, m_reader (std::move (reader_))
|
||||
{ }
|
||||
|
||||
~ListReader() final = default;
|
||||
|
||||
internal::schema::Restricted::RestrictedTypes restrictedType() const;
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue> dump(
|
||||
const std::string &,
|
||||
pn_data_t *,
|
||||
const SchemaType &) const override;
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue> dump(
|
||||
pn_data_t *,
|
||||
const SchemaType &) const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -0,0 +1,87 @@
|
||||
#include "BoolPropertyReader.h"
|
||||
|
||||
#include "proton/proton_wrapper.h"
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* BoolPropertyReader statics
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
const std::string
|
||||
amqp::internal::reader::
|
||||
BoolPropertyReader::m_name { // NOLINT
|
||||
"Bool Reader"
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
const std::string
|
||||
amqp::internal::reader::
|
||||
BoolPropertyReader::m_type { // NOLINT
|
||||
"bool"
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* BoolPropertyReader
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
std::any
|
||||
amqp::internal::reader::
|
||||
BoolPropertyReader::read (pn_data_t * data_) const {
|
||||
return std::any (true);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
BoolPropertyReader::readString (pn_data_t * data_) const {
|
||||
return std::to_string (proton::readAndNext<bool> (data_));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
uPtr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
BoolPropertyReader::dump (
|
||||
const std::string & name_,
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_) const
|
||||
{
|
||||
return std::make_unique<TypedPair<std::string>> (
|
||||
name_,
|
||||
std::to_string (proton::readAndNext<bool> (data_)));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
uPtr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
BoolPropertyReader::dump (
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_) const
|
||||
{
|
||||
return std::make_unique<TypedSingle<std::string>> (
|
||||
std::to_string (proton::readAndNext<bool> (data_)));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
const std::string &
|
||||
amqp::internal::reader::
|
||||
BoolPropertyReader::name() const {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
const std::string &
|
||||
amqp::internal::reader::
|
||||
BoolPropertyReader::type() const {
|
||||
return m_type;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#include "PropertyReader.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
namespace amqp::internal::reader {
|
||||
|
||||
class BoolPropertyReader : public PropertyReader {
|
||||
private :
|
||||
static const std::string m_name;
|
||||
static const std::string m_type;
|
||||
|
||||
public :
|
||||
std::string readString (pn_data_t *) const override;
|
||||
|
||||
std::any read (pn_data_t *) const override;
|
||||
|
||||
uPtr<amqp::reader::IValue> dump(
|
||||
const std::string &,
|
||||
pn_data_t *,
|
||||
const SchemaType &
|
||||
) const override;
|
||||
|
||||
uPtr<amqp::reader::IValue> dump(
|
||||
pn_data_t *,
|
||||
const SchemaType &
|
||||
) const override;
|
||||
|
||||
const std::string & name() const override;
|
||||
const std::string & type() const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
@ -0,0 +1,85 @@
|
||||
#include "DoublePropertyReader.h"
|
||||
|
||||
#include "proton/proton_wrapper.h"
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* DoublePropertyReader statics
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
const std::string
|
||||
amqp::internal::reader::
|
||||
DoublePropertyReader::m_name { // NOLINT
|
||||
"Double Reader"
|
||||
};
|
||||
|
||||
const std::string
|
||||
amqp::internal::reader::
|
||||
DoublePropertyReader::m_type { // NOLINT
|
||||
"double"
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* DoublePropertyReader
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
std::any
|
||||
amqp::internal::reader::
|
||||
DoublePropertyReader::read (pn_data_t * data_) const {
|
||||
return std::any (10.0);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
DoublePropertyReader::readString (pn_data_t * data_) const {
|
||||
return std::to_string (proton::readAndNext<double> (data_));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
uPtr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
DoublePropertyReader::dump (
|
||||
const std::string & name_,
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_) const
|
||||
{
|
||||
return std::make_unique<TypedPair<std::string>> (
|
||||
name_,
|
||||
std::to_string (proton::readAndNext<double> (data_)));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
uPtr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
DoublePropertyReader::dump (
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_) const
|
||||
{
|
||||
return std::make_unique<TypedSingle<std::string>> (
|
||||
std::to_string (proton::readAndNext<double> (data_)));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
const std::string &
|
||||
amqp::internal::reader::
|
||||
DoublePropertyReader::name() const {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
const std::string &
|
||||
amqp::internal::reader::
|
||||
DoublePropertyReader::type() const {
|
||||
return m_type;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#include "PropertyReader.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
namespace amqp::internal::reader {
|
||||
|
||||
class DoublePropertyReader : public PropertyReader {
|
||||
private :
|
||||
static const std::string m_name;
|
||||
static const std::string m_type;
|
||||
|
||||
public :
|
||||
std::string readString (pn_data_t *) const override;
|
||||
|
||||
std::any read (pn_data_t *) const override;
|
||||
|
||||
uPtr<amqp::reader::IValue> dump (
|
||||
const std::string &,
|
||||
pn_data_t *,
|
||||
const SchemaType &
|
||||
) const override;
|
||||
|
||||
uPtr<amqp::reader::IValue> dump (
|
||||
pn_data_t *,
|
||||
const SchemaType &
|
||||
) const override;
|
||||
|
||||
const std::string & name() const override;
|
||||
const std::string & type() const override;
|
||||
};
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
@ -0,0 +1,93 @@
|
||||
|
||||
#include "IntPropertyReader.h"
|
||||
|
||||
#include <any>
|
||||
#include <string>
|
||||
#include <proton/codec.h>
|
||||
|
||||
#include "proton/proton_wrapper.h"
|
||||
#include "amqp/reader/IReader.h"
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* IntPropertyReader statics
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
const std::string
|
||||
amqp::internal::reader::
|
||||
IntPropertyReader::m_name { // NOLINT
|
||||
"Int Reader"
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
const std::string
|
||||
amqp::internal::reader::
|
||||
IntPropertyReader::m_type { // NOLINT
|
||||
"int"
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* IntPropertyReader
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
std::any
|
||||
amqp::internal::reader::
|
||||
IntPropertyReader::read (pn_data_t * data_) const {
|
||||
return std::any (1);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
IntPropertyReader::readString (pn_data_t * data_) const {
|
||||
return std::to_string (proton::readAndNext<int> (data_));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
uPtr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
IntPropertyReader::dump (
|
||||
const std::string & name_,
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_) const
|
||||
{
|
||||
return std::make_unique<TypedPair<std::string>> (
|
||||
name_,
|
||||
std::to_string (proton::readAndNext<int> (data_)));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
uPtr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
IntPropertyReader::dump (
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_) const
|
||||
{
|
||||
return std::make_unique<TypedSingle<std::string>> (
|
||||
std::to_string (proton::readAndNext<int> (data_)));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
const std::string &
|
||||
amqp::internal::reader::
|
||||
IntPropertyReader::name() const {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
const std::string &
|
||||
amqp::internal::reader::
|
||||
IntPropertyReader::type() const {
|
||||
return m_type;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#include "PropertyReader.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
namespace amqp::internal::reader {
|
||||
|
||||
class IntPropertyReader : public PropertyReader {
|
||||
private :
|
||||
static const std::string m_name;
|
||||
static const std::string m_type;
|
||||
|
||||
public :
|
||||
~IntPropertyReader() override = default;
|
||||
|
||||
std::string readString(pn_data_t *) const override;
|
||||
|
||||
std::any read(pn_data_t *) const override;
|
||||
|
||||
uPtr <amqp::reader::IValue> dump(
|
||||
const std::string &,
|
||||
pn_data_t *,
|
||||
const SchemaType &
|
||||
) const override;
|
||||
|
||||
uPtr <amqp::reader::IValue> dump(
|
||||
pn_data_t *,
|
||||
const SchemaType &
|
||||
) const override;
|
||||
|
||||
const std::string &name() const override;
|
||||
const std::string &type() const override;
|
||||
};
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
@ -0,0 +1,87 @@
|
||||
#include "LongPropertyReader.h"
|
||||
|
||||
#include "proton/proton_wrapper.h"
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* LongPropertyReader statics
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
const std::string
|
||||
amqp::internal::reader::
|
||||
LongPropertyReader::m_name { // NOLINT
|
||||
"Long Reader"
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
const std::string
|
||||
amqp::internal::reader::
|
||||
LongPropertyReader::m_type { // NOLINT
|
||||
"long"
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* LongPropertyReader
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
std::any
|
||||
amqp::internal::reader::
|
||||
LongPropertyReader::read (pn_data_t * data_) const {
|
||||
return std::any (10L);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
LongPropertyReader::readString (pn_data_t * data_) const {
|
||||
return std::to_string (proton::readAndNext<long> (data_));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
uPtr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
LongPropertyReader::dump (
|
||||
const std::string & name_,
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_) const
|
||||
{
|
||||
return std::make_unique<TypedPair<std::string>> (
|
||||
name_,
|
||||
std::to_string (proton::readAndNext<long> (data_)));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
uPtr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
LongPropertyReader::dump (
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_) const
|
||||
{
|
||||
return std::make_unique<TypedSingle<std::string>> (
|
||||
std::to_string (proton::readAndNext<long> (data_)));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
const std::string &
|
||||
amqp::internal::reader::
|
||||
LongPropertyReader::name() const {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
const std::string &
|
||||
amqp::internal::reader::
|
||||
LongPropertyReader::type() const {
|
||||
return m_type;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#include "PropertyReader.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
namespace amqp::internal::reader {
|
||||
|
||||
class LongPropertyReader : public PropertyReader {
|
||||
private :
|
||||
static const std::string m_name;
|
||||
static const std::string m_type;
|
||||
|
||||
public :
|
||||
std::string readString (pn_data_t *) const override;
|
||||
|
||||
std::any read (pn_data_t *) const override;
|
||||
|
||||
uPtr<amqp::reader::IValue> dump(
|
||||
const std::string &,
|
||||
pn_data_t *,
|
||||
const SchemaType &
|
||||
) const override;
|
||||
|
||||
uPtr<amqp::reader::IValue> dump(
|
||||
pn_data_t *,
|
||||
const SchemaType &
|
||||
) const override;
|
||||
|
||||
const std::string & name() const override;
|
||||
const std::string & type() const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
@ -0,0 +1,89 @@
|
||||
#include "StringPropertyReader.h"
|
||||
|
||||
#include <proton/codec.h>
|
||||
|
||||
#include "proton/proton_wrapper.h"
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* StringPropertyReader statics
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
const std::string
|
||||
amqp::internal::reader::
|
||||
StringPropertyReader::m_type { // NOLINT
|
||||
"string"
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
const std::string
|
||||
amqp::internal::reader::
|
||||
StringPropertyReader::m_name { // NOLINT
|
||||
"String Reader"
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* class StringPropertyReader
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
std::any
|
||||
amqp::internal::reader::
|
||||
StringPropertyReader::read (pn_data_t * data_) const {
|
||||
return std::any ("hello");
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::string
|
||||
amqp::internal::reader::
|
||||
StringPropertyReader::readString (pn_data_t * data_) const {
|
||||
return proton::readAndNext<std::string> (data_);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
uPtr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
StringPropertyReader::dump (
|
||||
const std::string & name_,
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_) const
|
||||
{
|
||||
return std::make_unique<TypedPair<std::string>> (
|
||||
name_,
|
||||
"\"" + proton::readAndNext<std::string> (data_) + "\"");
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
uPtr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
StringPropertyReader::dump (
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_) const
|
||||
{
|
||||
return std::make_unique<TypedSingle<std::string>> (
|
||||
"\"" + proton::readAndNext<std::string> (data_) + "\"");
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
const std::string &
|
||||
amqp::internal::reader::
|
||||
StringPropertyReader::name() const {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
const std::string &
|
||||
amqp::internal::reader::
|
||||
StringPropertyReader::type() const {
|
||||
return m_type;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#include "PropertyReader.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
namespace amqp::internal::reader {
|
||||
|
||||
class StringPropertyReader : public PropertyReader {
|
||||
private :
|
||||
static const std::string m_name;
|
||||
static const std::string m_type;
|
||||
|
||||
public :
|
||||
std::string readString (pn_data_t *) const override;
|
||||
|
||||
std::any read (pn_data_t *) const override;
|
||||
|
||||
uPtr <amqp::reader::IValue> dump (
|
||||
const std::string &,
|
||||
pn_data_t *,
|
||||
const SchemaType &
|
||||
) const override;
|
||||
|
||||
uPtr <amqp::reader::IValue> dump (
|
||||
pn_data_t *,
|
||||
const SchemaType &
|
||||
) const override;
|
||||
|
||||
const std::string & name() const override;
|
||||
const std::string & type() const override;
|
||||
};
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
@ -0,0 +1,75 @@
|
||||
#include "ListReader.h"
|
||||
|
||||
#include "proton/proton_wrapper.h"
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* class ListReader
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
amqp::internal::schema::Restricted::RestrictedTypes
|
||||
amqp::internal::reader::
|
||||
ListReader::restrictedType() const {
|
||||
return internal::schema::Restricted::RestrictedTypes::List;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
ListReader::dump (
|
||||
const std::string & name_,
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_
|
||||
) const {
|
||||
proton::auto_next an (data_);
|
||||
|
||||
return std::make_unique<TypedPair<sList<uPtr<amqp::reader::IValue>>>>(
|
||||
name_,
|
||||
dump_ (data_, schema_));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue>
|
||||
amqp::internal::reader::
|
||||
ListReader::dump(
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_
|
||||
) const {
|
||||
proton::auto_next an (data_);
|
||||
|
||||
return std::make_unique<TypedSingle<sList<uPtr<amqp::reader::IValue>>>>(
|
||||
dump_ (data_, schema_));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
std::list<std::unique_ptr<amqp::reader::IValue>>
|
||||
amqp::internal::reader::
|
||||
ListReader::dump_(
|
||||
pn_data_t * data_,
|
||||
const SchemaType & schema_
|
||||
) const {
|
||||
proton::is_described (data_);
|
||||
|
||||
std::list<std::unique_ptr<amqp::reader::IValue>> read;
|
||||
|
||||
{
|
||||
proton::auto_enter ae (data_);
|
||||
auto it = schema_.fromDescriptor (proton::readAndNext<std::string>(data_));
|
||||
|
||||
{
|
||||
proton::auto_list_enter ale (data_, true);
|
||||
|
||||
for (size_t i { 0 } ; i < ale.elements() ; ++i) {
|
||||
read.emplace_back (m_reader.lock()->dump (data_, schema_));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return read;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#include "RestrictedReader.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
namespace amqp::internal::reader {
|
||||
|
||||
class ListReader : public RestrictedReader {
|
||||
private :
|
||||
// How to read the underlying types
|
||||
std::weak_ptr<Reader> m_reader;
|
||||
|
||||
std::list<uPtr<amqp::reader::IValue>> dump_(
|
||||
pn_data_t *,
|
||||
const SchemaType &) const;
|
||||
|
||||
public :
|
||||
ListReader (
|
||||
const std::string & type_,
|
||||
std::weak_ptr<Reader> reader_
|
||||
) : RestrictedReader (type_)
|
||||
, m_reader (std::move (reader_))
|
||||
{ }
|
||||
|
||||
~ListReader() final = default;
|
||||
|
||||
internal::schema::Restricted::RestrictedTypes restrictedType() const;
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue> dump(
|
||||
const std::string &,
|
||||
pn_data_t *,
|
||||
const SchemaType &) const override;
|
||||
|
||||
std::unique_ptr<amqp::reader::IValue> dump(
|
||||
pn_data_t *,
|
||||
const SchemaType &) const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
@ -38,9 +38,9 @@ amqp::internal::schema::
|
||||
Composite::Composite (
|
||||
const std::string & name_,
|
||||
std::string label_,
|
||||
const std::list<std::string> & provides_,
|
||||
std::unique_ptr<Descriptor> & descriptor_,
|
||||
std::vector<std::unique_ptr<Field>> & fields_
|
||||
const sList<std::string> & provides_,
|
||||
uPtr<Descriptor> & descriptor_,
|
||||
std::vector<uPtr<Field>> & fields_
|
||||
) : AMQPTypeNotation (name_, descriptor_)
|
||||
, m_label (std::move (label_))
|
||||
, m_provides (provides_)
|
||||
@ -49,7 +49,7 @@ Composite::Composite (
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
const std::vector<std::unique_ptr<amqp::internal::schema::Field>> &
|
||||
const std::vector<uPtr<amqp::internal::schema::Field>> &
|
||||
amqp::internal::schema::
|
||||
Composite::fields() const {
|
||||
return m_fields;
|
||||
|
@ -4,11 +4,11 @@
|
||||
|
||||
namespace amqp::internal::schema {
|
||||
|
||||
std::ostream &
|
||||
operator << (std::ostream & stream_, const Descriptor & desc_) {
|
||||
stream_ << desc_.m_name;
|
||||
return stream_;
|
||||
}
|
||||
std::ostream &
|
||||
operator << (std::ostream & stream_, const Descriptor & desc_) {
|
||||
stream_ << desc_.m_name;
|
||||
return stream_;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ operator << (
|
||||
|
||||
amqp::internal::schema::
|
||||
Envelope::Envelope (
|
||||
std::unique_ptr<Schema> & schema_,
|
||||
uPtr<Schema> & schema_,
|
||||
std::string descriptor_
|
||||
) : m_schema (std::move (schema_))
|
||||
, m_descriptor (std::move (descriptor_))
|
||||
|
Loading…
Reference in New Issue
Block a user