summaryrefslogtreecommitdiff
path: root/cpp/src/qpid
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2009-11-19 23:07:20 +0000
committerGordon Sim <gsim@apache.org>2009-11-19 23:07:20 +0000
commit92cea0bb1467c58cb1f826bbf3497fd98bf0cddd (patch)
tree0f4414537ff943faa4b757d97c5dd2e533a05d26 /cpp/src/qpid
parent3c9a8fdd71d8d1e29de4da3126cf35e1a88a069b (diff)
downloadqpid-python-92cea0bb1467c58cb1f826bbf3497fd98bf0cddd.tar.gz
QPID-664: Bring address option names in to line with those used in python client.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@882348 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid')
-rw-r--r--cpp/src/qpid/client/amqp0_10/AddressResolution.cpp63
-rw-r--r--cpp/src/qpid/messaging/Address.cpp32
2 files changed, 62 insertions, 33 deletions
diff --git a/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp b/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp
index b1e6a9b671..edf1ed74f5 100644
--- a/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp
+++ b/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp
@@ -71,6 +71,7 @@ const std::string FILTER("filter");
const std::string RELIABILITY("reliability");
const std::string NAME("subscription-name");
const std::string NODE_PROPERTIES("node-properties");
+const std::string X_PROPERTIES("x-properties");
//policy types
const std::string CREATE("create");
@@ -102,13 +103,12 @@ const std::string WILDCARD_ANY("*");
//some amqp 0-10 specific options
namespace xamqp{
-const std::string AUTO_DELETE("x-amqp0-10-auto-delete");
-const std::string EXCHANGE_TYPE("x-amqp0-10-exchange-type");
-const std::string EXCLUSIVE("x-amqp0-10-exclusive");
-const std::string ALTERNATE_EXCHANGE("x-amqp0-10-alternate-exchange");
-const std::string ARGUMENTS("x-amqp0-10-arguments");
-const std::string QUEUE_ARGUMENTS("x-amqp0-10-queue-arguments");
-const std::string SUBSCRIBE_ARGUMENTS("x-amqp0-10-queue-arguments");
+const std::string AUTO_DELETE("auto-delete");
+const std::string EXCHANGE_TYPE("type");
+const std::string EXCLUSIVE("exclusive");
+const std::string ALTERNATE_EXCHANGE("alternate-exchange");
+const std::string QUEUE_ARGUMENTS("x-queue-arguments");
+const std::string SUBSCRIBE_ARGUMENTS("x-subscribe-arguments");
}
class Node
@@ -692,20 +692,27 @@ void Queue::checkAssert(qpid::client::AsyncSession& session, CheckMode mode)
void Queue::configure(const Address& address)
{
- const Variant& properties = address.getOption(NODE_PROPERTIES);
- if (!properties.isVoid()) {
- Variant::Map p = properties.asMap();
- durable = p[DURABLE];
- autoDelete = p[xamqp::AUTO_DELETE];
- exclusive = p[xamqp::EXCLUSIVE];
- alternateExchange = p[xamqp::ALTERNATE_EXCHANGE].asString();
- if (!p[xamqp::ARGUMENTS].isVoid()) {
- translate(p[xamqp::ARGUMENTS].asMap(), arguments);
+ const Variant& v = address.getOption(NODE_PROPERTIES);
+ if (!v.isVoid()) {
+ Variant::Map nodeProps = v.asMap();
+ durable = nodeProps[DURABLE];
+ Variant::Map::const_iterator x = nodeProps.find(X_PROPERTIES);
+ if (x != nodeProps.end()) {
+ const Variant::Map& xProps = x->second.asMap();
+ Variant::Map passthrough;
+ for (Variant::Map::const_iterator i = xProps.begin(); i != xProps.end(); ++i) {
+ if (i->first == xamqp::AUTO_DELETE) autoDelete = i->second;
+ else if (i->first == xamqp::EXCLUSIVE) exclusive = i->second;
+ else if (i->first == xamqp::ALTERNATE_EXCHANGE) alternateExchange = i->second.asString();
+ else passthrough[i->first] = i->second;
+ }
+ translate(passthrough, arguments);
}
}
}
Exchange::Exchange(const Address& a) : Node(a),
+ type(TOPIC_EXCHANGE),
durable(false),
autoDelete(false)
{
@@ -778,15 +785,21 @@ void Exchange::checkAssert(qpid::client::AsyncSession& session, CheckMode mode)
void Exchange::configure(const Address& address)
{
- const Variant& properties = address.getOption(NODE_PROPERTIES);
- if (!properties.isVoid()) {
- Variant::Map p = properties.asMap();
- durable = p[DURABLE];
- autoDelete = p[xamqp::AUTO_DELETE];
- type = p[xamqp::EXCHANGE_TYPE].asString();
- alternateExchange = p[xamqp::ALTERNATE_EXCHANGE].asString();
- if (!p[xamqp::ARGUMENTS].isVoid()) {
- translate(p[xamqp::ARGUMENTS].asMap(), arguments);
+ const Variant& v = address.getOption(NODE_PROPERTIES);
+ if (!v.isVoid()) {
+ Variant::Map nodeProps = v.asMap();
+ durable = nodeProps[DURABLE];
+ Variant::Map::const_iterator x = nodeProps.find(X_PROPERTIES);
+ if (x != nodeProps.end()) {
+ const Variant::Map& xProps = x->second.asMap();
+ Variant::Map passthrough;
+ for (Variant::Map::const_iterator i = xProps.begin(); i != xProps.end(); ++i) {
+ if (i->first == xamqp::AUTO_DELETE) autoDelete = i->second;
+ else if (i->first == xamqp::EXCHANGE_TYPE) type = i->second.asString();
+ else if (i->first == xamqp::ALTERNATE_EXCHANGE) alternateExchange = i->second.asString();
+ else passthrough[i->first] = i->second;
+ }
+ translate(passthrough, arguments);
}
}
}
diff --git a/cpp/src/qpid/messaging/Address.cpp b/cpp/src/qpid/messaging/Address.cpp
index 5262cec0db..ff72f62705 100644
--- a/cpp/src/qpid/messaging/Address.cpp
+++ b/cpp/src/qpid/messaging/Address.cpp
@@ -114,20 +114,36 @@ void Address::setOptions(const Variant::Map& options) { impl->options = options;
namespace{
const Variant EMPTY_VARIANT;
const std::string EMPTY_STRING;
+const std::string NODE_PROPERTIES="node-properties";
+}
+
+const Variant& find(const Variant::Map& map, const std::string& key)
+{
+ Variant::Map::const_iterator i = map.find(key);
+ if (i == map.end()) return EMPTY_VARIANT;
+ else return i->second;
}
std::string Address::getType() const
{
- const Variant& type = getOption(TYPE);
- return type.isVoid() ? EMPTY_STRING : type.asString();
+ const Variant& props = getOption(NODE_PROPERTIES);
+ if (props.getType() == VAR_MAP) {
+ const Variant& type = find(props.asMap(), TYPE);
+ if (!type.isVoid()) return type.asString();
+ }
+ return EMPTY_STRING;
+}
+
+void Address::setType(const std::string& type)
+{
+ Variant& props = impl->options[NODE_PROPERTIES];
+ if (props.isVoid()) props = Variant::Map();
+ props.asMap()[TYPE] = type;
}
-void Address::setType(const std::string& type) { impl->options[TYPE] = type; }
const Variant& Address::getOption(const std::string& key) const
{
- Variant::Map::const_iterator i = impl->options.find(key);
- if (i == impl->options.end()) return EMPTY_VARIANT;
- else return i->second;
+ return find(impl->options, key);
}
std::ostream& operator<<(std::ostream& out, const Address& address)
@@ -144,7 +160,7 @@ AddressParser::AddressParser(const std::string& s) : input(s), current(0) {}
bool AddressParser::error(const std::string& message)
{
- throw MalformedAddress(message);//TODO: add more debug detail to error message (position etc)
+ throw MalformedAddress((boost::format("%1%, character %2% of %3%") % message % current % input).str());
}
bool AddressParser::parse(Address& address)
@@ -210,7 +226,7 @@ bool AddressParser::readKeyValuePair(Variant::Map& map)
map[key] = value;
return true;
} else {
- return error("Bad key-value pair!");
+ return error("Bad key-value pair, expected ':'");
}
} else {
return false;