Merge pull request #5 from luca3m/array-count
Array methods, Table and include guards
This commit is contained in:
commit
400c619b01
|
|
@ -1,6 +1,7 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* AMQP field array
|
* AMQP field array
|
||||||
*
|
*
|
||||||
* @copyright 2014 Copernica BV
|
* @copyright 2014 Copernica BV
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -20,7 +21,7 @@ private:
|
||||||
* @typedef
|
* @typedef
|
||||||
*/
|
*/
|
||||||
typedef std::vector<std::shared_ptr<Field>> FieldArray;
|
typedef std::vector<std::shared_ptr<Field>> FieldArray;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The actual fields
|
* The actual fields
|
||||||
* @var FieldArray
|
* @var FieldArray
|
||||||
|
|
@ -30,7 +31,7 @@ private:
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor to construct an array from a received frame
|
* Constructor to construct an array from a received frame
|
||||||
*
|
*
|
||||||
* @param frame received frame
|
* @param frame received frame
|
||||||
*/
|
*/
|
||||||
Array(ReceivedFrame &frame);
|
Array(ReceivedFrame &frame);
|
||||||
|
|
@ -99,6 +100,25 @@ public:
|
||||||
*/
|
*/
|
||||||
const Field &get(uint8_t index);
|
const Field &get(uint8_t index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get number of elements on this array
|
||||||
|
*
|
||||||
|
* @return array size
|
||||||
|
*/
|
||||||
|
uint32_t count() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove last element from array
|
||||||
|
*/
|
||||||
|
void pop_back();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add field to end of array
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
void push_back(const Field &value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a field
|
* Get a field
|
||||||
*
|
*
|
||||||
|
|
@ -111,7 +131,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write encoded payload to the given buffer.
|
* Write encoded payload to the given buffer.
|
||||||
* @param buffer
|
* @param buffer
|
||||||
*/
|
*/
|
||||||
virtual void fill(OutBuffer& buffer) const override;
|
virtual void fill(OutBuffer& buffer) const override;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* BooleanSet.h
|
* BooleanSet.h
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* Class describing a (mid-level) AMQP channel implementation
|
* Class describing a (mid-level) AMQP channel implementation
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* ChannelHandler.h
|
* ChannelHandler.h
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* ChannelImpl.h
|
* ChannelImpl.h
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* Classes.h
|
* Classes.h
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* Class describing a mid-level Amqp connection
|
* Class describing a mid-level Amqp connection
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* ConnectionHandler.h
|
* ConnectionHandler.h
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* Connection implementation
|
* Connection implementation
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* Decimal field type for AMQP
|
* Decimal field type for AMQP
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* EntityImpl.h
|
* EntityImpl.h
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* Envelope.h
|
* Envelope.h
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* ExchangeType.h
|
* ExchangeType.h
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* Available field types for AMQP
|
* Available field types for AMQP
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* Field proxy. Returned by the table. Can be casted to the
|
* Field proxy. Returned by the table. Can be casted to the
|
||||||
* relevant native type (std::string or numeric)
|
* relevant native type (std::string or numeric)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* AmqpFlags.h
|
* AmqpFlags.h
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* The login information to access a server
|
* The login information to access a server
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* Message.h
|
* Message.h
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* MetaData.h
|
* MetaData.h
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* Numeric field types for AMQP
|
* Numeric field types for AMQP
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* OutBuffer.h
|
* OutBuffer.h
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* ReceivedFrame.h
|
* ReceivedFrame.h
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* String field types for amqp
|
* String field types for amqp
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* AMQP field table
|
* AMQP field table
|
||||||
*
|
*
|
||||||
|
|
@ -109,7 +110,7 @@ public:
|
||||||
* @param name field name
|
* @param name field name
|
||||||
* @return the field value
|
* @return the field value
|
||||||
*/
|
*/
|
||||||
const Field &get(const std::string &name);
|
const Field &get(const std::string &name) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a field
|
* Get a field
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
/**
|
/**
|
||||||
* Watchable.h
|
* Watchable.h
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
/**
|
/**
|
||||||
* Array.cpp
|
* Array.cpp
|
||||||
*
|
*
|
||||||
* Implementation of an array
|
* Implementation of an array
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
|
|
||||||
|
|
@ -23,7 +23,7 @@ Array::Array(ReceivedFrame &frame)
|
||||||
{
|
{
|
||||||
// one byte less for the field type
|
// one byte less for the field type
|
||||||
charsToRead -= 1;
|
charsToRead -= 1;
|
||||||
|
|
||||||
// read the field type and construct the field
|
// read the field type and construct the field
|
||||||
Field *field = Field::decode(frame);
|
Field *field = Field::decode(frame);
|
||||||
if (!field) continue;
|
if (!field) continue;
|
||||||
|
|
@ -62,7 +62,7 @@ const Field &Array::get(uint8_t index)
|
||||||
{
|
{
|
||||||
// used if index does not exist
|
// used if index does not exist
|
||||||
static ShortString empty;
|
static ShortString empty;
|
||||||
|
|
||||||
// check whether we have that many elements
|
// check whether we have that many elements
|
||||||
if (index >= _fields.size()) return empty;
|
if (index >= _fields.size()) return empty;
|
||||||
|
|
||||||
|
|
@ -70,6 +70,21 @@ const Field &Array::get(uint8_t index)
|
||||||
return *_fields[index];
|
return *_fields[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t Array::count() const
|
||||||
|
{
|
||||||
|
return _fields.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Array::pop_back()
|
||||||
|
{
|
||||||
|
_fields.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Array::push_back(const Field& value)
|
||||||
|
{
|
||||||
|
_fields.push_back(std::shared_ptr<Field>(value.clone()));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the size this field will take when
|
* Get the size this field will take when
|
||||||
* encoded in the AMQP wire-frame format
|
* encoded in the AMQP wire-frame format
|
||||||
|
|
@ -92,7 +107,7 @@ size_t Array::size() const
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write encoded payload to the given buffer.
|
* Write encoded payload to the given buffer.
|
||||||
*/
|
*/
|
||||||
void Array::fill(OutBuffer& buffer) const
|
void Array::fill(OutBuffer& buffer) const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ Table &Table::operator=(Table &&table)
|
||||||
* @param name field name
|
* @param name field name
|
||||||
* @return the field value
|
* @return the field value
|
||||||
*/
|
*/
|
||||||
const Field &Table::get(const std::string &name)
|
const Field &Table::get(const std::string &name) const
|
||||||
{
|
{
|
||||||
// we need an empty string
|
// we need an empty string
|
||||||
static ShortString empty;
|
static ShortString empty;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue