diff options
author | Gordon Sim <gsim@apache.org> | 2008-03-31 17:20:08 +0000 |
---|---|---|
committer | Gordon Sim <gsim@apache.org> | 2008-03-31 17:20:08 +0000 |
commit | 9649f8ccca2a9f62a946bd58e7d3e8cb60031232 (patch) | |
tree | a8a4f30c6c01f455e2429002a5ccc3c719e773b7 /cpp/src | |
parent | 36cfeb13b8ad4b532f7f9c2b48ac2353e6217bcd (diff) | |
download | qpid-python-9649f8ccca2a9f62a946bd58e7d3e8cb60031232.tar.gz |
Updated xml fragment to reflect correct types for connection.start.mechanisms, connection.start.locales and connection.open.capabilities
Updated connection handler in line with above changes
Added Str16Value to FieldValues
Allow Array instances of different types to be created
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@643067 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/qpid/broker/ConnectionHandler.cpp | 10 | ||||
-rw-r--r-- | cpp/src/qpid/broker/ConnectionHandler.h | 2 | ||||
-rw-r--r-- | cpp/src/qpid/framing/Array.cpp | 11 | ||||
-rw-r--r-- | cpp/src/qpid/framing/Array.h | 5 | ||||
-rw-r--r-- | cpp/src/qpid/framing/FieldValue.cpp | 13 | ||||
-rw-r--r-- | cpp/src/qpid/framing/FieldValue.h | 6 |
6 files changed, 42 insertions, 5 deletions
diff --git a/cpp/src/qpid/broker/ConnectionHandler.cpp b/cpp/src/qpid/broker/ConnectionHandler.cpp index 53a403c955..f28c2bb7f7 100644 --- a/cpp/src/qpid/broker/ConnectionHandler.cpp +++ b/cpp/src/qpid/broker/ConnectionHandler.cpp @@ -66,8 +66,12 @@ void ConnectionHandler::handle(framing::AMQFrame& frame) ConnectionHandler::ConnectionHandler(Connection& connection) : handler(new Handler(connection)) { FieldTable properties; - string mechanisms(PLAIN); - string locales(en_US); + Array mechanisms(0x95); + boost::shared_ptr<FieldValue> m(new Str16Value(PLAIN)); + mechanisms.add(m); + Array locales(0x95); + boost::shared_ptr<FieldValue> l(new Str16Value(en_US)); + locales.add(l); handler->serverMode = true; handler->client.start(properties, mechanisms, locales); } @@ -105,7 +109,7 @@ void ConnectionHandler::Handler::tuneOk(uint16_t /*channelmax*/, } void ConnectionHandler::Handler::open(const string& /*virtualHost*/, - const string& /*capabilities*/, bool /*insist*/) + const framing::Array& /*capabilities*/, bool /*insist*/) { string knownhosts; client.openOk(knownhosts); diff --git a/cpp/src/qpid/broker/ConnectionHandler.h b/cpp/src/qpid/broker/ConnectionHandler.h index 8e659f0913..56de1c7517 100644 --- a/cpp/src/qpid/broker/ConnectionHandler.h +++ b/cpp/src/qpid/broker/ConnectionHandler.h @@ -56,7 +56,7 @@ class ConnectionHandler : public framing::FrameHandler void tuneOk(uint16_t channelMax, uint32_t frameMax, uint16_t heartbeat); void heartbeat() {} void open(const std::string& virtualHost, - const std::string& capabilities, bool insist); + const framing::Array& capabilities, bool insist); void close(uint16_t replyCode, const std::string& replyText, uint16_t classId, uint16_t methodId); void closeOk(); diff --git a/cpp/src/qpid/framing/Array.cpp b/cpp/src/qpid/framing/Array.cpp index 1215c8a28b..d2ab354dab 100644 --- a/cpp/src/qpid/framing/Array.cpp +++ b/cpp/src/qpid/framing/Array.cpp @@ -30,6 +30,8 @@ namespace framing { Array::Array() : typeOctet(0xF0/*void*/) {} +Array::Array(uint8_t type) : typeOctet(type) {} + Array::Array(const std::vector<std::string>& in) { typeOctet = 0xA4; @@ -39,6 +41,7 @@ Array::Array(const std::vector<std::string>& in) } } + uint32_t Array::size() const { //note: size is only included when used as a 'top level' type uint32_t len(4/*size*/ + 1/*type*/ + 4/*count*/); @@ -109,6 +112,14 @@ bool Array::operator==(const Array& x) const { return true; } +void Array::add(ValuePtr value) +{ + if (typeOctet != value->getType()) { + throw SyntaxErrorException(QPID_MSG("Wrong type of value, expected " << typeOctet)); + } + values.push_back(value); +} + } } diff --git a/cpp/src/qpid/framing/Array.h b/cpp/src/qpid/framing/Array.h index 6a13c63672..1367a023f2 100644 --- a/cpp/src/qpid/framing/Array.h +++ b/cpp/src/qpid/framing/Array.h @@ -47,9 +47,12 @@ class Array bool operator==(const Array& other) const; Array(); - //only long string arrays can currently be created (any type can be decoded) + Array(uint8_t type); + //creates a longstr array Array(const std::vector<std::string>& in); + void add(ValuePtr value); + template <class T> void collect(std::vector<T>& out) { diff --git a/cpp/src/qpid/framing/FieldValue.cpp b/cpp/src/qpid/framing/FieldValue.cpp index 961b6017cd..cbda061209 100644 --- a/cpp/src/qpid/framing/FieldValue.cpp +++ b/cpp/src/qpid/framing/FieldValue.cpp @@ -25,6 +25,11 @@ namespace qpid { namespace framing { +uint8_t FieldValue::getType() +{ + return typeOctet; +} + void FieldValue::setType(uint8_t type) { typeOctet = type; @@ -106,6 +111,14 @@ StringValue::StringValue(const std::string& v) : { } +Str16Value::Str16Value(const std::string& v) : + FieldValue( + 0x95, + new VariableWidthValue<2>( + reinterpret_cast<const uint8_t*>(v.data()), + reinterpret_cast<const uint8_t*>(v.data()+v.size()))) +{} + IntegerValue::IntegerValue(int v) : FieldValue(0x21, new FixedWidthValue<4>(v)) { diff --git a/cpp/src/qpid/framing/FieldValue.h b/cpp/src/qpid/framing/FieldValue.h index 3ec95a99e1..272670d102 100644 --- a/cpp/src/qpid/framing/FieldValue.h +++ b/cpp/src/qpid/framing/FieldValue.h @@ -79,6 +79,7 @@ class FieldValue { FieldValue(): data(0) {}; // Default assignment operator is fine void setType(uint8_t type); + uint8_t getType(); Data& getData() { return *data; } uint32_t size() const { return 1 + data->size(); }; bool empty() const { return data.get() == 0; } @@ -206,6 +207,11 @@ class StringValue : public FieldValue { StringValue(const std::string& v); }; +class Str16Value : public FieldValue { + public: + Str16Value(const std::string& v); +}; + /* * Basic integer value encodes as signed 32 bit */ |