Added Void field type
This commit is contained in:
parent
c783cbc17e
commit
1c4917bead
|
|
@ -55,6 +55,7 @@
|
|||
#include "amqpcpp/fieldproxy.h"
|
||||
#include "amqpcpp/table.h"
|
||||
#include "amqpcpp/array.h"
|
||||
#include "amqpcpp/voidfield.h"
|
||||
|
||||
// envelope for publishing and consuming
|
||||
#include "amqpcpp/metadata.h"
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ public:
|
|||
virtual bool isTable() const { return false; }
|
||||
virtual bool isBoolean() const { return false; }
|
||||
virtual bool isString() const { return false; }
|
||||
virtual bool isVoid() const { return false; }
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,124 @@
|
|||
/**
|
||||
* Void field type for AMQP
|
||||
*
|
||||
* @copyright
|
||||
*/
|
||||
|
||||
/**
|
||||
* Include guard
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Dependencies
|
||||
*/
|
||||
#include <memory>
|
||||
#include "receivedframe.h"
|
||||
#include "outbuffer.h"
|
||||
#include "field.h"
|
||||
|
||||
/**
|
||||
* Set up namespace
|
||||
*/
|
||||
namespace AMQP
|
||||
{
|
||||
class VoidField : public Field
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* Field have no value
|
||||
*/
|
||||
|
||||
public:
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
VoidField() {}
|
||||
|
||||
/**
|
||||
* Parse based on incoming buffer
|
||||
* @param frame
|
||||
*/
|
||||
VoidField(ReceivedFrame &frame)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~VoidField() {}
|
||||
|
||||
/**
|
||||
* Create a new instance of this object
|
||||
* @return Field*
|
||||
*/
|
||||
virtual std::shared_ptr<Field> clone() const override
|
||||
{
|
||||
// create a new copy of ourselves and return it
|
||||
return std::make_shared<VoidField>();
|
||||
}
|
||||
|
||||
/**
|
||||
* We are an integer field
|
||||
*
|
||||
* @return true, because we are an integer
|
||||
*/
|
||||
bool isInteger() const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size this field will take when
|
||||
* encoded in the AMQP wire-frame format
|
||||
* @return size_t
|
||||
*/
|
||||
virtual size_t size() const override
|
||||
{
|
||||
// numeric types have no extra storage requirements
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write encoded payload to the given buffer.
|
||||
* @param buffer OutBuffer to write to
|
||||
*/
|
||||
virtual void fill(OutBuffer &buffer) const override
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type ID that is used to identify this type of
|
||||
* field in a field table
|
||||
*/
|
||||
virtual char typeID() const override
|
||||
{
|
||||
return 'V';
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the object to a stream
|
||||
* @param std::ostream
|
||||
*/
|
||||
virtual void output(std::ostream &stream) const override
|
||||
{
|
||||
// show
|
||||
stream << "void()";
|
||||
}
|
||||
|
||||
/**
|
||||
* We are an void field
|
||||
*
|
||||
* @return true, because we are an void
|
||||
*/
|
||||
bool isVoid() const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* end namespace
|
||||
*/
|
||||
}
|
||||
|
|
@ -41,6 +41,7 @@ Field *Field::decode(ReceivedFrame &frame)
|
|||
case 'A': return new Array(frame);
|
||||
case 'T': return new Timestamp(frame);
|
||||
case 'F': return new Table(frame);
|
||||
case 'V': return new VoidField(frame);
|
||||
default: return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@
|
|||
#include "amqpcpp/fieldproxy.h"
|
||||
#include "amqpcpp/table.h"
|
||||
#include "amqpcpp/array.h"
|
||||
#include "amqpcpp/voidfield.h"
|
||||
|
||||
// envelope for publishing and consuming
|
||||
#include "amqpcpp/metadata.h"
|
||||
|
|
|
|||
Loading…
Reference in New Issue