http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/327f358e/proton-c/bindings/cpp/src/Message.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Message.cpp 
b/proton-c/bindings/cpp/src/Message.cpp
index f422202..540ba15 100644
--- a/proton-c/bindings/cpp/src/Message.cpp
+++ b/proton-c/bindings/cpp/src/Message.cpp
@@ -20,411 +20,209 @@
  */
 
 #include "proton/Message.hpp"
-#include "proton/exceptions.hpp"
+#include "proton/Error.hpp"
+#include "proton/message.h"
 #include "Msg.hpp"
+#include "proton_bits.hpp"
 #include "ProtonImplRef.hpp"
 
 #include <cstring>
 
 namespace proton {
-namespace reactor {
 
+namespace reactor {
 template class ProtonHandle<pn_message_t>;
-typedef ProtonImplRef<Message> PI;
+}
+typedef reactor::ProtonImplRef<Message> PI;
 
-Message::Message() {
+Message::Message() : body_(0) {
     PI::ctor(*this, 0);
 }
-Message::Message(pn_message_t *p) {
+Message::Message(pn_message_t *p) : body_(0) {
     PI::ctor(*this, p);
 }
-Message::Message(const Message& m) : ProtonHandle<pn_message_t>() {
+Message::Message(const Message& m) : ProtonHandle<pn_message_t>(), body_(0) {
     PI::copy(*this, m);
 }
+
+// FIXME aconway 2015-06-17: Message should be a value type, needs to own 
pn_message_t
+// and do appropriate _copy and _free operations.
 Message& Message::operator=(const Message& m) {
     return PI::assign(*this, m);
 }
 Message::~Message() { PI::dtor(*this); }
 
 namespace {
-void confirm(pn_message_t *&p) {
+void confirm(pn_message_t * const&  p) {
     if (p) return;
-    p = pn_message(); // Correct refcount of 1
+    const_cast<pn_message_t*&>(p) = pn_message(); // Correct refcount of 1
     if (!p)
-        throw ProtonException(MSG("No memory"));
-}
-
-void getFormatedStringContent(pn_data_t *data, std::string &str) {
-    pn_data_rewind(data);
-    size_t sz = str.capacity();
-    if (sz < 512) sz = 512;
-    while (true) {
-        str.resize(sz);
-        int err = pn_data_format(data, (char *) str.data(), &sz);
-        if (err) {
-            if (err != PN_OVERFLOW)
-                throw ProtonException(MSG("Unexpected message body data 
error"));
-        }
-        else {
-            str.resize(sz);
-            return;
-        }
-        sz *= 2;
-    }
-}
-
-} // namespace
-
-void Message::setId(uint64_t id) {
-    confirm(impl);
-    pn_data_t *data = pn_message_id(impl);
-    pn_data_clear(data);
-    if (int err = pn_data_put_ulong(data, id))
-        throw ProtonException(MSG("setId error " << err));
+        throw Error(MSG("No memory"));
 }
 
-uint64_t Message::getId() {
-    confirm(impl);
-    pn_data_t *data = pn_message_id(impl);
-    pn_data_rewind(data);
-    if (pn_data_size(data) == 1 && pn_data_next(data) && pn_data_type(data) == 
PN_ULONG) {
-        return pn_data_get_ulong(data);
-    }
-    throw ProtonException(MSG("Message ID is not a ULONG"));
+void check(int err) {
+    if (err) throw Error(errorStr(err));
 }
 
-void Message::setId(const std::string &id) {
-    confirm(impl);
-    pn_data_t *data = pn_message_id(impl);
-    pn_data_clear(data);
-    if (int err = pn_data_put_string(data, pn_bytes(id.size(), id.data())))
-        throw ProtonException(MSG("setId error " << err));
+void setValue(pn_data_t* d, const Value& v) {
+    Values values(d);
+    values.clear();
+    values << v;
 }
 
-std::string Message::getStringId() {
-    confirm(impl);
-    pn_data_t *data = pn_message_id(impl);
-    pn_data_rewind(data);
-    if (pn_data_size(data) == 1 && pn_data_next(data) && pn_data_type(data) == 
PN_STRING) {
-        pn_bytes_t bytes = pn_data_get_string(data);
-        return (std::string(bytes.start, bytes.size));
-    }
-    throw ProtonException(MSG("Message ID is not a string value"));
+Value getValue(pn_data_t* d) {
+    Values values(d);
+    values.rewind();
+    return values.get<Value>();
 }
+} // namespace
 
-void Message::setId(const char *p, size_t len) {
+void Message::id(const Value& id) {
     confirm(impl);
-    pn_data_t *data = pn_message_id(impl);
-    pn_data_clear(data);
-    if (int err = pn_data_put_binary(data, pn_bytes(len, p)))
-        throw ProtonException(MSG("setId error " << err));
+    setValue(pn_message_id(impl), id);
 }
 
-size_t Message::getId(const char **p) {
+Value Message::id() const {
     confirm(impl);
-    pn_data_t *data = pn_message_id(impl);
-    pn_data_rewind(data);
-    if (pn_data_size(data) == 1 && pn_data_next(data) && pn_data_type(data) == 
PN_BINARY) {
-        pn_bytes_t pnb = pn_data_get_binary(data);
-        *p = pnb.start;
-        return pnb.size;
-    }
-    throw ProtonException(MSG("Message ID is not a binary value"));
+    return getValue(pn_message_id(impl));
 }
-
-pn_type_t Message::getIdType() {
+void Message::user(const std::string &id) {
     confirm(impl);
-    pn_data_t *data = pn_message_id(impl);
-    pn_data_rewind(data);
-    if (pn_data_size(data) == 1 && pn_data_next(data)) {
-        pn_type_t type = pn_data_type(data);
-        switch (type) {
-        case PN_ULONG:
-        case PN_STRING:
-        case PN_BINARY:
-        case PN_UUID:
-            return type;
-            break;
-        default:
-            break;
-        }
-    }
-    return PN_NULL;
+    check(pn_message_set_user_id(impl, pn_bytes(id)));
 }
 
-void Message::setUserId(const std::string &id) {
+std::string Message::user() const {
     confirm(impl);
-    if (int err = pn_message_set_user_id(impl, pn_bytes(id.size(), id.data())))
-        throw ProtonException(MSG("setUserId error " << err));
+    return str(pn_message_get_user_id(impl));
 }
 
-std::string Message::getUserId() {
+void Message::address(const std::string &addr) {
     confirm(impl);
-    pn_bytes_t bytes = pn_message_get_user_id(impl);
-    return (std::string(bytes.start, bytes.size));
+    check(pn_message_set_address(impl, addr.c_str()));
 }
 
-void Message::setAddress(const std::string &addr) {
-    confirm(impl);
-    if (int err = pn_message_set_address(impl, addr.c_str()))
-        throw ProtonException(MSG("setAddress error " << err));
-}
-
-std::string Message::getAddress() {
+std::string Message::address() const {
     confirm(impl);
     const char* addr = pn_message_get_address(impl);
     return addr ? std::string(addr) : std::string();
 }
 
-void Message::setSubject(const std::string &s) {
+void Message::subject(const std::string &s) {
     confirm(impl);
-    if (int err = pn_message_set_subject(impl, s.c_str()))
-        throw ProtonException(MSG("setSubject error " << err));
+    check(pn_message_set_subject(impl, s.c_str()));
 }
 
-std::string Message::getSubject() {
+std::string Message::subject() const {
     confirm(impl);
     const char* s = pn_message_get_subject(impl);
     return s ? std::string(s) : std::string();
 }
 
-void Message::setReplyTo(const std::string &s) {
+void Message::replyTo(const std::string &s) {
     confirm(impl);
-    if (int err = pn_message_set_reply_to(impl, s.c_str()))
-        throw ProtonException(MSG("setReplyTo error " << err));
+    check(pn_message_set_reply_to(impl, s.c_str()));
 }
 
-std::string Message::getReplyTo() {
+std::string Message::replyTo() const {
     confirm(impl);
     const char* s = pn_message_get_reply_to(impl);
     return s ? std::string(s) : std::string();
 }
 
-void Message::setCorrelationId(uint64_t id) {
+void Message::correlationId(const Value& id) {
     confirm(impl);
-    pn_data_t *data = pn_message_correlation_id(impl);
-    pn_data_clear(data);
-    if (int err = pn_data_put_ulong(data, id))
-        throw ProtonException(MSG("setCorrelationId error " << err));
+    setValue(pn_message_correlation_id(impl), id);
 }
 
-uint64_t Message::getCorrelationId() {
+Value Message::correlationId() const {
     confirm(impl);
-    pn_data_t *data = pn_message_correlation_id(impl);
-    pn_data_rewind(data);
-    if (pn_data_size(data) == 1 && pn_data_next(data) && pn_data_type(data) == 
PN_ULONG) {
-        return pn_data_get_ulong(data);
-    }
-    throw ProtonException(MSG("Correlation ID is not a ULONG"));
+    return getValue(pn_message_correlation_id(impl));
 }
 
-void Message::setCorrelationId(const std::string &id) {
+void Message::contentType(const std::string &s) {
     confirm(impl);
-    pn_data_t *data = pn_message_correlation_id(impl);
-    pn_data_clear(data);
-    if (int err = pn_data_put_string(data, pn_bytes(id.size(), id.data())))
-        throw ProtonException(MSG("setCorrelationId error " << err));
-}
-
-std::string Message::getStringCorrelationId() {
-    confirm(impl);
-    pn_data_t *data = pn_message_correlation_id(impl);
-    pn_data_rewind(data);
-    if (pn_data_size(data) == 1 && pn_data_next(data) && pn_data_type(data) == 
PN_STRING) {
-        pn_bytes_t bytes = pn_data_get_string(data);
-        return (std::string(bytes.start, bytes.size));
-    }
-    throw ProtonException(MSG("Message ID is not a string value"));
+    check(pn_message_set_content_type(impl, s.c_str()));
 }
 
-void Message::setCorrelationId(const char *p, size_t len) {
-    confirm(impl);
-    pn_data_t *data = pn_message_correlation_id(impl);
-    pn_data_clear(data);
-    if (int err = pn_data_put_binary(data, pn_bytes(len, p)))
-        throw ProtonException(MSG("setCorrelationId error " << err));
-}
-
-size_t Message::getCorrelationId(const char **p) {
-    confirm(impl);
-    pn_data_t *data = pn_message_correlation_id(impl);
-    pn_data_rewind(data);
-    if (pn_data_size(data) == 1 && pn_data_next(data) && pn_data_type(data) == 
PN_BINARY) {
-        pn_bytes_t pnb = pn_data_get_binary(data);
-        *p = pnb.start;
-        return pnb.size;
-    }
-    throw ProtonException(MSG("Message ID is not a binary value"));
-}
-
-pn_type_t Message::getCorrelationIdType() {
-    confirm(impl);
-    pn_data_t *data = pn_message_correlation_id(impl);
-    pn_data_rewind(data);
-    if (pn_data_size(data) == 1 && pn_data_next(data)) {
-        pn_type_t type = pn_data_type(data);
-        switch (type) {
-        case PN_ULONG:
-        case PN_STRING:
-        case PN_BINARY:
-        case PN_UUID:
-            return type;
-            break;
-        default:
-            break;
-        }
-    }
-    return PN_NULL;
-}
-
-void Message::setContentType(const std::string &s) {
-    confirm(impl);
-    if (int err = pn_message_set_content_type(impl, s.c_str()))
-        throw ProtonException(MSG("setContentType error " << err));
-}
-
-std::string Message::getContentType() {
+std::string Message::contentType() const {
     confirm(impl);
     const char* s = pn_message_get_content_type(impl);
     return s ? std::string(s) : std::string();
 }
 
-void Message::setContentEncoding(const std::string &s) {
+void Message::contentEncoding(const std::string &s) {
     confirm(impl);
-    if (int err = pn_message_set_content_encoding(impl, s.c_str()))
-        throw ProtonException(MSG("setContentEncoding error " << err));
+    check(pn_message_set_content_encoding(impl, s.c_str()));
 }
 
-std::string Message::getContentEncoding() {
+std::string Message::contentEncoding() const {
     confirm(impl);
     const char* s = pn_message_get_content_encoding(impl);
     return s ? std::string(s) : std::string();
 }
 
-void Message::setExpiry(pn_timestamp_t t) {
+void Message::expiry(Timestamp t) {
     confirm(impl);
-    pn_message_set_expiry_time(impl, t);
+    pn_message_set_expiry_time(impl, t.milliseconds);
 }
-pn_timestamp_t Message::getExpiry() {
+Timestamp Message::expiry() const {
     confirm(impl);
-    return pn_message_get_expiry_time(impl);
+    return Timestamp(pn_message_get_expiry_time(impl));
 }
 
-void Message::setCreationTime(pn_timestamp_t t) {
+void Message::creationTime(Timestamp t) {
     confirm(impl);
     pn_message_set_creation_time(impl, t);
 }
-pn_timestamp_t Message::getCreationTime() {
+Timestamp Message::creationTime() const {
     confirm(impl);
     return pn_message_get_creation_time(impl);
 }
 
-
-void Message::setGroupId(const std::string &s) {
+void Message::groupId(const std::string &s) {
     confirm(impl);
-    if (int err = pn_message_set_group_id(impl, s.c_str()))
-        throw ProtonException(MSG("setGroupId error " << err));
+    check(pn_message_set_group_id(impl, s.c_str()));
 }
 
-std::string Message::getGroupId() {
+std::string Message::groupId() const {
     confirm(impl);
     const char* s = pn_message_get_group_id(impl);
     return s ? std::string(s) : std::string();
 }
 
-void Message::setReplyToGroupId(const std::string &s) {
+void Message::replyToGroupId(const std::string &s) {
     confirm(impl);
-    if (int err = pn_message_set_reply_to_group_id(impl, s.c_str()))
-        throw ProtonException(MSG("setReplyToGroupId error " << err));
+    check(pn_message_set_reply_to_group_id(impl, s.c_str()));
 }
 
-std::string Message::getReplyToGroupId() {
+std::string Message::replyToGroupId() const {
     confirm(impl);
     const char* s = pn_message_get_reply_to_group_id(impl);
     return s ? std::string(s) : std::string();
 }
 
-
-void Message::setBody(const std::string &buf) {
+void Message::body(const Value& v) {
     confirm(impl);
-    pn_data_t *body = pn_message_body(impl);
-    pn_data_clear(body);
-    pn_data_put_string(body, pn_bytes(buf.size(), buf.data()));
+    setValue(pn_message_body(impl), v);
 }
 
-void Message::getBody(std::string &str) {
-    // User supplied string/buffer
+void Message::body(const Values& v) {
     confirm(impl);
-    pn_data_t *body = pn_message_body(impl);
-    pn_data_rewind(body);
-
-    if (pn_data_next(body) && pn_data_type(body) == PN_STRING) {
-        pn_bytes_t bytes = pn_data_get_string(body);
-        if (!pn_data_next(body)) {
-            // String data and nothing else
-            str.resize(bytes.size);
-            memmove((void *) str.data(), bytes.start, bytes.size);
-            return;
-        }
-    }
-
-    getFormatedStringContent(body, str);
-}
-
-std::string Message::getBody() {
-    confirm(impl);
-    pn_data_t *body = pn_message_body(impl);
-    pn_data_rewind(body);
-
-    if (pn_data_next(body) && pn_data_type(body) == PN_STRING) {
-        pn_bytes_t bytes= pn_data_get_string(body);
-        if (!pn_data_next(body)) {
-            // String data and nothing else
-            return std::string(bytes.start, bytes.size);
-        }
-    }
-
-    std::string str;
-    getFormatedStringContent(body, str);
-    return str;
-}
-
-void Message::setBody(const char *bytes, size_t len) {
-    confirm(impl);
-    pn_data_t *body = pn_message_body(impl);
-    pn_data_clear(body);
-    pn_data_put_binary(body, pn_bytes(len, bytes));
+    pn_data_copy(pn_message_body(impl), v.data);
 }
 
-size_t Message::getBody(char *bytes, size_t len) {
+const Values& Message::body() const {
     confirm(impl);
-    pn_data_t *body = pn_message_body(impl);
-    pn_data_rewind(body);
-    if (pn_data_size(body) == 1 && pn_data_next(body) && pn_data_type(body) == 
PN_BINARY) {
-        pn_bytes_t pnb = pn_data_get_binary(body);
-        if (len >= pnb.size) {
-            memmove(bytes, pnb.start, pnb.size);
-            return pnb.size;
-        }
-        throw ProtonException(MSG("Binary buffer too small"));
-    }
-    throw ProtonException(MSG("Not simple binary data"));
+    body_.view(pn_message_body(impl));
+    return body_;
 }
 
-
-
-size_t Message::getBinaryBodySize() {
+Values& Message::body() {
     confirm(impl);
-    pn_data_t *body = pn_message_body(impl);
-    pn_data_rewind(body);
-    if (pn_data_size(body) == 1 && pn_data_next(body) && pn_data_type(body) == 
PN_BINARY) {
-        pn_bytes_t bytes = pn_data_get_binary(body);
-        return bytes.size;
-    }
-    return 0;
+    body_.view(pn_message_body(impl));
+    return body_;
 }
 
-
 void Message::encode(std::string &s) {
     confirm(impl);
     size_t sz = s.capacity();
@@ -434,7 +232,7 @@ void Message::encode(std::string &s) {
         int err = pn_message_encode(impl, (char *) s.data(), &sz);
         if (err) {
             if (err != PN_OVERFLOW)
-                throw ProtonException(MSG("unexpected error"));
+                check(err);
         } else {
             s.resize(sz);
             return;
@@ -445,12 +243,11 @@ void Message::encode(std::string &s) {
 
 void Message::decode(const std::string &s) {
     confirm(impl);
-    int err = pn_message_decode(impl, s.data(), s.size());
-    if (err) throw ProtonException(MSG("unexpected error"));
+    check(pn_message_decode(impl, s.data(), s.size()));
 }
 
-pn_message_t *Message::getPnMessage() const {
+pn_message_t *Message::pnMessage() const {
     return impl;
 }
 
-}} // namespace proton::reactor
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/327f358e/proton-c/bindings/cpp/src/MessagingAdapter.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/MessagingAdapter.cpp 
b/proton-c/bindings/cpp/src/MessagingAdapter.cpp
index 7c3ba6c..3b4152d 100644
--- a/proton-c/bindings/cpp/src/MessagingAdapter.cpp
+++ b/proton-c/bindings/cpp/src/MessagingAdapter.cpp
@@ -21,7 +21,7 @@
 #include "proton/MessagingAdapter.hpp"
 #include "proton/MessagingEvent.hpp"
 #include "proton/Sender.hpp"
-#include "proton/exceptions.hpp"
+#include "proton/Error.hpp"
 #include "Msg.hpp"
 
 #include "proton/link.h"
@@ -69,7 +69,7 @@ Message receiveMessage(pn_link_t *lnk, pn_delivery_t *dlv) {
     buf.resize(sz);
     ssize_t n = pn_link_recv(lnk, (char *) buf.data(), sz);
     if (n != (ssize_t) sz)
-        throw ProtonException(MSG("link read failure"));
+        throw Error(MSG("link read failure"));
     Message m;
     m. decode(buf);
     pn_link_advance(lnk);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/327f358e/proton-c/bindings/cpp/src/MessagingEvent.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/MessagingEvent.cpp 
b/proton-c/bindings/cpp/src/MessagingEvent.cpp
index fc20e2b..083180a 100644
--- a/proton-c/bindings/cpp/src/MessagingEvent.cpp
+++ b/proton-c/bindings/cpp/src/MessagingEvent.cpp
@@ -27,7 +27,7 @@
 #include "proton/Message.hpp"
 #include "proton/ProtonHandler.hpp"
 #include "proton/MessagingHandler.hpp"
-#include "proton/exceptions.hpp"
+#include "proton/Error.hpp"
 #include "Msg.hpp"
 #include "contexts.hpp"
 
@@ -41,7 +41,7 @@ MessagingEvent::MessagingEvent(pn_event_t *ce, 
pn_event_type_t t, Container &c)
 MessagingEvent::MessagingEvent(MessagingEventType_t t, ProtonEvent &p) :
     ProtonEvent(NULL, PN_EVENT_NONE, p.getContainer()), messagingType(t), 
parentEvent(&p), message(0) {
     if (messagingType == PN_MESSAGING_PROTON)
-        throw ProtonException(MSG("invalid messaging event type"));
+        throw Error(MSG("invalid messaging event type"));
 }
 
 MessagingEvent::~MessagingEvent() {
@@ -53,7 +53,7 @@ Connection &MessagingEvent::getConnection() {
         return ProtonEvent::getConnection();
     if (parentEvent)
         return parentEvent->getConnection();
-    throw ProtonException(MSG("No connection context for event"));
+    throw Error(MSG("No connection context for event"));
 }
 
 Sender MessagingEvent::getSender() {
@@ -61,7 +61,7 @@ Sender MessagingEvent::getSender() {
         return ProtonEvent::getSender();
     if (parentEvent)
         return parentEvent->getSender();
-    throw ProtonException(MSG("No sender context for event"));
+    throw Error(MSG("No sender context for event"));
 }
 
 Receiver MessagingEvent::getReceiver() {
@@ -69,7 +69,7 @@ Receiver MessagingEvent::getReceiver() {
         return ProtonEvent::getReceiver();
     if (parentEvent)
         return parentEvent->getReceiver();
-    throw ProtonException(MSG("No receiver context for event"));
+    throw Error(MSG("No receiver context for event"));
 }
 
 Link MessagingEvent::getLink() {
@@ -77,7 +77,7 @@ Link MessagingEvent::getLink() {
         return ProtonEvent::getLink();
     if (parentEvent)
         return parentEvent->getLink();
-    throw ProtonException(MSG("No link context for event"));
+    throw Error(MSG("No link context for event"));
 }
 
 Message MessagingEvent::getMessage() {
@@ -86,13 +86,13 @@ Message MessagingEvent::getMessage() {
         if (m)
             return Message(m);
     }
-    throw ProtonException(MSG("No message context for event"));
+    throw Error(MSG("No message context for event"));
 }
 
 void MessagingEvent::setMessage(Message &m) {
     if (messagingType != PN_MESSAGING_MESSAGE || !parentEvent)
-        throw ProtonException(MSG("Event type does not provide message"));
-    setEventContext(parentEvent->getPnEvent(), m.getPnMessage());
+        throw Error(MSG("Event type does not provide message"));
+    setEventContext(parentEvent->getPnEvent(), m.pnMessage());
 }
 
 void MessagingEvent::dispatch(Handler &h) {
@@ -133,7 +133,7 @@ void MessagingEvent::dispatch(Handler &h) {
 
         case PN_MESSAGING_TRANSPORT_CLOSED:       
handler->onTransportClosed(*this); break;
         default:
-            throw ProtonException(MSG("Unkown messaging event type " << 
messagingType));
+            throw Error(MSG("Unkown messaging event type " << messagingType));
             break;
         }
     } else {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/327f358e/proton-c/bindings/cpp/src/ProtonEvent.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ProtonEvent.cpp 
b/proton-c/bindings/cpp/src/ProtonEvent.cpp
index 4567ea7..8d32f35 100644
--- a/proton-c/bindings/cpp/src/ProtonEvent.cpp
+++ b/proton-c/bindings/cpp/src/ProtonEvent.cpp
@@ -25,7 +25,7 @@
 
 #include "proton/ProtonEvent.hpp"
 #include "proton/ProtonHandler.hpp"
-#include "proton/exceptions.hpp"
+#include "proton/Error.hpp"
 #include "proton/Container.hpp"
 
 #include "ConnectionImpl.hpp"
@@ -50,7 +50,7 @@ Container &ProtonEvent::getContainer() { return container; }
 Connection &ProtonEvent::getConnection() {
     pn_connection_t *conn = pn_event_connection(getPnEvent());
     if (!conn)
-        throw ProtonException(MSG("No connection context for this event"));
+        throw Error(MSG("No connection context for this event"));
     return ConnectionImpl::getReactorReference(conn);
 }
 
@@ -58,14 +58,14 @@ Sender ProtonEvent::getSender() {
     pn_link_t *lnk = pn_event_link(getPnEvent());
     if (lnk && pn_link_is_sender(lnk))
         return Sender(lnk);
-    throw ProtonException(MSG("No sender context for this event"));
+    throw Error(MSG("No sender context for this event"));
 }
 
 Receiver ProtonEvent::getReceiver() {
     pn_link_t *lnk = pn_event_link(getPnEvent());
     if (lnk && pn_link_is_receiver(lnk))
         return Receiver(lnk);
-    throw ProtonException(MSG("No receiver context for this event"));
+    throw Error(MSG("No receiver context for this event"));
 }
 
 Link ProtonEvent::getLink() {
@@ -76,7 +76,7 @@ Link ProtonEvent::getLink() {
         else
             return Receiver(lnk);
     }
-    throw ProtonException(MSG("No link context for this event"));
+    throw Error(MSG("No link context for this event"));
 }
 
 
@@ -136,7 +136,7 @@ void ProtonEvent::dispatch(Handler &h) {
         case PN_SELECTABLE_ERROR: handler->onSelectableError(*this); break;
         case PN_SELECTABLE_FINAL: handler->onSelectableFinal(*this); break;
         default:
-            throw ProtonException(MSG("Invalid Proton event type " << type));
+            throw Error(MSG("Invalid Proton event type " << type));
             break;
         }
     } else {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/327f358e/proton-c/bindings/cpp/src/Receiver.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Receiver.cpp 
b/proton-c/bindings/cpp/src/Receiver.cpp
index d148372..b46ab87 100644
--- a/proton-c/bindings/cpp/src/Receiver.cpp
+++ b/proton-c/bindings/cpp/src/Receiver.cpp
@@ -20,7 +20,7 @@
  */
 #include "proton/Link.hpp"
 #include "proton/Receiver.hpp"
-#include "proton/exceptions.hpp"
+#include "proton/Error.hpp"
 #include "Msg.hpp"
 
 #include "proton/connection.h"
@@ -38,7 +38,7 @@ Receiver::Receiver(const Link& c) : Link(c.getPnLink()) {}
 
 void Receiver::verifyType(pn_link_t *lnk) {
     if (lnk && pn_link_is_sender(lnk))
-        throw ProtonException(MSG("Creating receiver with sender context"));
+        throw Error(MSG("Creating receiver with sender context"));
 }
 
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/327f358e/proton-c/bindings/cpp/src/Sender.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Sender.cpp 
b/proton-c/bindings/cpp/src/Sender.cpp
index 8c2e414..11fa3c8 100644
--- a/proton-c/bindings/cpp/src/Sender.cpp
+++ b/proton-c/bindings/cpp/src/Sender.cpp
@@ -20,7 +20,7 @@
  */
 #include "proton/Link.hpp"
 #include "proton/Sender.hpp"
-#include "proton/exceptions.hpp"
+#include "proton/Error.hpp"
 #include "Msg.hpp"
 #include "contexts.hpp"
 
@@ -43,7 +43,7 @@ Sender::Sender() : Link(0) {}
 
 void Sender::verifyType(pn_link_t *lnk) {
     if (lnk && pn_link_is_receiver(lnk))
-        throw ProtonException(MSG("Creating sender with receiver context"));
+        throw Error(MSG("Creating sender with receiver context"));
 }
 
 Sender::Sender(const Link& c) : Link(c.getPnLink()) {}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/327f358e/proton-c/bindings/cpp/src/Url.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Url.cpp 
b/proton-c/bindings/cpp/src/Url.cpp
index 80020fb..60ab58d 100644
--- a/proton-c/bindings/cpp/src/Url.cpp
+++ b/proton-c/bindings/cpp/src/Url.cpp
@@ -19,7 +19,7 @@
  *
  */
 
-#include "proton/exceptions.hpp"
+#include "proton/Error.hpp"
 #include "Url.hpp"
 #include "ProtonImplRef.hpp"
 #include "Msg.hpp"
@@ -35,7 +35,7 @@ Url::Url(const std::string &url) {
     pn_url_t *up = pn_url_parse(url.c_str());
     // refcount is 1, no need to incref
     if (!up)
-        throw ProtonException(MSG("invalid URL: " << url));
+        throw Error(MSG("invalid URL: " << url));
     impl = up;
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/327f358e/proton-c/bindings/cpp/src/Value.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Value.cpp 
b/proton-c/bindings/cpp/src/Value.cpp
index 6d0a55c..cf41175 100644
--- a/proton-c/bindings/cpp/src/Value.cpp
+++ b/proton-c/bindings/cpp/src/Value.cpp
@@ -24,11 +24,11 @@
 #include <algorithm>
 
 namespace proton {
-namespace reactor {
 
 Value::Value() { *this = Null(); }
 Value::Value(const Value& v) { *this = v; }
 Value::~Value() {}
+
 Value& Value::operator=(const Value& v) { values = v.values; return *this; }
 
 TypeId Value::type() const {
@@ -39,7 +39,7 @@ TypeId Value::type() const {
 namespace {
 template <class T> T check(T result) {
     if (result < 0)
-        throw Encoder::Error("encode: " + errorStr(result));
+        throw EncodeError("encode: " + errorStr(result));
     return result;
 }
 }
@@ -133,4 +133,4 @@ bool Value::operator<(const Value& v) const {
     return compareNext(values, v.values) < 0;
 }
 
-}}
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/327f358e/proton-c/bindings/cpp/src/Values.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Values.cpp 
b/proton-c/bindings/cpp/src/Values.cpp
index fadfacf..95e5784 100644
--- a/proton-c/bindings/cpp/src/Values.cpp
+++ b/proton-c/bindings/cpp/src/Values.cpp
@@ -23,10 +23,11 @@
 #include <ostream>
 
 namespace proton {
-namespace reactor {
 
 Values::Values() {}
 Values::Values(const Values& v) { *this = v; }
+Values::Values(pn_data_t* d) : Data(d) {}
+
 Values::~Values() {}
 Values& Values::operator=(const Values& v) { Data::operator=(v); return *this; 
}
 
@@ -36,4 +37,4 @@ std::ostream& operator<<(std::ostream& o, const Values& v) {
     return o << static_cast<const Encoder&>(v);
 }
 
-}}
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/327f358e/proton-c/bindings/cpp/src/blocking/BlockingConnection.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking/BlockingConnection.cpp 
b/proton-c/bindings/cpp/src/blocking/BlockingConnection.cpp
index 95499d6..3e57b91 100644
--- a/proton-c/bindings/cpp/src/blocking/BlockingConnection.cpp
+++ b/proton-c/bindings/cpp/src/blocking/BlockingConnection.cpp
@@ -22,7 +22,7 @@
 #include "proton/BlockingConnection.hpp"
 #include "proton/BlockingSender.hpp"
 #include "proton/MessagingHandler.hpp"
-#include "proton/exceptions.hpp"
+#include "proton/Error.hpp"
 #include "Msg.hpp"
 #include "BlockingConnectionImpl.hpp"
 #include "PrivateImplRef.hpp"

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/327f358e/proton-c/bindings/cpp/src/blocking/BlockingConnectionImpl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking/BlockingConnectionImpl.cpp 
b/proton-c/bindings/cpp/src/blocking/BlockingConnectionImpl.cpp
index 7bb1261..912f11f 100644
--- a/proton-c/bindings/cpp/src/blocking/BlockingConnectionImpl.cpp
+++ b/proton-c/bindings/cpp/src/blocking/BlockingConnectionImpl.cpp
@@ -21,7 +21,7 @@
 #include "proton/Container.hpp"
 #include "proton/MessagingHandler.hpp"
 #include "proton/Duration.hpp"
-#include "proton/exceptions.hpp"
+#include "proton/Error.hpp"
 #include "proton/WaitCondition.hpp"
 #include "BlockingConnectionImpl.hpp"
 #include "Msg.hpp"
@@ -98,10 +98,10 @@ void BlockingConnectionImpl::wait(WaitCondition &condition, 
std::string &msg, Du
 
     pn_reactor_t *reactor = container.getReactor();
     pn_millis_t origTimeout = pn_reactor_get_timeout(reactor);
-    pn_reactor_set_timeout(reactor, waitTimeout.getMilliseconds());
+    pn_reactor_set_timeout(reactor, waitTimeout.milliseconds);
     try {
         pn_timestamp_t now = pn_reactor_mark(reactor);
-        pn_timestamp_t deadline = now + waitTimeout.getMilliseconds();
+        pn_timestamp_t deadline = now + waitTimeout.milliseconds;
         while (!condition.achieved()) {
             container.process();
             if (deadline < pn_reactor_mark(reactor)) {
@@ -109,7 +109,7 @@ void BlockingConnectionImpl::wait(WaitCondition &condition, 
std::string &msg, Du
                 if (!msg.empty())
                     txt += ": " + msg;
                 // TODO: proper Timeout exception
-                throw ProtonException(MSG(txt));
+                throw Error(MSG(txt));
             }
         }
     } catch (...) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/327f358e/proton-c/bindings/cpp/src/blocking/BlockingLink.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking/BlockingLink.cpp 
b/proton-c/bindings/cpp/src/blocking/BlockingLink.cpp
index 9dfc844..afc5f35 100644
--- a/proton-c/bindings/cpp/src/blocking/BlockingLink.cpp
+++ b/proton-c/bindings/cpp/src/blocking/BlockingLink.cpp
@@ -22,7 +22,7 @@
 #include "proton/BlockingConnection.hpp"
 #include "proton/MessagingHandler.hpp"
 #include "proton/WaitCondition.hpp"
-#include "proton/exceptions.hpp"
+#include "proton/Error.hpp"
 #include "Msg.hpp"
 
 
@@ -72,7 +72,7 @@ void BlockingLink::checkClosed() {
     if (pn_link_state(pnLink) & PN_REMOTE_CLOSED) {
         link.close();
         // TODO: LinkDetached exception
-        throw ProtonException(MSG("Link detached"));
+        throw Error(MSG("Link detached"));
     }
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/327f358e/proton-c/bindings/cpp/src/blocking/BlockingSender.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking/BlockingSender.cpp 
b/proton-c/bindings/cpp/src/blocking/BlockingSender.cpp
index ac37477..7a24324 100644
--- a/proton-c/bindings/cpp/src/blocking/BlockingSender.cpp
+++ b/proton-c/bindings/cpp/src/blocking/BlockingSender.cpp
@@ -21,7 +21,7 @@
 #include "proton/BlockingSender.hpp"
 #include "proton/BlockingConnection.hpp"
 #include "proton/WaitCondition.hpp"
-#include "proton/exceptions.hpp"
+#include "proton/Error.hpp"
 #include "Msg.hpp"
 
 
@@ -45,7 +45,7 @@ BlockingSender::BlockingSender(BlockingConnection &c, Sender 
&l) : BlockingLink(
         waitForClosed();
         link.close();
         std::string txt = "Failed to open sender " + link.getName() + ", 
target does not match";
-        throw ProtonException(MSG("Container not started"));
+        throw Error(MSG("Container not started"));
     }
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/327f358e/proton-c/bindings/cpp/src/contexts.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/contexts.cpp 
b/proton-c/bindings/cpp/src/contexts.cpp
index 28f4778..fd2f3e1 100644
--- a/proton-c/bindings/cpp/src/contexts.cpp
+++ b/proton-c/bindings/cpp/src/contexts.cpp
@@ -20,7 +20,7 @@
  */
 
 #include "contexts.hpp"
-#include "proton/exceptions.hpp"
+#include "proton/Error.hpp"
 #include "Msg.hpp"
 #include "proton/object.h"
 #include "proton/message.h"
@@ -55,7 +55,7 @@ void setContainerContext(pn_reactor_t *pnReactor, 
ContainerImpl *container) {
 ContainerImpl *getContainerContext(pn_reactor_t *pnReactor) {
     pn_record_t *record = pn_reactor_attachments(pnReactor);
     ContainerImpl *p = (ContainerImpl *) pn_record_get(record, 
PNI_CPP_CONTAINER_CONTEXT);
-    if (!p) throw ProtonException(MSG("Reactor has no C++ container context"));
+    if (!p) throw Error(MSG("Reactor has no C++ container context"));
     return p;
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/327f358e/proton-c/bindings/cpp/src/interop_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/interop_test.cpp 
b/proton-c/bindings/cpp/src/interop_test.cpp
index 122e983..db309f7 100644
--- a/proton-c/bindings/cpp/src/interop_test.cpp
+++ b/proton-c/bindings/cpp/src/interop_test.cpp
@@ -30,6 +30,7 @@
 #include <unistd.h>
 
 using namespace std;
+using namespace proton;
 using namespace proton::reactor;
 
 std::string testsDir;
@@ -66,22 +67,22 @@ void testDataOstream() {
 void testDecoderPrimitvesExact() {
     Decoder d(read("primitives"));
     ASSERT(d.more());
-    try { get<int8_t>(d); FAIL("got bool as byte"); } catch(Decoder::Error){}
+    try { get<int8_t>(d); FAIL("got bool as byte"); } catch(DecodeError){}
     ASSERT_EQUAL(true, get<bool>(d));
     ASSERT_EQUAL(false, get<bool>(d));
-    try { get<int8_t>(d); FAIL("got ubyte as byte"); } catch(Decoder::Error){}
+    try { get<int8_t>(d); FAIL("got ubyte as byte"); } catch(DecodeError){}
     ASSERT_EQUAL(42, get<uint8_t>(d));
-    try { get<int32_t>(d); FAIL("got uint as ushort"); } 
catch(Decoder::Error){}
+    try { get<int32_t>(d); FAIL("got uint as ushort"); } catch(DecodeError){}
     ASSERT_EQUAL(42, get<uint16_t>(d));
-    try { get<uint16_t>(d); FAIL("got short as ushort"); } 
catch(Decoder::Error){}
+    try { get<uint16_t>(d); FAIL("got short as ushort"); } catch(DecodeError){}
     ASSERT_EQUAL(-42, get<int16_t>(d));
     ASSERT_EQUAL(12345, get<uint32_t>(d));
     ASSERT_EQUAL(-12345, get<int32_t>(d));
     ASSERT_EQUAL(12345, get<uint64_t>(d));
     ASSERT_EQUAL(-12345, get<int64_t>(d));
-    try { get<double>(d); FAIL("got float as double"); } 
catch(Decoder::Error){}
+    try { get<double>(d); FAIL("got float as double"); } catch(DecodeError){}
     ASSERT_EQUAL(0.125, get<float>(d));
-    try { get<float>(d); FAIL("got double as float"); } catch(Decoder::Error){}
+    try { get<float>(d); FAIL("got double as float"); } catch(DecodeError){}
     ASSERT_EQUAL(0.125, get<double>(d));
     ASSERT(!d.more());
 }
@@ -109,8 +110,8 @@ void testValueConversions() {
     ASSERT_EQUAL(3, long(v=Byte(3)));
     ASSERT_EQUAL(1.0, double(v=Float(1.0)));
     ASSERT_EQUAL(1.0, float(v=Double(1.0)));
-    try { bool(v = Byte(1)); FAIL("got byte as bool"); } catch 
(Decoder::Error) {}
-    try { float(v = true); FAIL("got bool as float"); } catch (Decoder::Error) 
{}
+    try { bool(v = Byte(1)); FAIL("got byte as bool"); } catch (DecodeError) {}
+    try { float(v = true); FAIL("got bool as float"); } catch (DecodeError) {}
 }
 
 int run_test(void (*testfn)(), const char* name) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/327f358e/proton-c/bindings/cpp/src/proton_bits.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_bits.cpp 
b/proton-c/bindings/cpp/src/proton_bits.cpp
index 6a85b1d..e06589c 100644
--- a/proton-c/bindings/cpp/src/proton_bits.cpp
+++ b/proton-c/bindings/cpp/src/proton_bits.cpp
@@ -47,7 +47,7 @@ std::string errorStr(pn_error_t* err, int code) {
     return errorStr(code);
 }
 
-std::ostream& operator<<(std::ostream& o, const Object& object) {
+std::ostream& operator<<(std::ostream& o, const PnObject& object) {
     pn_string_t* str = pn_string("");
     pn_inspect(object.value, str);
     o << pn_string_get(str);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/327f358e/proton-c/bindings/cpp/src/proton_bits.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_bits.hpp 
b/proton-c/bindings/cpp/src/proton_bits.hpp
index e57f188..55c6473 100644
--- a/proton-c/bindings/cpp/src/proton_bits.hpp
+++ b/proton-c/bindings/cpp/src/proton_bits.hpp
@@ -33,10 +33,10 @@ std::string errorStr(int code);
 std::string errorStr(pn_error_t*, int code=0);
 
 /** Wrapper for a proton object pointer. */
-struct Object { void* value; Object(void* o) : value(o) {} };
+struct PnObject { void* value; PnObject(void* o) : value(o) {} };
 
 /** Stream a proton object via pn_inspect. */
-std::ostream& operator<<(std::ostream& o, const Object& object);
+std::ostream& operator<<(std::ostream& o, const PnObject& object);
 
 
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/327f358e/proton-c/bindings/cpp/src/types.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/types.cpp 
b/proton-c/bindings/cpp/src/types.cpp
index 1998b97..593d052 100644
--- a/proton-c/bindings/cpp/src/types.cpp
+++ b/proton-c/bindings/cpp/src/types.cpp
@@ -22,7 +22,6 @@
 #include <ostream>
 
 namespace proton {
-namespace reactor {
 
 std::string typeName(TypeId t) {
     switch (t) {
@@ -66,6 +65,8 @@ pn_bytes_t pn_bytes(const std::string& s) {
     return b;
 }
 
+std::string str(const pn_bytes_t& b) { return std::string(b.start, b.size); }
+
 pn_uuid_t pn_uuid(const std::string& s) {
     pn_uuid_t u = {0};          // Zero initialized.
     std::copy(s.begin(), s.begin() + std::max(s.size(), 
sizeof(pn_uuid_t::bytes)), &u.bytes[0]);
@@ -78,4 +79,4 @@ Start Start::list() { return Start(LIST); }
 Start Start::map() { return Start(MAP); }
 Start Start::described() { return Start(DESCRIBED, NULL_, true); }
 
-}}
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to