summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/framing/FieldValue.cpp
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2008-09-19 12:56:38 +0000
committerGordon Sim <gsim@apache.org>2008-09-19 12:56:38 +0000
commit6266b974c0c227d279f4dde0fdbc07defd7b5965 (patch)
treefb407d8484cd6e01f0823a39aefce922782420e2 /cpp/src/qpid/framing/FieldValue.cpp
parent85021877a773ca361d90ebfce5d9ff0994d50378 (diff)
downloadqpid-python-6266b974c0c227d279f4dde0fdbc07defd7b5965.tar.gz
Added support for nested field tables & arrays within a field table.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@697076 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/framing/FieldValue.cpp')
-rw-r--r--cpp/src/qpid/framing/FieldValue.cpp106
1 files changed, 58 insertions, 48 deletions
diff --git a/cpp/src/qpid/framing/FieldValue.cpp b/cpp/src/qpid/framing/FieldValue.cpp
index 681f20a793..3b3c2f2126 100644
--- a/cpp/src/qpid/framing/FieldValue.cpp
+++ b/cpp/src/qpid/framing/FieldValue.cpp
@@ -19,6 +19,7 @@
*
*/
#include "FieldValue.h"
+#include "Array.h"
#include "Buffer.h"
#include "qpid/framing/reply_exceptions.h"
@@ -33,53 +34,58 @@ uint8_t FieldValue::getType()
void FieldValue::setType(uint8_t type)
{
typeOctet = type;
-
- uint8_t lenType = typeOctet >> 4;
- switch(lenType){
- case 0:
- data.reset(new FixedWidthValue<1>());
- break;
- case 1:
- data.reset(new FixedWidthValue<2>());
- break;
- case 2:
- data.reset(new FixedWidthValue<4>());
- break;
- case 3:
- data.reset(new FixedWidthValue<8>());
- break;
- case 4:
- data.reset(new FixedWidthValue<16>());
- break;
- case 5:
- data.reset(new FixedWidthValue<32>());
- break;
- case 6:
- data.reset(new FixedWidthValue<64>());
- break;
- case 7:
- data.reset(new FixedWidthValue<128>());
- break;
- case 8:
- data.reset(new VariableWidthValue<1>());
- break;
- case 9:
- data.reset(new VariableWidthValue<2>());
- break;
- case 0xA:
- data.reset(new VariableWidthValue<4>());
- break;
- case 0xC:
- data.reset(new FixedWidthValue<5>());
- break;
- case 0xD:
- data.reset(new FixedWidthValue<9>());
- break;
- case 0xF:
- data.reset(new FixedWidthValue<0>());
- break;
- default:
- throw IllegalArgumentException(QPID_MSG("Unknown field table value type: " << (int)typeOctet));
+ if (typeOctet == 0xA8) {
+ data.reset(new EncodedValue<FieldTable>());
+ } else if (typeOctet == 0xAA) {
+ data.reset(new EncodedValue<Array>());
+ } else {
+ uint8_t lenType = typeOctet >> 4;
+ switch(lenType){
+ case 0:
+ data.reset(new FixedWidthValue<1>());
+ break;
+ case 1:
+ data.reset(new FixedWidthValue<2>());
+ break;
+ case 2:
+ data.reset(new FixedWidthValue<4>());
+ break;
+ case 3:
+ data.reset(new FixedWidthValue<8>());
+ break;
+ case 4:
+ data.reset(new FixedWidthValue<16>());
+ break;
+ case 5:
+ data.reset(new FixedWidthValue<32>());
+ break;
+ case 6:
+ data.reset(new FixedWidthValue<64>());
+ break;
+ case 7:
+ data.reset(new FixedWidthValue<128>());
+ break;
+ case 8:
+ data.reset(new VariableWidthValue<1>());
+ break;
+ case 9:
+ data.reset(new VariableWidthValue<2>());
+ break;
+ case 0xA:
+ data.reset(new VariableWidthValue<4>());
+ break;
+ case 0xC:
+ data.reset(new FixedWidthValue<5>());
+ break;
+ case 0xD:
+ data.reset(new FixedWidthValue<9>());
+ break;
+ case 0xF:
+ data.reset(new FixedWidthValue<0>());
+ break;
+ default:
+ throw IllegalArgumentException(QPID_MSG("Unknown field table value type: " << (int)typeOctet));
+ }
}
}
@@ -137,7 +143,11 @@ TimeValue::TimeValue(uint64_t v) :
{
}
-FieldTableValue::FieldTableValue(const FieldTable&) : FieldValue()
+FieldTableValue::FieldTableValue(const FieldTable& f) : FieldValue(0xa8, new EncodedValue<FieldTable>(f))
+{
+}
+
+ArrayValue::ArrayValue(const Array& a) : FieldValue(0xaa, new EncodedValue<Array>(a))
{
}