forked from CopernicaMarketingSoftware/AMQP-CPP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray.h
134 lines (116 loc) · 2.39 KB
/
array.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/**
* AMQP field array
*
* @copyright 2014 Copernica BV
*/
/**
* Set up namespace
*/
namespace AMQP {
/**
* AMQP field array
*/
class Array : public Field
{
private:
/**
* Definition of an array as a vector
* @typedef
*/
typedef std::vector<std::shared_ptr<Field>> FieldArray;
/**
* The actual fields
* @var FieldArray
*/
FieldArray _fields;
public:
/**
* Constructor to construct an array from a received frame
*
* @param frame received frame
*/
Array(ReceivedFrame &frame);
/**
* Copy constructor
* @param array
*/
Array(const Array &array);
/**
* Move constructor
* @param array
*/
Array(Array &&array) : _fields(std::move(array._fields)) {}
/**
* Constructor for an empty Array
*/
Array() {}
/**
* Destructor
*/
virtual ~Array() {}
/**
* Create a new instance of this object
* @return Field*
*/
virtual Field *clone() const override
{
return new Array(*this);
}
/**
* Get the size this field will take when
* encoded in the AMQP wire-frame format
* @return size_t
*/
virtual size_t size() const override;
/**
* Set a field
*
* @param index field index
* @param value field value
* @return Array
*/
Array set(uint8_t index, const Field &value)
{
// copy to a new pointer and store it
_fields[index] = std::shared_ptr<Field>(value.clone());
// allow chaining
return *this;
}
/**
* Get a field
*
* If the field does not exist, an empty string is returned
*
* @param index field index
* @return Field
*/
const Field &get(uint8_t index);
/**
* Get a field
*
* @param index field index
* @return ArrayFieldProxy
*/
ArrayFieldProxy operator[](uint8_t index)
{
return ArrayFieldProxy(this, index);
}
/**
* Write encoded payload to the given buffer.
* @param buffer
*/
virtual void fill(OutBuffer& buffer) const override;
/**
* Get the type ID that is used to identify this type of
* field in a field table
* @return char
*/
virtual char typeID() const override
{
return 'A';
}
};
/**
* end namespace
*/
}