From 8e1f647a10024492e09a689e61128eb5f42c561e Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 15 Jan 2010 15:17:01 +0000 Subject: QPID-2323: add a Uuid type and allow it as the value of a Variant. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@899657 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/client/amqp0_10/Codecs.cpp | 38 ++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'cpp/src/qpid/client') diff --git a/cpp/src/qpid/client/amqp0_10/Codecs.cpp b/cpp/src/qpid/client/amqp0_10/Codecs.cpp index ff72dfbf4e..835d80185a 100644 --- a/cpp/src/qpid/client/amqp0_10/Codecs.cpp +++ b/cpp/src/qpid/client/amqp0_10/Codecs.cpp @@ -112,6 +112,13 @@ void setEncodingFor(Variant& out, uint8_t code) } } +qpid::messaging::Uuid getUuid(FieldValue& value) +{ + unsigned char data[16]; + value.getFixedWidthValue<16>(data); + return qpid::messaging::Uuid(data); +} + Variant toVariant(boost::shared_ptr in) { Variant out; @@ -123,19 +130,21 @@ Variant toVariant(boost::shared_ptr in) case 0x03: out = in->getIntegerValue(); break; case 0x04: break; //TODO: iso-8859-15 char case 0x08: out = in->getIntegerValue(); break; - case 0x010: out.setEncoding(amqp0_10_binary); - case 0x011: out = in->getIntegerValue(); break; - case 0x012: out = in->getIntegerValue(); break; - case 0x020: out.setEncoding(amqp0_10_binary); - case 0x021: out = in->getIntegerValue(); break; - case 0x022: out = in->getIntegerValue(); break; - case 0x023: out = in->get(); break; - case 0x027: break; //TODO: utf-32 char - case 0x030: out.setEncoding(amqp0_10_binary); - case 0x031: out = in->getIntegerValue(); break; - case 0x038: out.setEncoding(amqp0_10_datetime); //treat datetime as uint64_t, but set encoding - case 0x032: out = in->getIntegerValue(); break; - case 0x033:out = in->get(); break; + case 0x10: out.setEncoding(amqp0_10_binary); + case 0x11: out = in->getIntegerValue(); break; + case 0x12: out = in->getIntegerValue(); break; + case 0x20: out.setEncoding(amqp0_10_binary); + case 0x21: out = in->getIntegerValue(); break; + case 0x22: out = in->getIntegerValue(); break; + case 0x23: out = in->get(); break; + case 0x27: break; //TODO: utf-32 char + case 0x30: out.setEncoding(amqp0_10_binary); + case 0x31: out = in->getIntegerValue(); break; + case 0x38: out.setEncoding(amqp0_10_datetime); //treat datetime as uint64_t, but set encoding + case 0x32: out = in->getIntegerValue(); break; + case 0x33: out = in->get(); break; + + case 0x48: out = getUuid(*in); break; //TODO: figure out whether and how to map values with codes 0x40-0xd8 @@ -197,12 +206,11 @@ boost::shared_ptr toFieldValue(const Variant& in) case VAR_DOUBLE: out = boost::shared_ptr(new DoubleValue(in.asDouble())); break; //TODO: check encoding (and length?) when deciding what AMQP type to treat string as case VAR_STRING: out = boost::shared_ptr(new Str16Value(in.asString())); break; + case VAR_UUID: out = boost::shared_ptr(new UuidValue(in.asUuid().data())); break; case VAR_MAP: - //out = boost::shared_ptr(toFieldValueCollection(in.asMap(), &toFieldTableEntry)); out = boost::shared_ptr(toFieldTableValue(in.asMap())); break; case VAR_LIST: - //out = boost::shared_ptr(toFieldValueCollection(in.asList(), &toFieldValue)); out = boost::shared_ptr(toListValue(in.asList())); break; } -- cgit v1.2.1