From 6266b974c0c227d279f4dde0fdbc07defd7b5965 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 19 Sep 2008 12:56:38 +0000 Subject: 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 --- cpp/src/qpid/framing/FieldTable.cpp | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'cpp/src/qpid/framing/FieldTable.cpp') diff --git a/cpp/src/qpid/framing/FieldTable.cpp b/cpp/src/qpid/framing/FieldTable.cpp index bd20c10c37..5a5d755fe8 100644 --- a/cpp/src/qpid/framing/FieldTable.cpp +++ b/cpp/src/qpid/framing/FieldTable.cpp @@ -19,6 +19,7 @@ * */ #include "FieldTable.h" +#include "Array.h" #include "Buffer.h" #include "FieldValue.h" #include "qpid/Exception.h" @@ -77,9 +78,14 @@ void FieldTable::setTimestamp(const std::string& name, uint64_t value){ values[name] = ValuePtr(new TimeValue(value)); } -void FieldTable::setTable(const std::string& name, const FieldTable& value){ +void FieldTable::setTable(const std::string& name, const FieldTable& value) +{ values[name] = ValuePtr(new FieldTableValue(value)); } +void FieldTable::setArray(const std::string& name, const Array& value) +{ + values[name] = ValuePtr(new ArrayValue(value)); +} FieldTable::ValuePtr FieldTable::get(const std::string& name) const { @@ -116,10 +122,23 @@ int FieldTable::getInt(const std::string& name) const { //uint64_t FieldTable::getTimestamp(const std::string& name) const { // return getValue(name); //} -// -//void FieldTable::getTable(const std::string& name, FieldTable& value) const { -// value = getValue(name); -//} + +void FieldTable::getTable(const std::string& name, FieldTable& value) const { + FieldTable::ValuePtr vptr = get(name); + if (vptr) { + value = vptr->get(); + } +} + +void FieldTable::getArray(const std::string& name, Array& value) const { + FieldTable::ValuePtr vptr = get(name); + if (vptr) { + const EncodedValue* ev = dynamic_cast< EncodedValue* >(&(vptr->getData())); + if (ev != 0) { + value = ev->getValue(); + } + } +} void FieldTable::encode(Buffer& buffer) const{ buffer.putLong(size() - 4); -- cgit v1.2.1