You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2016/02/26 00:36:35 UTC

[1/6] qpid-proton git commit: PROTON-1138: c++: Add proton::uuid, proton::timestamp and proton::decimal types.

Repository: qpid-proton
Updated Branches:
  refs/heads/master ce2dfd501 -> a0fa5ce23


PROTON-1138: c++: Add proton::uuid, proton::timestamp and proton::decimal types.

- removed amqp_ prefixed uuid/timestamp/decimal types.
- added proton::byte_array base class for fixed-size types with no C++ equivalent.
- Got rid of public duration::milliseconds data member.
- Gave duration and timestamp consistent accessors, constructors and operator= for milliseconds values.
- Completed duration/timestamp arithmetic.

NOTE: changed duration to use int64_t instead of uint64_t. Durations can be
added and subtracted and negative durations can occur during calculations. Also
AMQP timestamp is defined as signed so we should be consistent.

UNIX time_t is traditionally unsigned because signed 32 bits is too small to
express a useful time range after the epoch. 64 bit timestamps (and durations)
do not require this restriction, signed timestamps can express time before and
after epoch.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/71be1c69
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/71be1c69
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/71be1c69

Branch: refs/heads/master
Commit: 71be1c6912ca77aa297492b019ee0ec0736f3546
Parents: ce2dfd5
Author: Alan Conway <ac...@redhat.com>
Authored: Thu Feb 18 10:16:52 2016 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Thu Feb 25 17:47:13 2016 -0500

----------------------------------------------------------------------
 proton-c/bindings/cpp/CMakeLists.txt            |  1 +
 .../bindings/cpp/include/proton/byte_array.hpp  | 61 ++++++++++++++++++++
 .../bindings/cpp/include/proton/decimal.hpp     | 61 ++++++++++++++++++++
 .../bindings/cpp/include/proton/decoder.hpp     | 18 +++---
 .../bindings/cpp/include/proton/duration.hpp    | 31 +++++-----
 .../bindings/cpp/include/proton/encoder.hpp     | 10 ++--
 .../bindings/cpp/include/proton/message.hpp     | 10 ++--
 .../bindings/cpp/include/proton/message_id.hpp  |  8 +--
 .../bindings/cpp/include/proton/reactor.hpp     |  5 +-
 proton-c/bindings/cpp/include/proton/scalar.hpp | 27 +++++----
 .../bindings/cpp/include/proton/timestamp.hpp   | 46 +++++++++++++++
 .../bindings/cpp/include/proton/type_traits.hpp | 15 +++--
 proton-c/bindings/cpp/include/proton/types.hpp  | 46 ---------------
 proton-c/bindings/cpp/include/proton/url.hpp    |  2 +-
 proton-c/bindings/cpp/include/proton/uuid.hpp   | 54 +++++++++++++++++
 proton-c/bindings/cpp/include/proton/value.hpp  |  2 +
 proton-c/bindings/cpp/src/condition.cpp         |  1 -
 proton-c/bindings/cpp/src/connection_engine.cpp |  5 +-
 .../bindings/cpp/src/connection_options.cpp     |  2 +-
 proton-c/bindings/cpp/src/container_impl.cpp    |  4 +-
 proton-c/bindings/cpp/src/data.cpp              | 11 ++--
 proton-c/bindings/cpp/src/decimal.cpp           | 27 +++++++++
 proton-c/bindings/cpp/src/decoder.cpp           | 21 +++++--
 proton-c/bindings/cpp/src/duration.cpp          | 13 ++++-
 proton-c/bindings/cpp/src/encoder.cpp           | 24 +++++---
 proton-c/bindings/cpp/src/engine_test.cpp       |  2 +-
 proton-c/bindings/cpp/src/message.cpp           | 20 +++----
 proton-c/bindings/cpp/src/message_test.cpp      | 16 ++---
 proton-c/bindings/cpp/src/reactor.cpp           |  8 +--
 proton-c/bindings/cpp/src/reconnect_timer.cpp   |  2 +-
 proton-c/bindings/cpp/src/scalar.cpp            | 56 +++++++++++++-----
 proton-c/bindings/cpp/src/scalar_test.cpp       | 20 ++++---
 proton-c/bindings/cpp/src/types.cpp             | 30 ----------
 proton-c/bindings/cpp/src/types_internal.hpp    | 39 +++++++++++++
 proton-c/bindings/cpp/src/uuid.cpp              | 19 ++++--
 proton-c/bindings/cpp/src/uuid.hpp              | 41 -------------
 tests/tools/apps/cpp/reactor_send.cpp           |  3 +-
 37 files changed, 508 insertions(+), 253 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/CMakeLists.txt b/proton-c/bindings/cpp/CMakeLists.txt
index 86788a8..d60c551 100644
--- a/proton-c/bindings/cpp/CMakeLists.txt
+++ b/proton-c/bindings/cpp/CMakeLists.txt
@@ -36,6 +36,7 @@ set(qpid-proton-cpp-source
   src/contexts.cpp
   src/data.cpp
   src/decoder.cpp
+  src/decimal.cpp
   src/delivery.cpp
   src/duration.cpp
   src/encoder.cpp

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/include/proton/byte_array.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/byte_array.hpp b/proton-c/bindings/cpp/include/proton/byte_array.hpp
new file mode 100644
index 0000000..1319eae
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/byte_array.hpp
@@ -0,0 +1,61 @@
+#ifndef BYTE_ARRAY_HPP
+#define BYTE_ARRAY_HPP
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <proton/config.hpp>
+#include <proton/comparable.hpp>
+
+#include <algorithm>
+
+namespace proton {
+
+/// Used to represent fixed-sized data types that don't have a natural C++ representation
+/// as an array of bytes.
+template <size_t N> class byte_array : public comparable<byte_array<N> > {
+  public:
+    /// Initially all 0.
+    byte_array() : bytes_() {}
+
+    /// Returns N
+    static size_t size() { return N; }
+
+    char* begin() { return bytes_; }
+    char* end() { return bytes_+N; }
+    char& operator[](size_t i) { return bytes_[i]; }
+
+    const char* begin() const { return bytes_; }
+    const char* end() const { return bytes_+N; }
+    const char& operator[](size_t i) const { return bytes_[i]; }
+
+    friend bool operator==(const byte_array& x, const byte_array& y) {
+        return std::equal(x.begin(), x.end(), y.begin());
+    }
+
+    friend bool operator<(const byte_array& x, const byte_array& y) {
+        return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
+    }
+
+  private:
+    char bytes_[N];
+};
+
+}
+
+#endif // BYTE_ARRAY_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/include/proton/decimal.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/decimal.hpp b/proton-c/bindings/cpp/include/proton/decimal.hpp
new file mode 100644
index 0000000..ddb8ea8
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/decimal.hpp
@@ -0,0 +1,61 @@
+#ifndef DECIMAL_HPP
+#define DECIMAL_HPP
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "proton/byte_array.hpp"
+#include "proton/comparable.hpp"
+#include "proton/export.hpp"
+
+#include <proton/types.h>
+
+#include <iosfwd>
+
+namespace proton {
+
+///@name AMQP decimal types.
+///
+/// AMQP uses the standard IEEE 754-2008 encoding for decimal types.
+///
+/// This library does not provide support for decimal arithmetic but it does
+/// provide access to the byte representation of decimal values. You can pass
+/// these values uninterpreted via AMQP, or you can use a library that supports
+/// IEEE 754-2008 and make a byte-wise copy between the real decimal values and
+/// proton::decimal values.
+///
+/// @{
+
+/// 32-bit decimal floating point.
+class decimal32 : public byte_array<4> {};
+
+/// 64-bit decimal floating point.
+class decimal64 : public byte_array<8> {};
+
+/// 128-bit decimal floating point.
+class decimal128 : public byte_array<16> {};
+
+PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const decimal32&);
+PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const decimal64&);
+PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const decimal128&);
+
+///@}
+
+}
+
+#endif // DECIMAL_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/include/proton/decoder.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/decoder.hpp b/proton-c/bindings/cpp/include/proton/decoder.hpp
index 3dab9c9..1089d32 100644
--- a/proton-c/bindings/cpp/include/proton/decoder.hpp
+++ b/proton-c/bindings/cpp/include/proton/decoder.hpp
@@ -26,6 +26,8 @@
 #include "proton/type_traits.hpp"
 #include "proton/types.hpp"
 #include "proton/object.hpp"
+#include "proton/timestamp.hpp"
+#include "proton/uuid.hpp"
 #include <iosfwd>
 
 #ifndef PN_NO_CONTAINER_CONVERT
@@ -98,11 +100,11 @@ type or throw an exception if the types are not compatible.
 +-------------------------+-------------------------------+
 |BINARY                   |amqp_binary, std::string       |
 +-------------------------+-------------------------------+
-|DECIMAL32/64/128         |amqp_decimal32/64/128          |
+|DECIMAL32/64/128         |decimal32/64/128               |
 +-------------------------+-------------------------------+
-|TIMESTAMP                |amqp_timestamp                 |
+|TIMESTAMP                |timestamp                      |
 +-------------------------+-------------------------------+
-|UUID                     |amqp_uuid                      |
+|UUID                     |uuid                           |
 +-------------------------+-------------------------------+
 
 The special proton::value type can hold any AMQP type, simple or compound.
@@ -202,13 +204,13 @@ class decoder : public object<pn_data_t> {
     PN_CPP_EXTERN friend decoder operator>>(decoder, amqp_char&);
     PN_CPP_EXTERN friend decoder operator>>(decoder, amqp_ulong&);
     PN_CPP_EXTERN friend decoder operator>>(decoder, amqp_long&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, amqp_timestamp&);
+    PN_CPP_EXTERN friend decoder operator>>(decoder, timestamp&);
     PN_CPP_EXTERN friend decoder operator>>(decoder, amqp_float&);
     PN_CPP_EXTERN friend decoder operator>>(decoder, amqp_double&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, amqp_decimal32&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, amqp_decimal64&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, amqp_decimal128&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, amqp_uuid&);
+    PN_CPP_EXTERN friend decoder operator>>(decoder, decimal32&);
+    PN_CPP_EXTERN friend decoder operator>>(decoder, decimal64&);
+    PN_CPP_EXTERN friend decoder operator>>(decoder, decimal128&);
+    PN_CPP_EXTERN friend decoder operator>>(decoder, uuid&);
     PN_CPP_EXTERN friend decoder operator>>(decoder, std::string&);
     PN_CPP_EXTERN friend decoder operator>>(decoder, message_id&);
     PN_CPP_EXTERN friend decoder operator>>(decoder, annotation_key&);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/include/proton/duration.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/duration.hpp b/proton-c/bindings/cpp/include/proton/duration.hpp
index f206849..193e162 100644
--- a/proton-c/bindings/cpp/include/proton/duration.hpp
+++ b/proton-c/bindings/cpp/include/proton/duration.hpp
@@ -23,36 +23,39 @@
  */
 
 #include "proton/export.hpp"
-#include "proton/types.hpp"
 #include "proton/comparable.hpp"
+#include "proton/types.hpp"
+
+#include <iosfwd>
 
 namespace proton {
 
 /// A span of time in milliseconds.
 class duration : public comparable<duration> {
   public:
-    /// @cond INTERNAL
-    /// XXX public and mutable? - make this private
-    uint64_t milliseconds;
-    /// @endcond
-
-    /// Create a duration.
-    explicit duration(uint64_t ms = 0) : milliseconds(ms) {}
+    explicit duration(int64_t ms = 0) : ms_(ms) {}
+    duration& operator=(int64_t ms) { ms_ = ms; return *this; }
+    int64_t milliseconds() const { return ms_; }
+    int64_t ms() const { return ms_; }
 
     PN_CPP_EXTERN static const duration FOREVER;   ///< Wait for ever
     PN_CPP_EXTERN static const duration IMMEDIATE; ///< Don't wait at all
     PN_CPP_EXTERN static const duration SECOND;    ///< One second
     PN_CPP_EXTERN static const duration MINUTE;    ///< One minute
+
+  private:
+    int64_t ms_;
 };
 
-inline bool operator<(duration x, duration y) { return x.milliseconds < y.milliseconds; }
-inline bool operator==(duration x, duration y) { return x.milliseconds == y.milliseconds; }
+PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, duration);
 
-inline duration operator*(duration d, amqp_ulong n) { return duration(d.milliseconds*n); }
-inline duration operator*(amqp_ulong n, duration d) { return d * n; }
+inline bool operator<(duration x, duration y) { return x.ms() < y.ms(); }
+inline bool operator==(duration x, duration y) { return x.ms() == y.ms(); }
 
-inline amqp_timestamp operator+(amqp_timestamp ts, duration d) { return amqp_timestamp(ts.milliseconds+d.milliseconds); }
-inline amqp_timestamp operator+(duration d, amqp_timestamp ts) { return ts + d; }
+inline duration operator+(duration x, duration y) { return duration(x.ms() + y.ms()); }
+inline duration operator-(duration x, duration y) { return duration(x.ms() - y.ms()); }
+inline duration operator*(duration d, int64_t n) { return duration(d.ms()*n); }
+inline duration operator*(int64_t n, duration d) { return d * n; }
 
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/include/proton/encoder.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/encoder.hpp b/proton-c/bindings/cpp/include/proton/encoder.hpp
index 1876412..db9c35d 100644
--- a/proton-c/bindings/cpp/include/proton/encoder.hpp
+++ b/proton-c/bindings/cpp/include/proton/encoder.hpp
@@ -154,13 +154,13 @@ class encoder : public object<pn_data_t> {
   friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_char);
   friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_ulong);
   friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_long);
-  friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_timestamp);
+  friend PN_CPP_EXTERN encoder operator<<(encoder, timestamp);
   friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_float);
   friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_double);
-  friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_decimal32);
-  friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_decimal64);
-  friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_decimal128);
-  friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_uuid);
+  friend PN_CPP_EXTERN encoder operator<<(encoder, decimal32);
+  friend PN_CPP_EXTERN encoder operator<<(encoder, decimal64);
+  friend PN_CPP_EXTERN encoder operator<<(encoder, decimal128);
+  friend PN_CPP_EXTERN encoder operator<<(encoder, uuid);
   friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_string);
   friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_symbol);
   friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_binary);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/include/proton/message.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/message.hpp b/proton-c/bindings/cpp/include/proton/message.hpp
index 045143f..6981ac4 100644
--- a/proton-c/bindings/cpp/include/proton/message.hpp
+++ b/proton-c/bindings/cpp/include/proton/message.hpp
@@ -148,13 +148,11 @@ class message {
     PN_CPP_EXTERN void content_encoding(const std::string &s);
     PN_CPP_EXTERN std::string content_encoding() const;
 
-    // XXX amqp_timestamp -> timestamp
-    PN_CPP_EXTERN void expiry_time(amqp_timestamp t);
-    PN_CPP_EXTERN amqp_timestamp expiry_time() const;
+    PN_CPP_EXTERN void expiry_time(timestamp t);
+    PN_CPP_EXTERN timestamp expiry_time() const;
 
-    // XXX amqp_timestamp -> timestamp
-    PN_CPP_EXTERN void creation_time(amqp_timestamp t);
-    PN_CPP_EXTERN amqp_timestamp creation_time() const;
+    PN_CPP_EXTERN void creation_time(timestamp t);
+    PN_CPP_EXTERN timestamp creation_time() const;
 
     /// Get the inferred flag for a message.
     ///

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/include/proton/message_id.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/message_id.hpp b/proton-c/bindings/cpp/include/proton/message_id.hpp
index 0adef07..fcfd125 100644
--- a/proton-c/bindings/cpp/include/proton/message_id.hpp
+++ b/proton-c/bindings/cpp/include/proton/message_id.hpp
@@ -29,11 +29,11 @@ class encoder;
 class decoder;
 
 /// An AMQP message ID.
-///    
+///
 /// It can contain one of the following types:
 ///
 ///  - uint64_t
-///  - proton::amqp::amqp_uuid
+///  - proton::uuid
 ///  - proton::amqp::amqp_binary
 ///  - proton::amqp::amqp_string
 class message_id : public restricted_scalar {
@@ -47,7 +47,7 @@ class message_id : public restricted_scalar {
     ///
     /// @{
     message_id& operator=(uint64_t x) { scalar_ = x; return *this; }
-    message_id& operator=(const amqp_uuid& x) { scalar_ = x; return *this; }
+    message_id& operator=(const uuid& x) { scalar_ = x; return *this; }
     message_id& operator=(const amqp_binary& x) { scalar_ = x; return *this; }
     message_id& operator=(const amqp_string& x) { scalar_ = x; return *this; }
     /// std::string is encoded as amqp_string
@@ -66,7 +66,7 @@ class message_id : public restricted_scalar {
     ///
     /// @{
     void get(uint64_t& x) const { scalar_.get(x); }
-    void get(amqp_uuid& x) const { scalar_.get(x); }
+    void get(uuid& x) const { scalar_.get(x); }
     void get(amqp_binary& x) const { scalar_.get(x); }
     void get(amqp_string& x) const { scalar_.get(x); }
     /// @}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/include/proton/reactor.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/reactor.hpp b/proton-c/bindings/cpp/include/proton/reactor.hpp
index 8251405..4f8851d 100644
--- a/proton-c/bindings/cpp/include/proton/reactor.hpp
+++ b/proton-c/bindings/cpp/include/proton/reactor.hpp
@@ -25,6 +25,7 @@
 
 #include "proton/object.hpp"
 #include "proton/duration.hpp"
+#include "proton/timestamp.hpp"
 
 struct pn_reactor_t;
 struct pn_io_t;
@@ -69,8 +70,8 @@ class reactor : public object<pn_reactor_t> {
     /// Set timeout, process() will return if there is no activity within the timeout.
     PN_CPP_EXTERN void timeout(duration timeout);
 
-    PN_CPP_EXTERN amqp_timestamp mark();
-    PN_CPP_EXTERN amqp_timestamp now();
+    PN_CPP_EXTERN timestamp mark();
+    PN_CPP_EXTERN timestamp now();
 
     PN_CPP_EXTERN task schedule(int, pn_handler_t*);
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/include/proton/scalar.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/scalar.hpp b/proton-c/bindings/cpp/include/proton/scalar.hpp
index 3975301..05fdde3 100644
--- a/proton-c/bindings/cpp/include/proton/scalar.hpp
+++ b/proton-c/bindings/cpp/include/proton/scalar.hpp
@@ -28,8 +28,13 @@
 
 namespace proton {
 
-class encoder;
+class decimal128;
+class decimal32;
+class decimal64;
 class decoder;
+class encoder;
+class timestamp;
+class uuid;
 
 /// A holder for an instance of any scalar AMQP type.
 class scalar : public comparable<scalar> {
@@ -66,11 +71,11 @@ class scalar : public comparable<scalar> {
     PN_CPP_EXTERN scalar& operator=(wchar_t);
     PN_CPP_EXTERN scalar& operator=(float);
     PN_CPP_EXTERN scalar& operator=(double);
-    PN_CPP_EXTERN scalar& operator=(amqp_timestamp);
-    PN_CPP_EXTERN scalar& operator=(const amqp_decimal32&);
-    PN_CPP_EXTERN scalar& operator=(const amqp_decimal64&);
-    PN_CPP_EXTERN scalar& operator=(const amqp_decimal128&);
-    PN_CPP_EXTERN scalar& operator=(const amqp_uuid&);
+    PN_CPP_EXTERN scalar& operator=(timestamp);
+    PN_CPP_EXTERN scalar& operator=(const decimal32&);
+    PN_CPP_EXTERN scalar& operator=(const decimal64&);
+    PN_CPP_EXTERN scalar& operator=(const decimal128&);
+    PN_CPP_EXTERN scalar& operator=(const uuid&);
     PN_CPP_EXTERN scalar& operator=(const amqp_string&);
     PN_CPP_EXTERN scalar& operator=(const amqp_symbol&);
     PN_CPP_EXTERN scalar& operator=(const amqp_binary&);
@@ -99,11 +104,11 @@ class scalar : public comparable<scalar> {
     PN_CPP_EXTERN void get(wchar_t&) const;
     PN_CPP_EXTERN void get(float&) const;
     PN_CPP_EXTERN void get(double&) const;
-    PN_CPP_EXTERN void get(amqp_timestamp&) const;
-    PN_CPP_EXTERN void get(amqp_decimal32&) const;
-    PN_CPP_EXTERN void get(amqp_decimal64&) const;
-    PN_CPP_EXTERN void get(amqp_decimal128&) const;
-    PN_CPP_EXTERN void get(amqp_uuid&) const;
+    PN_CPP_EXTERN void get(timestamp&) const;
+    PN_CPP_EXTERN void get(decimal32&) const;
+    PN_CPP_EXTERN void get(decimal64&) const;
+    PN_CPP_EXTERN void get(decimal128&) const;
+    PN_CPP_EXTERN void get(uuid&) const;
     PN_CPP_EXTERN void get(amqp_string&) const;
     PN_CPP_EXTERN void get(amqp_symbol&) const;
     PN_CPP_EXTERN void get(amqp_binary&) const;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/include/proton/timestamp.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/timestamp.hpp b/proton-c/bindings/cpp/include/proton/timestamp.hpp
new file mode 100644
index 0000000..1cfb231
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/timestamp.hpp
@@ -0,0 +1,46 @@
+#ifndef TIMESTAMP_HPP
+#define TIMESTAMP_HPP
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "proton/duration.hpp"
+
+namespace proton {
+/// A timestamp in milliseconds since the epoch 00:00:00 (UTC), 1 January 1970.
+class timestamp : public comparable<timestamp> {
+  public:
+    explicit timestamp(int64_t ms = 0) : ms_(ms) {}
+    timestamp& operator=(int64_t ms) { ms_ = ms; return *this; }
+    int64_t milliseconds() const { return ms_; }
+    int64_t ms() const { return ms_; }
+
+  private:
+    int64_t ms_;
+};
+
+inline bool operator==(timestamp x, timestamp y) { return x.ms() == y.ms(); }
+inline bool operator<(timestamp x, timestamp y) { return x.ms() < y.ms(); }
+
+inline timestamp operator+(timestamp ts, duration d) { return timestamp(ts.ms() + d.ms()); }
+inline timestamp operator+(duration d, timestamp ts) { return ts + d; }
+
+PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, timestamp);
+
+}
+#endif // TIMESTAMP_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/include/proton/type_traits.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/type_traits.hpp b/proton-c/bindings/cpp/include/proton/type_traits.hpp
index 56f503c..967dea1 100644
--- a/proton-c/bindings/cpp/include/proton/type_traits.hpp
+++ b/proton-c/bindings/cpp/include/proton/type_traits.hpp
@@ -34,6 +34,11 @@
 
 namespace proton {
 
+class decimal128;
+class decimal32;
+class decimal64;
+class timestamp;
+class uuid;
 class value;
 
 template <bool, class T=void> struct enable_if {};
@@ -93,13 +98,13 @@ template<> struct type_id_of<amqp_int> { static const type_id value=INT; };
 template<> struct type_id_of<amqp_char> { static const type_id value=CHAR; };
 template<> struct type_id_of<amqp_ulong> { static const type_id value=ULONG; };
 template<> struct type_id_of<amqp_long> { static const type_id value=LONG; };
-template<> struct type_id_of<amqp_timestamp> { static const type_id value=TIMESTAMP; };
+template<> struct type_id_of<timestamp> { static const type_id value=TIMESTAMP; };
 template<> struct type_id_of<amqp_float> { static const type_id value=FLOAT; };
 template<> struct type_id_of<amqp_double> { static const type_id value=DOUBLE; };
-template<> struct type_id_of<amqp_decimal32> { static const type_id value=DECIMAL32; };
-template<> struct type_id_of<amqp_decimal64> { static const type_id value=DECIMAL64; };
-template<> struct type_id_of<amqp_decimal128> { static const type_id value=DECIMAL128; };
-template<> struct type_id_of<amqp_uuid> { static const type_id value=UUID; };
+template<> struct type_id_of<decimal32> { static const type_id value=DECIMAL32; };
+template<> struct type_id_of<decimal64> { static const type_id value=DECIMAL64; };
+template<> struct type_id_of<decimal128> { static const type_id value=DECIMAL128; };
+template<> struct type_id_of<uuid> { static const type_id value=UUID; };
 template<> struct type_id_of<amqp_binary> { static const type_id value=BINARY; };
 template<> struct type_id_of<amqp_string> { static const type_id value=STRING; };
 template<> struct type_id_of<amqp_symbol> { static const type_id value=SYMBOL; };

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/include/proton/types.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/types.hpp b/proton-c/bindings/cpp/include/proton/types.hpp
index ee93082..312ac75 100644
--- a/proton-c/bindings/cpp/include/proton/types.hpp
+++ b/proton-c/bindings/cpp/include/proton/types.hpp
@@ -24,7 +24,6 @@
 ///
 /// Defines C++ types representing AMQP types.
 
-#include "proton/comparable.hpp"
 #include "proton/export.hpp"
 #include "proton/error.hpp"
 
@@ -134,51 +133,6 @@ struct amqp_binary : public std::string {
     explicit amqp_binary(const pn_bytes_t& b) : std::string(b.start, b.size) {}
 };
 
-/// Template for opaque proton proton types that can be treated as
-/// byte arrays.
-template <class P> struct opaque : public comparable<opaque<P> > {
-    P value;
-    opaque(const P& p=P()) : value(p) {}
-    operator P() const { return value; }
-
-    static size_t size() { return sizeof(P); }
-    char* begin() { return reinterpret_cast<char*>(&value); }
-    char* end() { return reinterpret_cast<char*>(&value)+size(); }
-    const char* begin() const { return reinterpret_cast<const char*>(&value); }
-    const char* end() const { return reinterpret_cast<const char*>(&value)+size(); }
-    char& operator[](size_t i) { return *(begin()+i); }
-    const char& operator[](size_t i) const { return *(begin()+i); }
-};
-
-template <class T> bool operator==(const opaque<T>& x, const opaque<T>& y) { return std::equal(x.begin(), x.end(), y.begin()); }
-template <class T> bool operator<(const opaque<T>& x, const opaque<T>& y) { return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
-
-/// AMQP 16-byte UUID.
-typedef opaque<pn_uuid_t> amqp_uuid;
-PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const amqp_uuid&);
-
-/// AMQP 32-bit decimal floating point (IEEE 854).
-typedef opaque<pn_decimal32_t> amqp_decimal32;
-PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const amqp_decimal32&);
-
-/// AMQP 64-bit decimal floating point (IEEE 854).
-typedef opaque<pn_decimal64_t> amqp_decimal64;
-PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const amqp_decimal64&);
-
-/// AMQP 128-bit decimal floating point (IEEE 854).
-typedef opaque<pn_decimal128_t> amqp_decimal128;
-PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const amqp_decimal128&);
-
-/// AMQP timestamp, milliseconds since the epoch 00:00:00 (UTC), 1 January 1970.
-struct amqp_timestamp : public comparable<amqp_timestamp> {
-    pn_timestamp_t milliseconds;
-    amqp_timestamp(::int64_t ms=0) : milliseconds(ms) {}
-    operator pn_timestamp_t() const { return milliseconds; }
-};
-inline bool operator==(amqp_timestamp x, amqp_timestamp y) { return x.milliseconds == y.milliseconds; }
-inline bool operator<(amqp_timestamp x, amqp_timestamp y) { return x.milliseconds < y.milliseconds; }
-PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const amqp_timestamp&);
-
 /// @endcond
 
 // TODO aconway 2015-06-16: described types.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/include/proton/url.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/url.hpp b/proton-c/bindings/cpp/include/proton/url.hpp
index ccf3f1e..a8896b2 100644
--- a/proton-c/bindings/cpp/include/proton/url.hpp
+++ b/proton-c/bindings/cpp/include/proton/url.hpp
@@ -108,7 +108,7 @@ class url {
     PN_CPP_EXTERN std::string username() const;
     PN_CPP_EXTERN void username(const std::string&);
     /// @endcond
-    
+
     PN_CPP_EXTERN std::string password() const;
     PN_CPP_EXTERN void password(const std::string&);
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/include/proton/uuid.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/uuid.hpp b/proton-c/bindings/cpp/include/proton/uuid.hpp
new file mode 100644
index 0000000..cbe3e32
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/uuid.hpp
@@ -0,0 +1,54 @@
+#ifndef UUID_HPP
+#define UUID_HPP
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <proton/byte_array.hpp>
+#include <proton/export.hpp>
+
+#include <proton/types.h>        // FIXME aconway 2016-02-18: cleanup
+
+#include <string>
+#include <iosfwd>
+
+namespace proton {
+
+/// A 16-byte universally unique identifier.
+class uuid : public byte_array<16> {
+  public:
+    /// Return a uuid copied from bytes, bytes must point to at least sizeof(uuid) bytes.
+    /// If bytes==0 the UUID is zero initialized.
+    PN_CPP_EXTERN static uuid make(const char* bytes=0);
+
+    /// Return a simple randomly-generated UUID. Used by the proton library to
+    /// generate default UUIDs.  For specific security, performance or
+    /// uniqueness requirements you may want to use a better UUID generator or
+    /// some other form of identifier entirely.
+    PN_CPP_EXTERN static uuid random();
+
+    /// UUID standard string format: 8-4-4-4-12 (36 chars, 32 alphanumeric and 4 hypens)
+    PN_CPP_EXTERN std::string str()  const;
+};
+
+/// UUID standard format: 8-4-4-4-12 (36 chars, 32 alphanumeric and 4 hypens)
+PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const uuid&);
+
+}
+
+#endif // UUID_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/include/proton/value.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/value.hpp b/proton-c/bindings/cpp/include/proton/value.hpp
index b2c1c0b..783f56e 100644
--- a/proton-c/bindings/cpp/include/proton/value.hpp
+++ b/proton-c/bindings/cpp/include/proton/value.hpp
@@ -22,6 +22,8 @@
 
 #include "proton/data.hpp"
 #include "proton/types.hpp"
+#include "proton/timestamp.hpp"
+#include "proton/uuid.hpp"
 
 namespace proton {
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/src/condition.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/condition.cpp b/proton-c/bindings/cpp/src/condition.cpp
index 9220fd7..3c10c39 100644
--- a/proton-c/bindings/cpp/src/condition.cpp
+++ b/proton-c/bindings/cpp/src/condition.cpp
@@ -19,7 +19,6 @@
  *
  */
 #include "proton/condition.hpp"
-
 #include "proton/condition.h"
 
 namespace proton {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/src/connection_engine.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connection_engine.cpp b/proton-c/bindings/cpp/src/connection_engine.cpp
index 89d901e..940bca6 100644
--- a/proton-c/bindings/cpp/src/connection_engine.cpp
+++ b/proton-c/bindings/cpp/src/connection_engine.cpp
@@ -20,15 +20,14 @@
 #include "proton/connection_engine.hpp"
 #include "proton/error.hpp"
 #include "proton/handler.hpp"
+#include "proton/uuid.hpp"
 
 #include "contexts.hpp"
 #include "messaging_adapter.hpp"
-#include "uuid.hpp"
 #include "msg.hpp"
 #include "proton_bits.hpp"
 #include "messaging_event.hpp"
 #include "proton_bits.hpp"
-#include "uuid.hpp"
 
 #include <proton/connection.h>
 #include <proton/transport.h>
@@ -54,7 +53,7 @@ void close_transport(connection_engine_context *ctx_) {
         pn_transport_close_tail(ctx_->transport);
 }
 
-std::string  make_id(const std::string s="") { return s.empty() ? uuid().str() : s; }
+std::string  make_id(const std::string s="") { return s.empty() ? uuid::random().str() : s; }
 }
 
 connection_engine::container::container(const std::string& s) : id_(make_id(s)) {}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/src/connection_options.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connection_options.cpp b/proton-c/bindings/cpp/src/connection_options.cpp
index 2751aaa..5bc35aa 100644
--- a/proton-c/bindings/cpp/src/connection_options.cpp
+++ b/proton-c/bindings/cpp/src/connection_options.cpp
@@ -117,7 +117,7 @@ class connection_options::impl {
             if (max_channels.set)
                 pn_transport_set_channel_max(pnt, max_channels.value);
             if (idle_timeout.set)
-                pn_transport_set_idle_timeout(pnt, idle_timeout.value.milliseconds);
+                pn_transport_set_idle_timeout(pnt, idle_timeout.value.ms());
         }
         // Only apply connection options if uninit.
         if (uninit) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/src/container_impl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/container_impl.cpp b/proton-c/bindings/cpp/src/container_impl.cpp
index 8527b68..67bbdcd 100644
--- a/proton-c/bindings/cpp/src/container_impl.cpp
+++ b/proton-c/bindings/cpp/src/container_impl.cpp
@@ -32,6 +32,7 @@
 #include "proton/ssl.hpp"
 #include "proton/sasl.hpp"
 #include "proton/transport.hpp"
+#include "proton/uuid.hpp"
 
 #include "connector.hpp"
 #include "container_impl.hpp"
@@ -39,7 +40,6 @@
 #include "messaging_adapter.hpp"
 #include "messaging_event.hpp"
 #include "msg.hpp"
-#include "uuid.hpp"
 
 #include "proton/connection.h"
 #include "proton/session.h"
@@ -125,7 +125,7 @@ pn_ptr<pn_handler_t> container_impl::cpp_handler(proton_handler *h) {
 
 container_impl::container_impl(container& c, messaging_adapter *h, const std::string& id) :
     container_(c), reactor_(reactor::create()), handler_(h),
-    id_(id.empty() ? uuid().str() : id), id_gen_()
+    id_(id.empty() ? uuid::random().str() : id), id_gen_()
 {
     container_context::set(reactor_, container_);
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/src/data.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/data.cpp b/proton-c/bindings/cpp/src/data.cpp
index 6783dae..b6838aa 100644
--- a/proton-c/bindings/cpp/src/data.cpp
+++ b/proton-c/bindings/cpp/src/data.cpp
@@ -19,6 +19,7 @@
 
 #include "proton_bits.hpp"
 #include "proton/data.hpp"
+#include "proton/decimal.hpp"
 
 #include <proton/codec.h>
 
@@ -126,13 +127,13 @@ int compare_next(data& a, data& b) {
       case CHAR: return compare_simple<amqp_char>(a, b);
       case ULONG: return compare_simple<amqp_ulong>(a, b);
       case LONG: return compare_simple<amqp_long>(a, b);
-      case TIMESTAMP: return compare_simple<amqp_timestamp>(a, b);
+      case TIMESTAMP: return compare_simple<timestamp>(a, b);
       case FLOAT: return compare_simple<amqp_float>(a, b);
       case DOUBLE: return compare_simple<amqp_double>(a, b);
-      case DECIMAL32: return compare_simple<amqp_decimal32>(a, b);
-      case DECIMAL64: return compare_simple<amqp_decimal64>(a, b);
-      case DECIMAL128: return compare_simple<amqp_decimal128>(a, b);
-      case UUID: return compare_simple<amqp_uuid>(a, b);
+      case DECIMAL32: return compare_simple<decimal32>(a, b);
+      case DECIMAL64: return compare_simple<decimal64>(a, b);
+      case DECIMAL128: return compare_simple<decimal128>(a, b);
+      case UUID: return compare_simple<uuid>(a, b);
       case BINARY: return compare_simple<amqp_binary>(a, b);
       case STRING: return compare_simple<amqp_string>(a, b);
       case SYMBOL: return compare_simple<amqp_symbol>(a, b);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/src/decimal.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/decimal.cpp b/proton-c/bindings/cpp/src/decimal.cpp
new file mode 100644
index 0000000..65279f4
--- /dev/null
+++ b/proton-c/bindings/cpp/src/decimal.cpp
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "proton/decimal.hpp"
+#include <iostream>
+
+namespace proton {
+std::ostream& operator<<(std::ostream& o, const decimal32& ) { return o << "<decimal32>"; }
+std::ostream& operator<<(std::ostream& o, const decimal64& ) { return o << "<decimal32>"; }
+std::ostream& operator<<(std::ostream& o, const decimal128& ) { return o << "<decimal32>"; }
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/src/decoder.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/decoder.cpp b/proton-c/bindings/cpp/src/decoder.cpp
index f775001..9056674 100644
--- a/proton-c/bindings/cpp/src/decoder.cpp
+++ b/proton-c/bindings/cpp/src/decoder.cpp
@@ -19,10 +19,13 @@
 
 #include "proton/data.hpp"
 #include "proton/decoder.hpp"
+#include "proton/decimal.hpp"
 #include "proton/value.hpp"
 #include "proton/message_id.hpp"
 #include "proton/annotation_key.hpp"
 #include "proton_bits.hpp"
+
+#include "types_internal.hpp"
 #include "msg.hpp"
 
 #include <proton/codec.h>
@@ -96,11 +99,17 @@ type_id pre_get(pn_data_t* data) {
     return t;
 }
 
+template <class T, class U> void assign(T& x, const U& y) { x = y; }
+void assign(uuid& x, const pn_uuid_t y) { byte_copy(x, y); }
+void assign(decimal32& x, const pn_decimal32_t y) { byte_copy(x, y); }
+void assign(decimal64& x, const pn_decimal64_t y)  { byte_copy(x, y); }
+void assign(decimal128& x, const pn_decimal128_t y) { byte_copy(x, y); }
+
 // Simple extract with no type conversion.
 template <class T, class U> void extract(pn_data_t* data, T& x, U (*get)(pn_data_t*)) {
     save_state ss(data);
     bad_type(type_id_of<T>::value, pre_get(data));
-    x = T(get(data));
+    assign(x, get(data));
     ss.cancel();                // No error, no rewind
 }
 
@@ -312,7 +321,7 @@ decoder operator>>(decoder d, amqp_char &x) {
     return d;
 }
 
-decoder operator>>(decoder d, amqp_timestamp &x) {
+decoder operator>>(decoder d, timestamp &x) {
     extract(d.pn_object(), x, pn_data_get_timestamp);
     return d;
 }
@@ -341,22 +350,22 @@ decoder operator>>(decoder d0, amqp_double &x) {
     return d0;
 }
 
-decoder operator>>(decoder d, amqp_decimal32 &x) {
+decoder operator>>(decoder d, decimal32 &x) {
     extract(d.pn_object(), x, pn_data_get_decimal32);
     return d;
 }
 
-decoder operator>>(decoder d, amqp_decimal64 &x) {
+decoder operator>>(decoder d, decimal64 &x) {
     extract(d.pn_object(), x, pn_data_get_decimal64);
     return d;
 }
 
-decoder operator>>(decoder d, amqp_decimal128 &x)  {
+decoder operator>>(decoder d, decimal128 &x)  {
     extract(d.pn_object(), x, pn_data_get_decimal128);
     return d;
 }
 
-decoder operator>>(decoder d, amqp_uuid &x)  {
+decoder operator>>(decoder d, uuid &x)  {
     extract(d.pn_object(), x, pn_data_get_uuid);
     return d;
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/src/duration.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/duration.cpp b/proton-c/bindings/cpp/src/duration.cpp
index 8c8263e..1763631 100644
--- a/proton-c/bindings/cpp/src/duration.cpp
+++ b/proton-c/bindings/cpp/src/duration.cpp
@@ -19,13 +19,24 @@
  *
  */
 #include "proton/duration.hpp"
+#include "proton/timestamp.hpp"
+
 #include <limits>
+#include <iostream>
 
 namespace proton {
 
-const duration duration::FOREVER(std::numeric_limits<amqp_ulong>::max());
+const duration duration::FOREVER(std::numeric_limits<int64_t>::max());
 const duration duration::IMMEDIATE(0);
 const duration duration::SECOND(1000);
 const duration duration::MINUTE(SECOND * 60);
 
+std::ostream& operator<<(std::ostream& o, timestamp ts) {
+    return o << "timestamp:" << ts.ms() << "ms";
+}
+
+std::ostream& operator<<(std::ostream& o, duration d) {
+    return o << d.ms() << "ms";
+}
+
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/src/encoder.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/encoder.cpp b/proton-c/bindings/cpp/src/encoder.cpp
index 58b41b3..58246d7 100644
--- a/proton-c/bindings/cpp/src/encoder.cpp
+++ b/proton-c/bindings/cpp/src/encoder.cpp
@@ -22,8 +22,10 @@
 #include "proton/message_id.hpp"
 #include "proton/annotation_key.hpp"
 #include "proton/value.hpp"
+#include "proton/decimal.hpp"
 
 #include "proton_bits.hpp"
+#include "types_internal.hpp"
 #include "msg.hpp"
 
 #include <proton/codec.h>
@@ -100,10 +102,17 @@ encoder operator<<(encoder e, finish) {
 }
 
 namespace {
+
+template <class T, class U> T convert(const U &x) { return x; }
+template <> pn_uuid_t convert(const uuid& x) { pn_uuid_t y; byte_copy(y, x); return  y; }
+template <> pn_decimal32_t convert(const decimal32 &x) { pn_decimal32_t y; byte_copy(y, x); return  y; }
+template <> pn_decimal64_t convert(const decimal64 &x) { pn_decimal64_t y; byte_copy(y, x); return  y; }
+template <> pn_decimal128_t convert(const decimal128 &x) { pn_decimal128_t y; byte_copy(y, x); return  y; }
+
 template <class T, class U>
-encoder insert(encoder e, pn_data_t* data, T& x, int (*put)(pn_data_t*, U)) {
+encoder insert(encoder e, pn_data_t* data, const T& x, int (*put)(pn_data_t*, U)) {
     save_state ss(data);         // Save state in case of error.
-    check(put(data, x), data);
+    check(put(data, convert<U>(x)), data);
     ss.cancel();                // Don't restore state, all is good.
     return e;
 }
@@ -124,13 +133,14 @@ encoder operator<<(encoder e, amqp_int x) { return insert(e, e.pn_object(), x, p
 encoder operator<<(encoder e, amqp_char x) { return insert(e, e.pn_object(), x, pn_data_put_char); }
 encoder operator<<(encoder e, amqp_ulong x) { return insert(e, e.pn_object(), x, pn_data_put_ulong); }
 encoder operator<<(encoder e, amqp_long x) { return insert(e, e.pn_object(), x, pn_data_put_long); }
-encoder operator<<(encoder e, amqp_timestamp x) { return insert(e, e.pn_object(), x, pn_data_put_timestamp); }
+encoder operator<<(encoder e, timestamp x) { return insert(e, e.pn_object(), x.ms(), pn_data_put_timestamp); }
 encoder operator<<(encoder e, amqp_float x) { return insert(e, e.pn_object(), x, pn_data_put_float); }
 encoder operator<<(encoder e, amqp_double x) { return insert(e, e.pn_object(), x, pn_data_put_double); }
-encoder operator<<(encoder e, amqp_decimal32 x) { return insert(e, e.pn_object(), x, pn_data_put_decimal32); }
-encoder operator<<(encoder e, amqp_decimal64 x) { return insert(e, e.pn_object(), x, pn_data_put_decimal64); }
-encoder operator<<(encoder e, amqp_decimal128 x) { return insert(e, e.pn_object(), x, pn_data_put_decimal128); }
-encoder operator<<(encoder e, amqp_uuid x) { return insert(e, e.pn_object(), x, pn_data_put_uuid); }
+
+encoder operator<<(encoder e, decimal32 x) { return insert(e, e.pn_object(), x, pn_data_put_decimal32); }
+encoder operator<<(encoder e, decimal64 x) { return insert(e, e.pn_object(), x, pn_data_put_decimal64); }
+encoder operator<<(encoder e, decimal128 x) { return insert(e, e.pn_object(), x, pn_data_put_decimal128); }
+encoder operator<<(encoder e, uuid x) { return insert(e, e.pn_object(), x, pn_data_put_uuid); }
 encoder operator<<(encoder e, amqp_string x) { return insert(e, e.pn_object(), x, pn_data_put_amqp_string); }
 encoder operator<<(encoder e, amqp_symbol x) { return insert(e, e.pn_object(), x, pn_data_put_amqp_symbol); }
 encoder operator<<(encoder e, amqp_binary x) { return insert(e, e.pn_object(), x, pn_data_put_amqp_binary); }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/src/engine_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/engine_test.cpp b/proton-c/bindings/cpp/src/engine_test.cpp
index cb8e389..d386d6d 100644
--- a/proton-c/bindings/cpp/src/engine_test.cpp
+++ b/proton-c/bindings/cpp/src/engine_test.cpp
@@ -19,7 +19,7 @@
 
 
 #include "test_bits.hpp"
-#include "uuid.hpp"
+#include <proton/uuid.hpp>
 #include <proton/connection_engine.hpp>
 #include <proton/handler.hpp>
 #include <proton/event.hpp>

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/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 2358da2..2b231e4 100644
--- a/proton-c/bindings/cpp/src/message.cpp
+++ b/proton-c/bindings/cpp/src/message.cpp
@@ -91,7 +91,7 @@ inline message_id from_pn_atom(const pn_atom_t& v) {
     case PN_ULONG:
       return message_id(amqp_ulong(v.u.as_ulong));
     case PN_UUID:
-      return message_id(amqp_uuid(v.u.as_uuid));
+      return message_id(uuid::make(reinterpret_cast<const char*>(&v.u.as_uuid)));
     case PN_BINARY:
       return message_id(amqp_binary(v.u.as_bytes));
     case PN_STRING:
@@ -167,18 +167,18 @@ std::string message::content_encoding() const {
     return s ? std::string(s) : std::string();
 }
 
-void message::expiry_time(amqp_timestamp t) {
-    pn_message_set_expiry_time(pn_msg(), t.milliseconds);
+void message::expiry_time(timestamp t) {
+    pn_message_set_expiry_time(pn_msg(), t.ms());
 }
-amqp_timestamp message::expiry_time() const {
-    return amqp_timestamp(pn_message_get_expiry_time(pn_msg()));
+timestamp message::expiry_time() const {
+    return timestamp(pn_message_get_expiry_time(pn_msg()));
 }
 
-void message::creation_time(amqp_timestamp t) {
-    pn_message_set_creation_time(pn_msg(), t);
+void message::creation_time(timestamp t) {
+    pn_message_set_creation_time(pn_msg(), t.ms());
 }
-amqp_timestamp message::creation_time() const {
-    return pn_message_get_creation_time(pn_msg());
+timestamp message::creation_time() const {
+    return timestamp(pn_message_get_creation_time(pn_msg()));
 }
 
 void message::group_id(const std::string &s) {
@@ -303,7 +303,7 @@ bool message::durable() const { return pn_message_is_durable(pn_msg()); }
 void message::durable(bool b) { pn_message_set_durable(pn_msg(), b); }
 
 duration message::ttl() const { return duration(pn_message_get_ttl(pn_msg())); }
-void message::ttl(duration d) { pn_message_set_ttl(pn_msg(), d.milliseconds); }
+void message::ttl(duration d) { pn_message_set_ttl(pn_msg(), d.ms()); }
 
 uint8_t message::priority() const { return pn_message_get_priority(pn_msg()); }
 void message::priority(uint8_t d) { pn_message_set_priority(pn_msg(), d); }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/src/message_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/message_test.cpp b/proton-c/bindings/cpp/src/message_test.cpp
index 988aa34..8c1e585 100644
--- a/proton-c/bindings/cpp/src/message_test.cpp
+++ b/proton-c/bindings/cpp/src/message_test.cpp
@@ -53,10 +53,10 @@ void test_message_properties() {
     CHECK_STR(content_encoding);
     CHECK_STR(group_id);
     CHECK_STR(reply_to_group_id);
-    m.expiry_time(42);
-    ASSERT_EQUAL(m.expiry_time().milliseconds, 42);
-    m.creation_time(4242);
-    ASSERT_EQUAL(m.creation_time().milliseconds, 4242);
+    m.expiry_time(timestamp(42));
+    ASSERT_EQUAL(m.expiry_time().ms(), 42);
+    m.creation_time(timestamp(4242));
+    ASSERT_EQUAL(m.creation_time().ms(), 4242);
 
     message m2(m);
     ASSERT_EQUAL("hello", m2.body().get<std::string>());
@@ -70,8 +70,8 @@ void test_message_properties() {
     ASSERT_EQUAL("content_encoding", m2.content_encoding());
     ASSERT_EQUAL("group_id", m2.group_id());
     ASSERT_EQUAL("reply_to_group_id", m2.reply_to_group_id());
-    ASSERT_EQUAL(42, m2.expiry_time().milliseconds);
-    ASSERT_EQUAL(4242, m.creation_time().milliseconds);
+    ASSERT_EQUAL(42, m2.expiry_time().ms());
+    ASSERT_EQUAL(4242, m.creation_time().ms());
 
     m2 = m;
     ASSERT_EQUAL("hello", m2.body().get<std::string>());
@@ -85,8 +85,8 @@ void test_message_properties() {
     ASSERT_EQUAL("content_encoding", m2.content_encoding());
     ASSERT_EQUAL("group_id", m2.group_id());
     ASSERT_EQUAL("reply_to_group_id", m2.reply_to_group_id());
-    ASSERT_EQUAL(42, m2.expiry_time().milliseconds);
-    ASSERT_EQUAL(4242, m.creation_time().milliseconds);
+    ASSERT_EQUAL(42, m2.expiry_time().ms());
+    ASSERT_EQUAL(4242, m.creation_time().ms());
 }
 
 void test_message_body() {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/src/reactor.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/reactor.cpp b/proton-c/bindings/cpp/src/reactor.cpp
index 59db5e0..159eb94 100644
--- a/proton-c/bindings/cpp/src/reactor.cpp
+++ b/proton-c/bindings/cpp/src/reactor.cpp
@@ -40,8 +40,8 @@ void reactor::stop() { pn_reactor_stop(pn_object()); }
 void reactor::wakeup() { pn_reactor_wakeup(pn_object()); }
 bool reactor::quiesced() { return pn_reactor_quiesced(pn_object()); }
 void reactor::yield() { pn_reactor_yield(pn_object()); }
-amqp_timestamp reactor::mark() { return pn_reactor_mark(pn_object()); }
-amqp_timestamp reactor::now() { return pn_reactor_now(pn_object()); }
+timestamp reactor::mark() { return timestamp(pn_reactor_mark(pn_object())); }
+timestamp reactor::now() { return timestamp(pn_reactor_now(pn_object())); }
 
 acceptor reactor::listen(const url& url){
     return pn_reactor_acceptor(pn_object(), url.host().c_str(), url.port().c_str(), 0);
@@ -83,10 +83,10 @@ duration reactor::timeout() {
 }
 
 void reactor::timeout(duration timeout) {
-    if (timeout == duration::FOREVER || timeout.milliseconds > PN_MILLIS_MAX)
+    if (timeout == duration::FOREVER || timeout.ms() > PN_MILLIS_MAX)
         pn_reactor_set_timeout(pn_object(), PN_MILLIS_MAX);
     else
-        pn_reactor_set_timeout(pn_object(), timeout.milliseconds);
+        pn_reactor_set_timeout(pn_object(), timeout.ms());
 }
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/src/reconnect_timer.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/reconnect_timer.cpp b/proton-c/bindings/cpp/src/reconnect_timer.cpp
index 2a44063..245778b 100644
--- a/proton-c/bindings/cpp/src/reconnect_timer.cpp
+++ b/proton-c/bindings/cpp/src/reconnect_timer.cpp
@@ -46,7 +46,7 @@ int reconnect_timer::next_delay() {
         return -1;
     if (!reactor_)
         throw error(MSG("reconnect timer missing reactor reference"));
-    pn_timestamp_t now = reactor_.now();
+    pn_timestamp_t now = reactor_.now().ms();
 
     if (retries_ == 1) {
         if (timeout_ >= 0)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/src/scalar.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/scalar.cpp b/proton-c/bindings/cpp/src/scalar.cpp
index 3379c01..eab19e6 100644
--- a/proton-c/bindings/cpp/src/scalar.cpp
+++ b/proton-c/bindings/cpp/src/scalar.cpp
@@ -18,8 +18,13 @@
  */
 
 #include "msg.hpp"
+#include "types_internal.hpp"
+
+#include "proton/decimal.hpp"
 #include "proton/scalar.hpp"
+#include "proton/timestamp.hpp"
 #include "proton/type_traits.hpp"
+#include "proton/uuid.hpp"
 
 #include <ostream>
 
@@ -61,11 +66,32 @@ scalar& scalar::operator=(int64_t x) { atom_.u.as_long = x; atom_.type = PN_LONG
 scalar& scalar::operator=(wchar_t x) { atom_.u.as_char = x; atom_.type = PN_CHAR; return *this; }
 scalar& scalar::operator=(float x) { atom_.u.as_float = x; atom_.type = PN_FLOAT; return *this; }
 scalar& scalar::operator=(double x) { atom_.u.as_double = x; atom_.type = PN_DOUBLE; return *this; }
-scalar& scalar::operator=(amqp_timestamp x) { atom_.u.as_timestamp = x; atom_.type = PN_TIMESTAMP; return *this; }
-scalar& scalar::operator=(const amqp_decimal32& x) { atom_.u.as_decimal32 = x; atom_.type = PN_DECIMAL32; return *this; }
-scalar& scalar::operator=(const amqp_decimal64& x) { atom_.u.as_decimal64 = x; atom_.type = PN_DECIMAL64; return *this; }
-scalar& scalar::operator=(const amqp_decimal128& x) { atom_.u.as_decimal128 = x; atom_.type = PN_DECIMAL128; return *this; }
-scalar& scalar::operator=(const amqp_uuid& x) { atom_.u.as_uuid = x; atom_.type = PN_UUID; return *this; }
+scalar& scalar::operator=(timestamp x) { atom_.u.as_timestamp = x.ms(); atom_.type = PN_TIMESTAMP; return *this; }
+
+scalar& scalar::operator=(const decimal32& x) {
+    byte_copy(atom_.u.as_decimal32, x);
+    atom_.type = PN_DECIMAL32;
+    return *this;
+}
+
+scalar& scalar::operator=(const decimal64& x) {
+    byte_copy(atom_.u.as_decimal64, x);
+    atom_.type = PN_DECIMAL64;
+    return *this;
+}
+
+scalar& scalar::operator=(const decimal128& x) {
+    byte_copy(atom_.u.as_decimal128, x);
+    atom_.type = PN_DECIMAL128;
+    return *this;
+}
+
+scalar& scalar::operator=(const uuid& x) {
+    byte_copy(atom_.u.as_uuid, x);
+    atom_.type = PN_UUID;
+    return *this;
+}
+
 scalar& scalar::operator=(const amqp_string& x) { set(x, PN_STRING); return *this; }
 scalar& scalar::operator=(const amqp_symbol& x) { set(x, PN_SYMBOL); return *this; }
 scalar& scalar::operator=(const amqp_binary& x) { set(x, PN_BINARY); return *this; }
@@ -86,13 +112,13 @@ void scalar::get(int32_t& x) const { ok(PN_INT); x = atom_.u.as_int; }
 void scalar::get(wchar_t& x) const { ok(PN_CHAR); x = wchar_t(atom_.u.as_char); }
 void scalar::get(uint64_t& x) const { ok(PN_ULONG); x = atom_.u.as_ulong; }
 void scalar::get(int64_t& x) const { ok(PN_LONG); x = atom_.u.as_long; }
-void scalar::get(amqp_timestamp& x) const { ok(PN_TIMESTAMP); x = atom_.u.as_timestamp; }
+void scalar::get(timestamp& x) const { ok(PN_TIMESTAMP); x = atom_.u.as_timestamp; }
 void scalar::get(float& x) const { ok(PN_FLOAT); x = atom_.u.as_float; }
 void scalar::get(double& x) const { ok(PN_DOUBLE); x = atom_.u.as_double; }
-void scalar::get(amqp_decimal32& x) const { ok(PN_DECIMAL32); x = atom_.u.as_decimal32; }
-void scalar::get(amqp_decimal64& x) const { ok(PN_DECIMAL64); x = atom_.u.as_decimal64; }
-void scalar::get(amqp_decimal128& x) const { ok(PN_DECIMAL128); x = atom_.u.as_decimal128; }
-void scalar::get(amqp_uuid& x) const { ok(PN_UUID); x = atom_.u.as_uuid; }
+void scalar::get(decimal32& x) const { ok(PN_DECIMAL32); byte_copy(x, atom_.u.as_decimal32); }
+void scalar::get(decimal64& x) const { ok(PN_DECIMAL64); byte_copy(x, atom_.u.as_decimal64); }
+void scalar::get(decimal128& x) const { ok(PN_DECIMAL128); byte_copy(x, atom_.u.as_decimal128); }
+void scalar::get(uuid& x) const { ok(PN_UUID); byte_copy(x, atom_.u.as_uuid); }
 void scalar::get(amqp_string& x) const { ok(PN_STRING); x = amqp_string(str_); }
 void scalar::get(amqp_symbol& x) const { ok(PN_SYMBOL); x = amqp_symbol(str_); }
 void scalar::get(amqp_binary& x) const { ok(PN_BINARY); x = amqp_binary(str_); }
@@ -154,13 +180,13 @@ template <class T, class F> T type_switch(const scalar& a, F f) {
       case CHAR: return f(a.get<wchar_t>());
       case ULONG: return f(a.get<uint64_t>());
       case LONG: return f(a.get<int64_t>());
-      case TIMESTAMP: return f(a.get<amqp_timestamp>());
+      case TIMESTAMP: return f(a.get<timestamp>());
       case FLOAT: return f(a.get<float>());
       case DOUBLE: return f(a.get<double>());
-      case DECIMAL32: return f(a.get<amqp_decimal32>());
-      case DECIMAL64: return f(a.get<amqp_decimal64>());
-      case DECIMAL128: return f(a.get<amqp_decimal128>());
-      case UUID: return f(a.get<amqp_uuid>());
+      case DECIMAL32: return f(a.get<decimal32>());
+      case DECIMAL64: return f(a.get<decimal64>());
+      case DECIMAL128: return f(a.get<decimal128>());
+      case UUID: return f(a.get<uuid>());
       case BINARY: return f(a.get<amqp_binary>());
       case STRING: return f(a.get<amqp_string>());
       case SYMBOL: return f(a.get<amqp_symbol>());

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/src/scalar_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/scalar_test.cpp b/proton-c/bindings/cpp/src/scalar_test.cpp
index a9700b0..c444acd 100644
--- a/proton-c/bindings/cpp/src/scalar_test.cpp
+++ b/proton-c/bindings/cpp/src/scalar_test.cpp
@@ -24,6 +24,7 @@
 #include <proton/value.hpp>
 #include <proton/message_id.hpp>
 #include <proton/annotation_key.hpp>
+#include <proton/decimal.hpp>
 
 #include <sstream>
 
@@ -76,7 +77,7 @@ void convert_test() {
 
     a = int16_t(42);
     ASSERT_MISMATCH(a.get<std::string>(), STRING, SHORT);
-    ASSERT_MISMATCH(a.get<amqp_timestamp>(), TIMESTAMP, SHORT);
+    ASSERT_MISMATCH(a.get<timestamp>(), TIMESTAMP, SHORT);
     ASSERT_MISMATCH(a.as_string(), STRING, SHORT);
     ASSERT_EQUAL(a.as_int(), 42);
     ASSERT_EQUAL(a.as_uint(), 42);
@@ -105,7 +106,8 @@ void message_id_test() {
     ASSERT_EQUAL(scalar("foo"), message_id("foo"));
     ASSERT_EQUAL("foo", message_id("foo").as_string());
     ASSERT(message_id("a") < message_id("z"));
-    ASSERT_EQUAL(amqp_uuid(), message_id(amqp_uuid()).get<amqp_uuid>());
+    uuid r = uuid::random();
+    ASSERT_EQUAL(r, message_id(r).get<uuid>());
 }
 
 void annotation_key_test() {
@@ -115,6 +117,8 @@ void annotation_key_test() {
     ASSERT_EQUAL(scalar(amqp_symbol("foo")), annotation_key("foo"));
 }
 
+template <class T> T make(const char c) { T x; std::fill(x.begin(), x.end(), c); return x; }
+
 int main(int, char**) {
     int failed = 0;
     RUN_TEST(failed, type_test(false, BOOLEAN, true));
@@ -129,13 +133,11 @@ int main(int, char**) {
     RUN_TEST(failed, type_test(wchar_t(23), CHAR, wchar_t(24)));
     RUN_TEST(failed, type_test(amqp_float(1.234), FLOAT, amqp_float(2.345)));
     RUN_TEST(failed, type_test(amqp_double(11.2233), DOUBLE, amqp_double(12)));
-    RUN_TEST(failed, type_test(amqp_timestamp(0), TIMESTAMP, amqp_timestamp(1)));
-    RUN_TEST(failed, type_test(amqp_decimal32(0), DECIMAL32, amqp_decimal32(1)));
-    RUN_TEST(failed, type_test(amqp_decimal64(0), DECIMAL64, amqp_decimal64(1)));
-    pn_decimal128_t da = {0}, db = {1};
-    RUN_TEST(failed, type_test(amqp_decimal128(da), DECIMAL128, amqp_decimal128(db)));
-    pn_uuid_t ua = {0}, ub = {1};
-    RUN_TEST(failed, type_test(amqp_uuid(ua), UUID, amqp_uuid(ub)));
+    RUN_TEST(failed, type_test(timestamp(0), TIMESTAMP, timestamp(1)));
+    RUN_TEST(failed, type_test(make<decimal32>(0), DECIMAL32, make<decimal32>(1)));
+    RUN_TEST(failed, type_test(make<decimal64>(0), DECIMAL64, make<decimal64>(1)));
+    RUN_TEST(failed, type_test(make<decimal128>(0), DECIMAL128, make<decimal128>(1)));
+    RUN_TEST(failed, type_test(uuid::make("a"), UUID, uuid::make("x")));
     RUN_TEST(failed, type_test(amqp_string("aaa"), STRING, amqp_string("aaaa")));
     RUN_TEST(failed, type_test(amqp_symbol("aaa"), SYMBOL, amqp_symbol("aaaa")));
     RUN_TEST(failed, type_test(amqp_binary("aaa"), BINARY, amqp_binary("aaaa")));

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/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 1ace1a1..6f5b0d9 100644
--- a/proton-c/bindings/cpp/src/types.cpp
+++ b/proton-c/bindings/cpp/src/types.cpp
@@ -27,19 +27,6 @@
 namespace proton {
 
 namespace {
-struct ios_guard {
-    std::ios &guarded;
-    std::ios old;
-    ios_guard(std::ios& x) : guarded(x), old(0) { old.copyfmt(guarded); }
-    ~ios_guard() { guarded.copyfmt(old); }
-};
-
-inline std::ostream& print_segment(std::ostream& o, const amqp_uuid& u, size_t begin, size_t end, const char* sep="") {
-    ios_guard restore_flags(o);
-    for (const char* p = &u[begin]; p < &u[end]; ++p)
-        o << std::setw(2) << std::setfill('0') << (int(*p) & 0xff);
-    return o << sep;
-}
 
 std::string mismatch_message(type_id want, type_id got, const std::string& msg=std::string()) {
     std::ostringstream s;
@@ -53,23 +40,6 @@ type_error::type_error(type_id want_, type_id got_, const std::string &msg)
     : decode_error(mismatch_message(want_, got_, msg)), want(want_), got(got_)
 {}
 
-std::ostream& operator<<(std::ostream& o, const amqp_decimal32&) { return o << "<decimal32>"; }
-std::ostream& operator<<(std::ostream& o, const amqp_decimal64&) { return o << "<decimal64>"; }
-std::ostream& operator<<(std::ostream& o, const amqp_decimal128&) { return o << "<decimal128>"; }
-std::ostream& operator<<(std::ostream& o, const amqp_timestamp& ts) { return o << "timestamp:" << ts.milliseconds; }
-
-std::ostream& operator<<(std::ostream& o, const amqp_uuid& u) {
-    std::ios_base::fmtflags ff = o.flags();
-    o.flags(std::ios_base::hex);
-    print_segment(o, u, 0, 4, "-");
-    print_segment(o, u, 4, 6, "-");
-    print_segment(o, u, 6, 8, "-");
-    print_segment(o, u, 8, 10, "-");
-    print_segment(o, u, 10, 16);
-    o.flags(ff);
-    return o;
-}
-
 std::string type_name(type_id t) {
     switch (t) {
       case NULL_TYPE: return "null";

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/src/types_internal.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/types_internal.hpp b/proton-c/bindings/cpp/src/types_internal.hpp
new file mode 100644
index 0000000..a77168d
--- /dev/null
+++ b/proton-c/bindings/cpp/src/types_internal.hpp
@@ -0,0 +1,39 @@
+#ifndef CODEC_HPP
+#define CODEC_HPP
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "proton/type_traits.hpp"
+
+///@file
+/// Internal helpers for encode/decode/type conversion.
+
+namespace proton {
+
+/// Byte copy between two objects, only enabled if their sizes are equal.
+template <class T, class U>
+typename enable_if<sizeof(T) == sizeof(U)>::type byte_copy(T &to, const U &from) {
+    const char *p = reinterpret_cast<const char*>(&from);
+    std::copy(p, p + sizeof(T), reinterpret_cast<char*>(&to));
+}
+
+
+}
+
+#endif // CODEC_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/src/uuid.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/uuid.cpp b/proton-c/bindings/cpp/src/uuid.cpp
index 6e8367f..9e64cca 100644
--- a/proton-c/bindings/cpp/src/uuid.cpp
+++ b/proton-c/bindings/cpp/src/uuid.cpp
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-#include "uuid.hpp"
+#include "proton/uuid.hpp"
 
 #include <cstdlib>
 #include <ctime>
@@ -56,9 +56,19 @@ struct ios_guard {
 };
 }
 
-uuid::uuid() {
+uuid uuid::make(const char* bytes) {
+    uuid u;
+    if (bytes)
+        std::copy(bytes, bytes + u.size(), u.begin());
+    else
+        std::fill(u.begin(), u.end(), 0);
+    return u;
+}
+
+uuid uuid::random() {
+    uuid bytes;
     int r = std::rand();
-    for (size_t i = 0; i < sizeof(bytes); ++i ) {
+    for (size_t i = 0; i < bytes.size(); ++i ) {
         bytes[i] = r & 0xFF;
         r >>= 8;
         if (!r) r = std::rand();
@@ -69,6 +79,7 @@ uuid::uuid() {
 
     // From RFC4122, the top two bits of byte 8 get set to 01
     bytes[8] = (bytes[8] & 0x3F) | 0x80;
+    return bytes;
 }
 
 /// UUID standard format: 8-4-4-4-12 (36 chars, 32 alphanumeric and 4 hypens)
@@ -76,7 +87,7 @@ std::ostream& operator<<(std::ostream& o, const uuid& u) {
     ios_guard restore_flags(o);
     o << std::hex << std::setfill('0');
     static const int segments[] = {4,2,2,2,6}; // 1 byte is 2 hex chars.
-    const uint8_t *p = u.bytes;
+    const char *p = u.begin();
     for (size_t i = 0; i < sizeof(segments)/sizeof(segments[0]); ++i) {
         if (i > 0)
             o << '-';

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/proton-c/bindings/cpp/src/uuid.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/uuid.hpp b/proton-c/bindings/cpp/src/uuid.hpp
deleted file mode 100644
index e8ee908..0000000
--- a/proton-c/bindings/cpp/src/uuid.hpp
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef UUID_HPP
-#define UUID_HPP
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <proton/types.hpp>
-
-#include <string>
-#include <iosfwd>
-
-namespace proton {
-
-/// A random UUID.
-struct uuid {
-    PN_CPP_EXTERN uuid();
-    uint8_t bytes[16];
-    PN_CPP_EXTERN std::string str()  const;
-};
-
-/// UUID standard format: 8-4-4-4-12 (36 chars, 32 alphanumeric and 4 hypens)
-PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const uuid&);
-
-}
-
-#endif // UUID_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71be1c69/tests/tools/apps/cpp/reactor_send.cpp
----------------------------------------------------------------------
diff --git a/tests/tools/apps/cpp/reactor_send.cpp b/tests/tools/apps/cpp/reactor_send.cpp
index 76fa9dc..6a6e8b6 100644
--- a/tests/tools/apps/cpp/reactor_send.cpp
+++ b/tests/tools/apps/cpp/reactor_send.cpp
@@ -74,8 +74,7 @@ class reactor_send : public proton::handler {
         while (sender.credit() && sent_ < total_) {
             id_value_ = sent_ + 1;
             message_.correlation_id(id_value_);
-            proton::amqp_timestamp reactor_now(reactor_.now());
-            message_.creation_time(reactor_now);
+            message_.creation_time(reactor_.now());
             sender.send(message_);
             sent_++;
         }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[4/6] qpid-proton git commit: PROTON-1138: Simplify comparable class, make comparable inheritance private.

Posted by ac...@apache.org.
PROTON-1138: Simplify comparable class, make comparable inheritance private.

Simplified the comparable class.

- comparable<T> is a private empty base class that exists only to instantiate operator friends of T.
- comparable<T> is never used in any other way.
- for any compiler with even rudimentary empty-base-class support, this has 0 run-time overhead.

I did some research to try and eliminate inheritance entirely. There are 2 well
known approaches.

1. boost::operators uses exactly the approach above.
2. std::rel_ops uses unconstrained templates that match anything with op == or < operator, we already agreed that approach is unsuitable for public API.

I tried type-trait approaches but could not find one that was better than the
above.  IMO inheritance is the right fit: It has no run-time overhead, it is
easy to understand, and we *want* "is-a" inheritance semantics: if `object` is
comparable then sub-classes of `object` should be comparable. (That is the part
that is hard to achieve with type-traits. When I realized I was trying to
reinvent inheritance I decided to let go.)


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/c7f3f558
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/c7f3f558
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/c7f3f558

Branch: refs/heads/master
Commit: c7f3f558511ed07b8972304a2ba7a69dfc6b6354
Parents: 71be1c6
Author: Alan Conway <ac...@redhat.com>
Authored: Mon Feb 22 11:28:54 2016 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Thu Feb 25 17:50:55 2016 -0500

----------------------------------------------------------------------
 .../bindings/cpp/include/proton/byte_array.hpp  |  2 +-
 .../bindings/cpp/include/proton/comparable.hpp  | 25 ++++++--------------
 .../bindings/cpp/include/proton/duration.hpp    |  2 +-
 .../bindings/cpp/include/proton/endpoint.hpp    |  2 +-
 proton-c/bindings/cpp/include/proton/object.hpp |  4 ++--
 proton-c/bindings/cpp/include/proton/scalar.hpp |  4 ++--
 .../bindings/cpp/include/proton/timestamp.hpp   |  2 +-
 proton-c/bindings/cpp/include/proton/value.hpp  |  2 +-
 8 files changed, 16 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7f3f558/proton-c/bindings/cpp/include/proton/byte_array.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/byte_array.hpp b/proton-c/bindings/cpp/include/proton/byte_array.hpp
index 1319eae..88b05aa 100644
--- a/proton-c/bindings/cpp/include/proton/byte_array.hpp
+++ b/proton-c/bindings/cpp/include/proton/byte_array.hpp
@@ -28,7 +28,7 @@ namespace proton {
 
 /// Used to represent fixed-sized data types that don't have a natural C++ representation
 /// as an array of bytes.
-template <size_t N> class byte_array : public comparable<byte_array<N> > {
+template <size_t N> class byte_array : private comparable<byte_array<N> > {
   public:
     /// Initially all 0.
     byte_array() : bytes_() {}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7f3f558/proton-c/bindings/cpp/include/proton/comparable.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/comparable.hpp b/proton-c/bindings/cpp/include/proton/comparable.hpp
index 6c64249..e0c3d85 100644
--- a/proton-c/bindings/cpp/include/proton/comparable.hpp
+++ b/proton-c/bindings/cpp/include/proton/comparable.hpp
@@ -28,26 +28,15 @@ namespace proton {
 
 /// Base class for comparable types with operator< and
 /// operator==. Provides remaining operators.
-template <class T> class comparable {};
+template <class T> class comparable {
+    friend bool operator>(const T &a, const T &b) { return b < a; }
+    friend bool operator<=(const T &a, const T &b) { return !(a > b); }
+    friend bool operator>=(const T &a, const T &b) { return !(a < b); }
+    friend bool operator!=(const T &a, const T &b) { return !(a == b); }
+};
 
-template <class T> bool operator>(const comparable<T> &a, const comparable<T> &b) {
-    return static_cast<const T&>(b) < static_cast<const T&>(a);
-}
-
-template <class T> bool operator<=(const comparable<T> &a, const comparable<T> &b) {
-    return !(static_cast<const T&>(a) > static_cast<const T&>(b));
-}
-
-template <class T> bool operator>=(const comparable<T> &a, const comparable<T> &b) {
-    return !(static_cast<const T&>(a) < static_cast<const T&>(b));
-}
-
-template <class T> bool operator!=(const comparable<T> &a, const comparable<T> &b) {
-    return !(static_cast<const T&>(a) == static_cast<const T&>(b));
-}
+///@endcond
 
 }
 
-///@endcond
-
 #endif // COMPARABLE_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7f3f558/proton-c/bindings/cpp/include/proton/duration.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/duration.hpp b/proton-c/bindings/cpp/include/proton/duration.hpp
index 193e162..c8a38cc 100644
--- a/proton-c/bindings/cpp/include/proton/duration.hpp
+++ b/proton-c/bindings/cpp/include/proton/duration.hpp
@@ -31,7 +31,7 @@
 namespace proton {
 
 /// A span of time in milliseconds.
-class duration : public comparable<duration> {
+class duration : private comparable<duration> {
   public:
     explicit duration(int64_t ms = 0) : ms_(ms) {}
     duration& operator=(int64_t ms) { ms_ = ms; return *this; }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7f3f558/proton-c/bindings/cpp/include/proton/endpoint.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/endpoint.hpp b/proton-c/bindings/cpp/include/proton/endpoint.hpp
index 8a8712e..aedacfb 100644
--- a/proton-c/bindings/cpp/include/proton/endpoint.hpp
+++ b/proton-c/bindings/cpp/include/proton/endpoint.hpp
@@ -78,7 +78,7 @@ PN_CPP_CLASS_EXTERN endpoint {
 /// @cond INTERNAL
 /// XXX move to internal
 
-template <class T> class iter_base  : public comparable<iter_base<T> > {
+template <class T> class iter_base {
   public:
     typedef T value_type;
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7f3f558/proton-c/bindings/cpp/include/proton/object.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/object.hpp b/proton-c/bindings/cpp/include/proton/object.hpp
index 4e12e6f..8f4dfb2 100644
--- a/proton-c/bindings/cpp/include/proton/object.hpp
+++ b/proton-c/bindings/cpp/include/proton/object.hpp
@@ -35,7 +35,7 @@ class pn_ptr_base {
     PN_CPP_EXTERN static void decref(void* p);
 };
 
-template <class T> class pn_ptr : private pn_ptr_base, public comparable<pn_ptr<T> > {
+template <class T> class pn_ptr : private pn_ptr_base, private comparable<pn_ptr<T> > {
   public:
     pn_ptr() : ptr_(0) {}
     pn_ptr(T* p) : ptr_(p) { incref(ptr_); }
@@ -69,7 +69,7 @@ template <class T> class pn_ptr : private pn_ptr_base, public comparable<pn_ptr<
 template <class T> pn_ptr<T> take_ownership(T* p) { return pn_ptr<T>::take_ownership(p); }
 
 /// Base class for proton object types.
-template <class T> class object : public comparable<object<T> > {
+template <class T> class object : private comparable<object<T> > {
   public:
     bool operator!() const { return !object_; }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7f3f558/proton-c/bindings/cpp/include/proton/scalar.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/scalar.hpp b/proton-c/bindings/cpp/include/proton/scalar.hpp
index 05fdde3..6d8ed8c 100644
--- a/proton-c/bindings/cpp/include/proton/scalar.hpp
+++ b/proton-c/bindings/cpp/include/proton/scalar.hpp
@@ -37,7 +37,7 @@ class timestamp;
 class uuid;
 
 /// A holder for an instance of any scalar AMQP type.
-class scalar : public comparable<scalar> {
+class scalar : private comparable<scalar> {
   public:
     /// Create an empty scalar.
     PN_CPP_EXTERN scalar();
@@ -160,7 +160,7 @@ class scalar : public comparable<scalar> {
 /// XXX should it be public?
     
 /// Base class for restricted scalar types.
-class restricted_scalar : public comparable<restricted_scalar> {
+class restricted_scalar : private comparable<restricted_scalar> {
   public:
     operator const scalar&() const { return scalar_; }
     type_id type() const { return scalar_.type(); }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7f3f558/proton-c/bindings/cpp/include/proton/timestamp.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/timestamp.hpp b/proton-c/bindings/cpp/include/proton/timestamp.hpp
index 1cfb231..589072f 100644
--- a/proton-c/bindings/cpp/include/proton/timestamp.hpp
+++ b/proton-c/bindings/cpp/include/proton/timestamp.hpp
@@ -23,7 +23,7 @@
 
 namespace proton {
 /// A timestamp in milliseconds since the epoch 00:00:00 (UTC), 1 January 1970.
-class timestamp : public comparable<timestamp> {
+class timestamp : private comparable<timestamp> {
   public:
     explicit timestamp(int64_t ms = 0) : ms_(ms) {}
     timestamp& operator=(int64_t ms) { ms_ = ms; return *this; }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7f3f558/proton-c/bindings/cpp/include/proton/value.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/value.hpp b/proton-c/bindings/cpp/include/proton/value.hpp
index 783f56e..e6cfec0 100644
--- a/proton-c/bindings/cpp/include/proton/value.hpp
+++ b/proton-c/bindings/cpp/include/proton/value.hpp
@@ -32,7 +32,7 @@ namespace proton {
 /// A proton::value can hold any AMQP data value, simple or compound.
 /// It has assignment and conversion operators to convert its contents
 /// easily to and from native C++ types.
-class value : public comparable<value> {
+class value : private comparable<value> {
   public:
     /// Create an empty value.
     PN_CPP_EXTERN value();


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[6/6] qpid-proton git commit: PROTON-1138: c++: Remove value_* types, add amqp:: typedefs.

Posted by ac...@apache.org.
PROTON-1138: c++: Remove value_* types, add amqp:: typedefs.

Consistently use either native C++ types or types defined in the proton:: namespace in the API.

The proton::amqp namespace contains typedefs and documentation explaining the
relationship between the AMQP type system and the C++/proton types. Its use is
optional, a C++ programmer will most likely use the C++ types directly. However
an AMQP programmer working in multiple languages may find it convenient to use
the AMQP type names consistently across languages.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/a0fa5ce2
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/a0fa5ce2
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/a0fa5ce2

Branch: refs/heads/master
Commit: a0fa5ce2323179d04726243f20d71daa78cbbb81
Parents: 8cbde66
Author: Alan Conway <ac...@redhat.com>
Authored: Thu Feb 25 17:14:43 2016 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Thu Feb 25 18:25:49 2016 -0500

----------------------------------------------------------------------
 examples/cpp/encode_decode.cpp                  |  14 +-
 proton-c/bindings/cpp/include/proton/amqp.hpp   | 102 ++++++++++++++
 .../cpp/include/proton/annotation_key.hpp       |  16 +--
 proton-c/bindings/cpp/include/proton/binary.hpp |  37 ++++++
 .../bindings/cpp/include/proton/comparable.hpp  |   4 -
 .../bindings/cpp/include/proton/decoder.hpp     | 133 ++++---------------
 .../bindings/cpp/include/proton/encoder.hpp     |  92 +++----------
 .../bindings/cpp/include/proton/message_id.hpp  |  39 +++---
 proton-c/bindings/cpp/include/proton/scalar.hpp |  36 ++---
 proton-c/bindings/cpp/include/proton/symbol.hpp |  35 +++++
 .../bindings/cpp/include/proton/type_traits.hpp |  49 +++----
 proton-c/bindings/cpp/include/proton/types.hpp  |  36 +----
 proton-c/bindings/cpp/include/proton/uuid.hpp   |   2 -
 proton-c/bindings/cpp/include/proton/value.hpp  |   3 +
 proton-c/bindings/cpp/src/data.cpp              |  34 ++---
 proton-c/bindings/cpp/src/decoder.cpp           |  31 ++---
 proton-c/bindings/cpp/src/encoder.cpp           |  44 +++---
 proton-c/bindings/cpp/src/interop_test.cpp      |  13 +-
 proton-c/bindings/cpp/src/link_options.cpp      |  12 +-
 proton-c/bindings/cpp/src/message.cpp           |  22 +--
 proton-c/bindings/cpp/src/messaging_adapter.cpp |   2 +-
 proton-c/bindings/cpp/src/scalar.cpp            |  22 +--
 proton-c/bindings/cpp/src/scalar_test.cpp       |  37 +++---
 proton-c/bindings/cpp/src/sender.cpp            |   4 +-
 proton-c/bindings/cpp/src/types.cpp             |   7 -
 proton-c/bindings/cpp/src/types_internal.hpp    |   9 ++
 proton-c/bindings/cpp/src/value_test.cpp        |  36 ++---
 tests/tools/apps/cpp/reactor_send.cpp           |   5 +-
 28 files changed, 445 insertions(+), 431 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/examples/cpp/encode_decode.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/encode_decode.cpp b/examples/cpp/encode_decode.cpp
index 9c14ade..b2a07ae 100644
--- a/examples/cpp/encode_decode.cpp
+++ b/examples/cpp/encode_decode.cpp
@@ -18,6 +18,7 @@
  */
 
 #include <proton/value.hpp>
+#include <proton/symbol.hpp>
 #include <algorithm>
 #include <iostream>
 #include <iterator>
@@ -108,7 +109,7 @@ void mixed_containers() {
 
     std::vector<proton::value> l;
     l.push_back(proton::value(42));
-    l.push_back(proton::value(proton::amqp_string("foo")));
+    l.push_back(proton::value(std::string("foo")));
     // By default, a sequence of proton::value is treated as an AMQP list.
     v = l;
     print(v);
@@ -118,8 +119,7 @@ void mixed_containers() {
 
     std::map<proton::value, proton::value> m;
     m[proton::value("five")] = proton::value(5);
-    m[proton::value(4)] = proton::value("four");
-    v = m;
+    m[proton::value(4)] = proton::value("four"); v = m;
     print(v);
     std::map<proton::value, proton::value> m2;
     v.get(m2);
@@ -133,20 +133,20 @@ void insert_stream_operators() {
 
     // Create an array of INT with values [1, 2, 3]
     v.encode() << proton::start::array(proton::INT)
-                << proton::amqp_int(1) << proton::amqp_int(2) << proton::amqp_int(3)
+                << int32_t(1) << int32_t(2) << int32_t(3)
                 << proton::finish();
     print(v);
 
     // Create a mixed-type list of the values [42, false, "x"].
     v.encode() << proton::start::list()
-                << proton::amqp_int(42) << false << proton::amqp_symbol("x")
+                << int32_t(42) << false << proton::symbol("x")
                 << proton::finish();
     print(v);
 
     // Create a map { "k1":42, "k2": false }
     v.encode() << proton::start::map()
-                << "k1" << proton::amqp_int(42)
-                << proton::amqp_symbol("k2") << false
+                << "k1" << int32_t(42)
+                << proton::symbol("k2") << false
                 << proton::finish();
     print(v);
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/proton-c/bindings/cpp/include/proton/amqp.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/amqp.hpp b/proton-c/bindings/cpp/include/proton/amqp.hpp
new file mode 100644
index 0000000..43662ce
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/amqp.hpp
@@ -0,0 +1,102 @@
+#ifndef PROTON_AMQP_HPP
+#define PROTON_AMQP_HPP
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "proton/types.hpp"
+
+#include <string>
+
+namespace proton {
+
+class uuid;
+class binary;
+class symbol;
+class timestamp;
+class uuid;
+class decimal32;
+class decimal64;
+class decimal128;
+
+/// This namespace contains typedefs to associate AMQP scalar type names with
+/// the corresponding C++ types. These are provided as a convenience for those
+/// familiar with AMQP, you do not need to use them, you can use the C++ types
+/// directly.
+///
+/// The typedef names have a _type suffix to avoid ambiguity with C++ reserved
+/// and std library type names.
+///
+namespace amqp {
+
+///@name Typedefs for AMQP numeric types.
+///@{
+///@ Boolean true or false.
+typedef bool boolean_type;
+///@ 8-bit unsigned byte 
+typedef uint8_t ubyte_type;
+///@ 8-bit signed byte
+typedef int8_t byte_type;
+///@ 16-bit unsigned short integer
+typedef uint16_t ushort_type;
+///@ 16-bit signed short integer
+typedef int16_t short_type;
+///@ 32-bit unsigned integer
+typedef uint32_t uint_type;
+///@ 32-bit signed integer
+typedef int32_t int_type;
+///@ 64-bit unsigned long integer
+typedef uint64_t ulong_type;
+///@ 64-bit signed long integer
+typedef int64_t long_type;
+///@ 32-bit unicode code point
+typedef wchar_t char_type;
+///@ 32-bit binary floating point
+typedef float float_type;
+///@ 64-bit binary floating point
+typedef double double_type;
+///@}
+
+/// An AMQP string is unicode  UTF-8 encoded.
+typedef std::string string_type;
+
+/// An AMQP string is ASCII 7-bit  encoded.
+typedef proton::symbol symbol_type;
+
+/// An AMQP binary contains variable length raw binary data.
+typedef proton::binary binary_type;
+
+/// A timestamp in milliseconds since the epoch 00:00:00 (UTC), 1 January 1970.
+typedef proton::timestamp timestamp_type;
+
+/// A 16-byte universally unique identifier.
+typedef proton::uuid uuid_type;
+
+///@name AMQP decimal floating point types.
+///
+/// These are not usable as arithmetic types in C++. You can pass them on over
+/// AMQP or convert the raw bytes using a decimal support library. @see proton::decimal.
+/// @{
+typedef proton::decimal32 decimal32_type;
+typedef proton::decimal64 decimal64_type;
+typedef proton::decimal128 decimal128_type;
+///@}
+
+}}
+
+#endif // PROTON_AMQP_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/proton-c/bindings/cpp/include/proton/annotation_key.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/annotation_key.hpp b/proton-c/bindings/cpp/include/proton/annotation_key.hpp
index 69138ca..5610f23 100644
--- a/proton-c/bindings/cpp/include/proton/annotation_key.hpp
+++ b/proton-c/bindings/cpp/include/proton/annotation_key.hpp
@@ -22,16 +22,16 @@
 
 #include "proton/types.hpp"
 #include "proton/scalar.hpp"
+#include "proton/symbol.hpp"
 
 namespace proton {
-    
+
 class encoder;
 class decoder;
 
 /// A key for use with AMQP annotation maps.
 ///
-/// An annotation_key can contain either a uint64_t or a
-/// proton::amqp::amqp_symbol.
+/// An annotation_key can contain either a uint64_t or a proton::symbol.
 class annotation_key : public restricted_scalar {
   public:
     /// Create an empty key.
@@ -43,11 +43,9 @@ class annotation_key : public restricted_scalar {
     ///
     /// @{
     annotation_key& operator=(uint64_t x) { scalar_ = x; return *this; }
-    annotation_key& operator=(const amqp_symbol& x) { scalar_ = x; return *this; }
-    /// `std::string` is encoded as proton::amqp::amqp_symbol.
-    annotation_key& operator=(const std::string& x) { scalar_ = amqp_symbol(x); return *this; }
-    /// `char*` is encoded as proton::amqp::amqp_symbol.
-    annotation_key& operator=(const char *x) { scalar_ = amqp_symbol(x); return *this; }
+    annotation_key& operator=(const symbol& x) { scalar_ = x; return *this; }
+    /// `char*` is encoded as proton::amqp::symbol.
+    annotation_key& operator=(const char *x) { scalar_ = symbol(x); return *this; }
     /// @}
 
     /// A constructor that converts from any type that we can assign
@@ -58,7 +56,7 @@ class annotation_key : public restricted_scalar {
     ///
     /// @{
     void get(uint64_t& x) const { scalar_.get(x); }
-    void get(amqp_symbol& x) const { scalar_.get(x); }
+    void get(symbol& x) const { scalar_.get(x); }
     /// @}
 
     /// Return the value as type T.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/proton-c/bindings/cpp/include/proton/binary.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/binary.hpp b/proton-c/bindings/cpp/include/proton/binary.hpp
new file mode 100644
index 0000000..e673854
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/binary.hpp
@@ -0,0 +1,37 @@
+#ifndef BINARY_HPP
+#define BINARY_HPP
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <string>
+
+namespace proton {
+
+/// symbol is a std::string that represents the AMQP symbol type.
+/// A symbol can only contain 7-bit ASCII characters.
+///
+class binary : public std::string {
+  public:
+    explicit binary(const std::string& s=std::string()) : std::string(s) {}
+    explicit binary(const char* s) : std::string(s) {}
+};
+
+}
+
+#endif // BINARY_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/proton-c/bindings/cpp/include/proton/comparable.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/comparable.hpp b/proton-c/bindings/cpp/include/proton/comparable.hpp
index e0c3d85..8bf0e47 100644
--- a/proton-c/bindings/cpp/include/proton/comparable.hpp
+++ b/proton-c/bindings/cpp/include/proton/comparable.hpp
@@ -20,10 +20,6 @@
  * under the License.
  */
 
-/// @cond INTERNAL
-/// XXX revisit with alan - adds spurious superclasses
-/// XXX decision - remove; use type traits to include this behavior
-
 namespace proton {
 
 /// Base class for comparable types with operator< and

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/proton-c/bindings/cpp/include/proton/decoder.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/decoder.hpp b/proton-c/bindings/cpp/include/proton/decoder.hpp
index 1089d32..a96be88 100644
--- a/proton-c/bindings/cpp/include/proton/decoder.hpp
+++ b/proton-c/bindings/cpp/include/proton/decoder.hpp
@@ -69,90 +69,10 @@ struct assert_type {
 /** Rewind the decoder with `dec >> rewind()`. */
 struct rewind{};
 
-/**
-Stream-like decoder from AMQP bytes to C++ values.
-
-@see types.hpp defines C++ types corresponding to AMQP types.
-
-The decoder operator>> will extract AMQP types into any compatible C++
-type or throw an exception if the types are not compatible.
-
-+-------------------------+-------------------------------+
-|AMQP type                |Compatible C++ types           |
-+=========================+===============================+
-|BOOLEAN                  |amqp_boolean, bool             |
-+-------------------------+-------------------------------+
-|signed integer type I    |C++ signed integer type T where|
-|                         |sizeof(T) >= sizeof(I)         |
-+-------------------------+-------------------------------+
-|unsigned integer type U  |C++ unsigned integer type T    |
-|                         |where sizeof(T) >= sizeof(U)   |
-+-------------------------+-------------------------------+
-|CHAR                     |amqp_char, wchar_t             |
-+-------------------------+-------------------------------+
-|FLOAT                    |amqp_float, float              |
-+-------------------------+-------------------------------+
-|DOUBLE                   |amqp_double, double            |
-+-------------------------+-------------------------------+
-|STRING                   |amqp_string, std::string       |
-+-------------------------+-------------------------------+
-|SYMBOL                   |amqp_symbol, std::string       |
-+-------------------------+-------------------------------+
-|BINARY                   |amqp_binary, std::string       |
-+-------------------------+-------------------------------+
-|DECIMAL32/64/128         |decimal32/64/128               |
-+-------------------------+-------------------------------+
-|TIMESTAMP                |timestamp                      |
-+-------------------------+-------------------------------+
-|UUID                     |uuid                           |
-+-------------------------+-------------------------------+
-
-The special proton::value type can hold any AMQP type, simple or compound.
-
-By default operator >> will do any conversion that does not lose data. For example
-any AMQP signed integer type can be extracted as follows:
-
-    int64_t i;
-    dec >> i;
-
-You can assert the exact AMQP type with proton::assert_type, for example
-the following will throw if the AMQP type is not an AMQP INT (32 bits)
-
-    amqp_int i;
-    dec >> assert_type(INT) >> i;       // Will throw if decoder does not contain an INT
-
-You can extract AMQP ARRAY, LIST or MAP into standard C++ containers of compatible types, for example:
-
-    std::vector<int32_t> v;
-    dec >> v;
-
-This will work if the decoder contains an AMQP ARRAY or LIST of SHORT or INT values. It won't work
-for LONG or other types. It will also work for a MAP with keys and values that are SHORT OR INT,
-the map will be "flattened" into a sequence [ key1, value1, key2, value2 ] This will work with
-std::dequeue, std::array, std::list or std::forward_list.
-
-You can extract a MAP into a std::map or std::unordered_map
-
-    std::map<std::string, std::string> v;
-    dec >> v;
-
-This will work for any AMQP map with keys and values that are STRING, SYMBOL or BINARY.
-
-If you have non-standard container types that meet the most basic requirements for
-the container or associative-container concepts, you can use them via helper functions:
-
-    my_sequence_type<int64_t> s;
-    dec >> proton::to_sequence(s); // Decode sequence of integers
-    my_map_type<amqp_string, bool> s;
-    dec >> proton::to_map(s); // Decode map of string: bool.
-
-Finally you can extract an AMQP LIST with mixed type elements into a container of proton::value, e.g.
-
-    std::vector<proton::value> v;
-    dec >> v;
-
-You can also extract container values element-by-element, see decoder::operator>>(decoder&, start&)
-*/
+/// Stream-like decoder from AMQP bytes to C++ values.
+///
+/// Internal use only, see proton::value, proton::scalar and proton::amqp
+/// for the recommended ways to manage AMQP data.
 class decoder : public object<pn_data_t> {
   public:
     decoder(pn_data_t* d) : object<pn_data_t>(d) {}
@@ -193,29 +113,28 @@ class decoder : public object<pn_data_t> {
      * @throw error if the decoder is empty or the current value has an incompatible type.
      * @{
      */
-    PN_CPP_EXTERN friend decoder operator>>(decoder, amqp_null);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, amqp_boolean&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, amqp_ubyte&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, amqp_byte&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, amqp_ushort&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, amqp_short&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, amqp_uint&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, amqp_int&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, amqp_char&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, amqp_ulong&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, amqp_long&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, timestamp&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, amqp_float&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, amqp_double&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, decimal32&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, decimal64&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, decimal128&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, uuid&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, std::string&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, message_id&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, annotation_key&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, value&);
-    PN_CPP_EXTERN friend decoder operator>>(decoder, scalar&);
+  friend PN_CPP_EXTERN decoder operator>>(decoder, bool&);
+  friend PN_CPP_EXTERN decoder operator>>(decoder, uint8_t&);
+  friend PN_CPP_EXTERN decoder operator>>(decoder, int8_t&);
+  friend PN_CPP_EXTERN decoder operator>>(decoder, uint16_t&);
+  friend PN_CPP_EXTERN decoder operator>>(decoder, int16_t&);
+  friend PN_CPP_EXTERN decoder operator>>(decoder, uint32_t&);
+  friend PN_CPP_EXTERN decoder operator>>(decoder, int32_t&);
+  friend PN_CPP_EXTERN decoder operator>>(decoder, wchar_t&);
+  friend PN_CPP_EXTERN decoder operator>>(decoder, uint64_t&);
+  friend PN_CPP_EXTERN decoder operator>>(decoder, int64_t&);
+  friend PN_CPP_EXTERN decoder operator>>(decoder, timestamp&);
+  friend PN_CPP_EXTERN decoder operator>>(decoder, float&);
+  friend PN_CPP_EXTERN decoder operator>>(decoder, double&);
+  friend PN_CPP_EXTERN decoder operator>>(decoder, decimal32&);
+  friend PN_CPP_EXTERN decoder operator>>(decoder, decimal64&);
+  friend PN_CPP_EXTERN decoder operator>>(decoder, decimal128&);
+  friend PN_CPP_EXTERN decoder operator>>(decoder, uuid&);
+  friend PN_CPP_EXTERN decoder operator>>(decoder, std::string&);
+  friend PN_CPP_EXTERN decoder operator>>(decoder, message_id&);
+  friend PN_CPP_EXTERN decoder operator>>(decoder, annotation_key&);
+  friend PN_CPP_EXTERN decoder operator>>(decoder, value&);
+  friend PN_CPP_EXTERN decoder operator>>(decoder, scalar&);
     ///@}
 
     /** Extract and return a value of type T. */

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/proton-c/bindings/cpp/include/proton/encoder.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/encoder.hpp b/proton-c/bindings/cpp/include/proton/encoder.hpp
index db9c35d..8fbb83a 100644
--- a/proton-c/bindings/cpp/include/proton/encoder.hpp
+++ b/proton-c/bindings/cpp/include/proton/encoder.hpp
@@ -69,52 +69,13 @@ template <class T, type_id A> const type_id cref<T, A>::type = A;
 
 /**
  * Indicate the desired AMQP type to use when encoding T.
- * For example to encode a vector as a list:
- *
- *     std::vector<amqp_int> v;
- *     encoder << as<LIST>(v);
  */
 template <type_id A, class T> cref<T, A> as(const T& value) { return cref<T, A>(value); }
 
-/**
- * Stream-like encoder from C++ values to AMQP values.
- *
- * types.hpp defines a C++ type for each AMQP type. For simple types they are
- * just typedefs for corresponding native C++ types. These types encode as the
- * corresponding AMQP type.
- *
- * There are some special case conversions:
- *
- * - Integer types other than those mentioned in types.hpp encode as the AMQP
- *   integer type of matching size and signedness.
- * - std::string or char* insert as AMQP STRING.
- *
- * For example to encode an AMQP INT, BOOLEAN and STRING these are equivalent:
- *
- *     enc << proton::amqp_int(1) << proton::amqp_boolean(true) << proton::amqp_string("foo");
- *     enc << int32_t(1) << true << "foo";
- *
- * You can force the encoding using the `proton::as` template function, for example:
- *
- *     uint64_t i = 100;
- *     enc << as<proton::SHORT>(i);
- *
- * C++ standard containers can be inserted. By default:
- *
- * - std::map and std::unordered_map encode as AMQP MAP
- * - std::vector, std::deque, std::list, std::array or std::forward_list encode as an AMQP ARRAY.
- * - std::vector<proton::value> etc. encode as AMQP LIST
- *
- * Again you can force the encoding using proton::as<LIST>() or proton::as<ARRAY>()
- *
- * Note that you can encode a sequence of pairs as a map, which allows you to control the
- * encoded order if that is important:
- *
- *     std::vector<std::pair<T1, T2> > v;
- *     enc << proton::as<MAP>(v);
- *
- * You can also insert containers element-by-element, see operator<<(encoder&, const start&)
- */
+/// Stream-like encoder from AMQP bytes to C++ values.
+///
+/// Internal use only, see proton::value, proton::scalar and proton::amqp
+/// for the recommended ways to manage AMQP data.
 class encoder : public object<pn_data_t> {
   public:
     encoder(pn_data_t* e) : object<pn_data_t>(e) {}
@@ -143,27 +104,26 @@ class encoder : public object<pn_data_t> {
     /** @name Insert simple types.
      *@{
      */
-  friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_null);
-  friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_boolean);
-  friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_ubyte);
-  friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_byte);
-  friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_ushort);
-  friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_short);
-  friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_uint);
-  friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_int);
-  friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_char);
-  friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_ulong);
-  friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_long);
+  friend PN_CPP_EXTERN encoder operator<<(encoder, bool);
+  friend PN_CPP_EXTERN encoder operator<<(encoder, uint8_t);
+  friend PN_CPP_EXTERN encoder operator<<(encoder, int8_t);
+  friend PN_CPP_EXTERN encoder operator<<(encoder, uint16_t);
+  friend PN_CPP_EXTERN encoder operator<<(encoder, int16_t);
+  friend PN_CPP_EXTERN encoder operator<<(encoder, uint32_t);
+  friend PN_CPP_EXTERN encoder operator<<(encoder, int32_t);
+  friend PN_CPP_EXTERN encoder operator<<(encoder, wchar_t);
+  friend PN_CPP_EXTERN encoder operator<<(encoder, uint64_t);
+  friend PN_CPP_EXTERN encoder operator<<(encoder, int64_t);
   friend PN_CPP_EXTERN encoder operator<<(encoder, timestamp);
-  friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_float);
-  friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_double);
+  friend PN_CPP_EXTERN encoder operator<<(encoder, float);
+  friend PN_CPP_EXTERN encoder operator<<(encoder, double);
   friend PN_CPP_EXTERN encoder operator<<(encoder, decimal32);
   friend PN_CPP_EXTERN encoder operator<<(encoder, decimal64);
   friend PN_CPP_EXTERN encoder operator<<(encoder, decimal128);
   friend PN_CPP_EXTERN encoder operator<<(encoder, uuid);
-  friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_string);
-  friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_symbol);
-  friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_binary);
+  friend PN_CPP_EXTERN encoder operator<<(encoder, std::string);
+  friend PN_CPP_EXTERN encoder operator<<(encoder, symbol);
+  friend PN_CPP_EXTERN encoder operator<<(encoder, binary);
   friend PN_CPP_EXTERN encoder operator<<(encoder, const message_id&);
   friend PN_CPP_EXTERN encoder operator<<(encoder, const annotation_key&);
   friend PN_CPP_EXTERN encoder operator<<(encoder, const value&);
@@ -172,13 +132,6 @@ class encoder : public object<pn_data_t> {
 
     /**
      * Start a container type.
-     *
-     * Use one of the static functions start::array(), start::list(),
-     * start::map() or start::described() to create an appropriate start value
-     * and insert it into the encoder, followed by the contained elements.  For
-     * example:
-     *
-     *      enc << start::list() << amqp_int(1) << amqp_symbol("two") << 3.0 << finish();
      */
   friend PN_CPP_EXTERN encoder operator<<(encoder, const start&);
 
@@ -197,10 +150,9 @@ class encoder : public object<pn_data_t> {
     ///@}
 };
 
-// Need to disambiguate char* conversion to bool and std::string as amqp_string.
-inline encoder operator<<(encoder e, char* s) { return e << amqp_string(s); }
-inline encoder operator<<(encoder e, const char* s) { return e << amqp_string(s); }
-inline encoder operator<<(encoder e, const std::string& s) { return e << amqp_string(s); }
+// Treat char* as string
+inline encoder operator<<(encoder e, char* s) { return e << std::string(s); }
+inline encoder operator<<(encoder e, const char* s) { return e << std::string(s); }
 
 // operator << for integer types that are not covered by the standard overrides.
 template <class T>

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/proton-c/bindings/cpp/include/proton/message_id.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/message_id.hpp b/proton-c/bindings/cpp/include/proton/message_id.hpp
index ace58f9..3140f55 100644
--- a/proton-c/bindings/cpp/include/proton/message_id.hpp
+++ b/proton-c/bindings/cpp/include/proton/message_id.hpp
@@ -24,7 +24,7 @@
 #include "proton/scalar.hpp"
 
 namespace proton {
-    
+
 class encoder;
 class decoder;
 
@@ -33,13 +33,17 @@ class decoder;
 /// It can contain one of the following types:
 ///
 ///  - uint64_t
+///  - std::string
 ///  - proton::uuid
-///  - proton::amqp::amqp_binary
-///  - proton::amqp::amqp_string
+///  - proton::binary
+///
 class message_id : public restricted_scalar {
   public:
-    /// Create an empty (0) message ID.
-    message_id() { scalar_ = uint64_t(0); }
+    message_id(uint64_t x = 0) { scalar_ = x; }
+    message_id(const uuid& x) { scalar_ = x; }
+    message_id(const binary& x) { scalar_ = x; }
+    message_id(const std::string& x) { scalar_ = x; }
+    message_id(const char *x) { scalar_ = std::string(x); }
 
     /// @name Assignment operators
     ///
@@ -48,17 +52,12 @@ class message_id : public restricted_scalar {
     /// @{
     message_id& operator=(uint64_t x) { scalar_ = x; return *this; }
     message_id& operator=(const uuid& x) { scalar_ = x; return *this; }
-    message_id& operator=(const amqp_binary& x) { scalar_ = x; return *this; }
-    message_id& operator=(const amqp_string& x) { scalar_ = x; return *this; }
-    /// std::string is encoded as amqp_string
-    message_id& operator=(const std::string& x) { scalar_ = amqp_string(x); return *this; }
-    /// char* is encoded as amqp_string
-    message_id& operator=(const char *x) { scalar_ = amqp_string(x); return *this; }
+    message_id& operator=(const binary& x) { scalar_ = x; return *this; }
+    message_id& operator=(const std::string& x) { scalar_ = x; return *this; }
+    /// char* is encoded as std::string
+    message_id& operator=(const char *x) { scalar_ = std::string(x); return *this; }
     /// @}
 
-    /// Create a message ID from any type that we can assign from.
-    template <class T> message_id(T x) { *this = x; }
-
     /// @name Get methods
     ///
     /// get(T&) extracts the value if the types match exactly and
@@ -67,18 +66,20 @@ class message_id : public restricted_scalar {
     /// @{
     void get(uint64_t& x) const { scalar_.get(x); }
     void get(uuid& x) const { scalar_.get(x); }
-    void get(amqp_binary& x) const { scalar_.get(x); }
-    void get(amqp_string& x) const { scalar_.get(x); }
+    void get(binary& x) const { scalar_.get(x); }
+    void get(std::string& x) const { scalar_.get(x); }
     /// @}
 
     /// Return the value as type T.
     template<class T> T get() const { T x; get(x); return x; }
 
-    /// @cond INTERNAL
     friend PN_CPP_EXTERN encoder operator<<(encoder, const message_id&);
     friend PN_CPP_EXTERN decoder operator>>(decoder, message_id&);
-    friend class message;
-    /// @endcond
+
+  private:
+    message_id(const pn_atom_t& a): restricted_scalar(a) {}
+
+  friend class message;
 };
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/proton-c/bindings/cpp/include/proton/scalar.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/scalar.hpp b/proton-c/bindings/cpp/include/proton/scalar.hpp
index 822efc6..56c7177 100644
--- a/proton-c/bindings/cpp/include/proton/scalar.hpp
+++ b/proton-c/bindings/cpp/include/proton/scalar.hpp
@@ -28,15 +28,19 @@
 
 namespace proton {
 
+class binary;
 class decimal128;
 class decimal32;
 class decimal64;
 class decoder;
 class encoder;
+class symbol;
 class timestamp;
 class uuid;
 
 /// A holder for an instance of any scalar AMQP type.
+/// The conversions for scalar types are documented in proton::amqp.
+///
 class scalar : private comparable<scalar> {
   public:
     /// Create an empty scalar.
@@ -56,7 +60,8 @@ class scalar : private comparable<scalar> {
 
     /// @name Assignment operators
     ///
-    /// Assign a C++ value and deduce the AMQP type().
+    /// Assign a C++ value as the corresponding AMQP type.
+    /// See proton::amqp for the list of type correspondences.
     ///
     /// @{
     PN_CPP_EXTERN scalar& operator=(bool);
@@ -76,11 +81,10 @@ class scalar : private comparable<scalar> {
     PN_CPP_EXTERN scalar& operator=(const decimal64&);
     PN_CPP_EXTERN scalar& operator=(const decimal128&);
     PN_CPP_EXTERN scalar& operator=(const uuid&);
-    PN_CPP_EXTERN scalar& operator=(const amqp_string&);
-    PN_CPP_EXTERN scalar& operator=(const amqp_symbol&);
-    PN_CPP_EXTERN scalar& operator=(const amqp_binary&);
-    PN_CPP_EXTERN scalar& operator=(const std::string& s); ///< Treated as an AMQP string
-    PN_CPP_EXTERN scalar& operator=(const char* s);        ///< Treated as an AMQP string
+    PN_CPP_EXTERN scalar& operator=(const std::string&);
+    PN_CPP_EXTERN scalar& operator=(const symbol&);
+    PN_CPP_EXTERN scalar& operator=(const binary&);
+    PN_CPP_EXTERN scalar& operator=(const char* s); ///< Treated as an AMQP string
     /// @}
 
     /// Create a scalar from any type that we can assign from.
@@ -109,10 +113,9 @@ class scalar : private comparable<scalar> {
     PN_CPP_EXTERN void get(decimal64&) const;
     PN_CPP_EXTERN void get(decimal128&) const;
     PN_CPP_EXTERN void get(uuid&) const;
-    PN_CPP_EXTERN void get(amqp_string&) const;
-    PN_CPP_EXTERN void get(amqp_symbol&) const;
-    PN_CPP_EXTERN void get(amqp_binary&) const;
-    PN_CPP_EXTERN void get(std::string&) const; ///< Treated as an AMQP string
+    PN_CPP_EXTERN void get(symbol&) const;
+    PN_CPP_EXTERN void get(binary&) const;
+    PN_CPP_EXTERN void get(std::string&) const;
     /// @}
 
     /// get<T>() is like get(T&) but returns the value.
@@ -132,7 +135,7 @@ class scalar : private comparable<scalar> {
     /// @}
 
     /// @cond INTERNAL
-    
+
   friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const scalar&);
   friend PN_CPP_EXTERN encoder operator<<(encoder, const scalar&);
   friend PN_CPP_EXTERN decoder operator>>(decoder, scalar&);
@@ -145,8 +148,9 @@ class scalar : private comparable<scalar> {
   friend PN_CPP_EXTERN bool operator<(const scalar& x, const scalar& y);
 
     /// @endcond
-    
+
   private:
+    scalar(const pn_atom_t& a);
     void ok(pn_type_t) const;
     void set(const std::string&, pn_type_t);
     void set(const pn_atom_t&);
@@ -154,11 +158,10 @@ class scalar : private comparable<scalar> {
     std::string str_;           // Owner of string-like data.
 
   friend class message;
+  friend class restricted_scalar;
 };
 
 /// @cond INTERNAL
-/// XXX should it be public?
-    
 /// Base class for restricted scalar types.
 class restricted_scalar : private comparable<restricted_scalar> {
   public:
@@ -180,13 +183,16 @@ class restricted_scalar : private comparable<restricted_scalar> {
 
   protected:
     restricted_scalar() {}
+    restricted_scalar(const pn_atom_t& a) : scalar_(a) {}
+
     scalar scalar_;
 
+  friend class message;
+
     friend std::ostream& operator<<(std::ostream& o, const restricted_scalar& x)  { return o << x.scalar_; }
     friend bool operator<(const restricted_scalar& x, const restricted_scalar& y)  { return x.scalar_ < y.scalar_; }
     friend bool operator==(const restricted_scalar& x, const restricted_scalar& y)  { return x.scalar_ == y.scalar_; }
 };
-
 /// @endcond
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/proton-c/bindings/cpp/include/proton/symbol.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/symbol.hpp b/proton-c/bindings/cpp/include/proton/symbol.hpp
new file mode 100644
index 0000000..4e6db7a
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/symbol.hpp
@@ -0,0 +1,35 @@
+#ifndef SYMBOL_HPP
+#define SYMBOL_HPP
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace proton {
+
+/// symbol is a std::string that represents the AMQP symbol type.
+/// A symbol can only contain 7-bit ASCII characters.
+///
+class symbol : public std::string {
+  public:
+    explicit symbol(const std::string& s=std::string()) : std::string(s) {}
+    explicit symbol(const char* s) : std::string(s) {}
+};
+
+}
+
+#endif // SYMBOL_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/proton-c/bindings/cpp/include/proton/type_traits.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/type_traits.hpp b/proton-c/bindings/cpp/include/proton/type_traits.hpp
index 967dea1..753c33c 100644
--- a/proton-c/bindings/cpp/include/proton/type_traits.hpp
+++ b/proton-c/bindings/cpp/include/proton/type_traits.hpp
@@ -34,9 +34,11 @@
 
 namespace proton {
 
+class binary;
 class decimal128;
 class decimal32;
 class decimal64;
+class symbol;
 class timestamp;
 class uuid;
 class value;
@@ -87,27 +89,26 @@ template< class T > struct remove_const<const T> { typedef T type; };
 
 // Metafunction returning AMQP type for scalar C++ types
 template <class T, class Enable=void> struct type_id_of;
-template<> struct type_id_of<amqp_null> { static const type_id value=NULL_TYPE; };
-template<> struct type_id_of<amqp_boolean> { static const type_id value=BOOLEAN; };
-template<> struct type_id_of<amqp_ubyte> { static const type_id value=UBYTE; };
-template<> struct type_id_of<amqp_byte> { static const type_id value=BYTE; };
-template<> struct type_id_of<amqp_ushort> { static const type_id value=USHORT; };
-template<> struct type_id_of<amqp_short> { static const type_id value=SHORT; };
-template<> struct type_id_of<amqp_uint> { static const type_id value=UINT; };
-template<> struct type_id_of<amqp_int> { static const type_id value=INT; };
-template<> struct type_id_of<amqp_char> { static const type_id value=CHAR; };
-template<> struct type_id_of<amqp_ulong> { static const type_id value=ULONG; };
-template<> struct type_id_of<amqp_long> { static const type_id value=LONG; };
+template<> struct type_id_of<bool> { static const type_id value=BOOLEAN; };
+template<> struct type_id_of<uint8_t> { static const type_id value=UBYTE; };
+template<> struct type_id_of<int8_t> { static const type_id value=BYTE; };
+template<> struct type_id_of<uint16_t> { static const type_id value=USHORT; };
+template<> struct type_id_of<int16_t> { static const type_id value=SHORT; };
+template<> struct type_id_of<uint32_t> { static const type_id value=UINT; };
+template<> struct type_id_of<int32_t> { static const type_id value=INT; };
+template<> struct type_id_of<wchar_t> { static const type_id value=CHAR; };
+template<> struct type_id_of<uint64_t> { static const type_id value=ULONG; };
+template<> struct type_id_of<int64_t> { static const type_id value=LONG; };
 template<> struct type_id_of<timestamp> { static const type_id value=TIMESTAMP; };
-template<> struct type_id_of<amqp_float> { static const type_id value=FLOAT; };
-template<> struct type_id_of<amqp_double> { static const type_id value=DOUBLE; };
+template<> struct type_id_of<float> { static const type_id value=FLOAT; };
+template<> struct type_id_of<double> { static const type_id value=DOUBLE; };
 template<> struct type_id_of<decimal32> { static const type_id value=DECIMAL32; };
 template<> struct type_id_of<decimal64> { static const type_id value=DECIMAL64; };
 template<> struct type_id_of<decimal128> { static const type_id value=DECIMAL128; };
 template<> struct type_id_of<uuid> { static const type_id value=UUID; };
-template<> struct type_id_of<amqp_binary> { static const type_id value=BINARY; };
-template<> struct type_id_of<amqp_string> { static const type_id value=STRING; };
-template<> struct type_id_of<amqp_symbol> { static const type_id value=SYMBOL; };
+template<> struct type_id_of<binary> { static const type_id value=BINARY; };
+template<> struct type_id_of<std::string> { static const type_id value=STRING; };
+template<> struct type_id_of<symbol> { static const type_id value=SYMBOL; };
 
 template <class T, class Enable=void> struct has_type_id : public false_type {};
 template <class T> struct has_type_id<T, typename enable_if<!!type_id_of<T>::value>::type>  {
@@ -116,14 +117,14 @@ template <class T> struct has_type_id<T, typename enable_if<!!type_id_of<T>::val
 
 // Map arbitrary integral types to known AMQP integral types.
 template<size_t SIZE, bool IS_SIGNED> struct integer_type;
-template<> struct integer_type<1, true> { typedef amqp_byte type; };
-template<> struct integer_type<2, true> { typedef amqp_short type; };
-template<> struct integer_type<4, true> { typedef amqp_int type; };
-template<> struct integer_type<8, true> { typedef amqp_long type; };
-template<> struct integer_type<1, false> { typedef amqp_ubyte type; };
-template<> struct integer_type<2, false> { typedef amqp_ushort type; };
-template<> struct integer_type<4, false> { typedef amqp_uint type; };
-template<> struct integer_type<8, false> { typedef amqp_ulong type; };
+template<> struct integer_type<1, true> { typedef int8_t type; };
+template<> struct integer_type<2, true> { typedef int16_t type; };
+template<> struct integer_type<4, true> { typedef int32_t type; };
+template<> struct integer_type<8, true> { typedef int64_t type; };
+template<> struct integer_type<1, false> { typedef uint8_t type; };
+template<> struct integer_type<2, false> { typedef uint16_t type; };
+template<> struct integer_type<4, false> { typedef uint32_t type; };
+template<> struct integer_type<8, false> { typedef uint64_t type; };
 
 // True if T is an integer type that does not have a type_id mapping.
 template <class T> struct is_unknown_integer {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/proton-c/bindings/cpp/include/proton/types.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/types.hpp b/proton-c/bindings/cpp/include/proton/types.hpp
index c052cd1..54b8391 100644
--- a/proton-c/bindings/cpp/include/proton/types.hpp
+++ b/proton-c/bindings/cpp/include/proton/types.hpp
@@ -71,38 +71,6 @@ PN_CPP_EXTERN std::string type_name(type_id);
 /// Print the type name.
 PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, type_id);
 
-/// @cond INTERNAL
-
-PN_CPP_EXTERN pn_bytes_t pn_bytes(const std::string&);
-PN_CPP_EXTERN std::string str(const pn_bytes_t& b);
-
-/// AMQP NULL type.
-struct amqp_null {};
-/// AMQP boolean type.
-typedef bool amqp_boolean;
-/// AMQP unsigned 8-bit type.
-typedef ::uint8_t amqp_ubyte;
-/// AMQP signed 8-bit integer type.
-typedef ::int8_t amqp_byte;
-/// AMQP unsigned 16-bit integer type.
-typedef ::uint16_t amqp_ushort;
-/// AMQP signed 16-bit integer type.
-typedef ::int16_t amqp_short;
-/// AMQP unsigned 32-bit integer type.
-typedef ::uint32_t amqp_uint;
-/// AMQP signed 32-bit integer type.
-typedef ::int32_t amqp_int;
-/// AMQP 32-bit unicode character type.
-typedef wchar_t amqp_char;
-/// AMQP unsigned 64-bit integer type.
-typedef ::uint64_t amqp_ulong;
-/// AMQP signed 64-bit integer type.
-typedef ::int64_t amqp_long;
-/// AMQP 32-bit floating-point type.
-typedef float amqp_float;
-/// AMQP 64-bit floating-point type.
-typedef double amqp_double;
-
 /// AMQP UTF-8 encoded string.
 struct amqp_string : public std::string {
     explicit amqp_string(const std::string& s=std::string()) : std::string(s) {}
@@ -124,12 +92,10 @@ struct amqp_binary : public std::string {
     explicit amqp_binary(const pn_bytes_t& b) : std::string(b.start, b.size) {}
 };
 
-/// @endcond
-
 // TODO aconway 2015-06-16: described types.
 
 /// @name Type test functions
-///    
+///
 /// Attributes of a type_id value, returns same result as the
 /// corresponding std::type_traits tests for the corresponding C++
 /// types.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/proton-c/bindings/cpp/include/proton/uuid.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/uuid.hpp b/proton-c/bindings/cpp/include/proton/uuid.hpp
index cbe3e32..ec95b34 100644
--- a/proton-c/bindings/cpp/include/proton/uuid.hpp
+++ b/proton-c/bindings/cpp/include/proton/uuid.hpp
@@ -22,8 +22,6 @@
 #include <proton/byte_array.hpp>
 #include <proton/export.hpp>
 
-#include <proton/types.h>        // FIXME aconway 2016-02-18: cleanup
-
 #include <string>
 #include <iosfwd>
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/proton-c/bindings/cpp/include/proton/value.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/value.hpp b/proton-c/bindings/cpp/include/proton/value.hpp
index 8de6962..8457428 100644
--- a/proton-c/bindings/cpp/include/proton/value.hpp
+++ b/proton-c/bindings/cpp/include/proton/value.hpp
@@ -32,6 +32,9 @@ namespace proton {
 /// A proton::value can hold any AMQP data value, simple or compound.
 /// It has assignment and conversion operators to convert its contents
 /// easily to and from native C++ types.
+///
+/// The conversions for scalar types are documented in proton::amqp.
+///
 class value : private comparable<value> {
   public:
     /// Create an empty value.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/proton-c/bindings/cpp/src/data.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/data.cpp b/proton-c/bindings/cpp/src/data.cpp
index b6838aa..74e20db 100644
--- a/proton-c/bindings/cpp/src/data.cpp
+++ b/proton-c/bindings/cpp/src/data.cpp
@@ -18,8 +18,12 @@
  */
 
 #include "proton_bits.hpp"
+
+#include "proton/amqp.hpp"
+#include "proton/binary.hpp"
 #include "proton/data.hpp"
 #include "proton/decimal.hpp"
+#include "proton/symbol.hpp"
 
 #include <proton/codec.h>
 
@@ -117,26 +121,26 @@ int compare_next(data& a, data& b) {
       case MAP:
       case DESCRIBED:
         return compare_container(a, b);
-      case BOOLEAN: return compare_simple<amqp_boolean>(a, b);
-      case UBYTE: return compare_simple<amqp_ubyte>(a, b);
-      case BYTE: return compare_simple<amqp_byte>(a, b);
-      case USHORT: return compare_simple<amqp_ushort>(a, b);
-      case SHORT: return compare_simple<amqp_short>(a, b);
-      case UINT: return compare_simple<amqp_uint>(a, b);
-      case INT: return compare_simple<amqp_int>(a, b);
-      case CHAR: return compare_simple<amqp_char>(a, b);
-      case ULONG: return compare_simple<amqp_ulong>(a, b);
-      case LONG: return compare_simple<amqp_long>(a, b);
+      case BOOLEAN: return compare_simple<bool>(a, b);
+      case UBYTE: return compare_simple<amqp::ubyte_type>(a, b);
+      case BYTE: return compare_simple<amqp::byte_type>(a, b);
+      case USHORT: return compare_simple<amqp::ushort_type>(a, b);
+      case SHORT: return compare_simple<amqp::short_type>(a, b);
+      case UINT: return compare_simple<amqp::uint_type>(a, b);
+      case INT: return compare_simple<amqp::int_type>(a, b);
+      case CHAR: return compare_simple<amqp::char_type>(a, b);
+      case ULONG: return compare_simple<amqp::ulong_type>(a, b);
+      case LONG: return compare_simple<amqp::long_type>(a, b);
       case TIMESTAMP: return compare_simple<timestamp>(a, b);
-      case FLOAT: return compare_simple<amqp_float>(a, b);
-      case DOUBLE: return compare_simple<amqp_double>(a, b);
+      case FLOAT: return compare_simple<amqp::float_type>(a, b);
+      case DOUBLE: return compare_simple<amqp::double_type>(a, b);
       case DECIMAL32: return compare_simple<decimal32>(a, b);
       case DECIMAL64: return compare_simple<decimal64>(a, b);
       case DECIMAL128: return compare_simple<decimal128>(a, b);
       case UUID: return compare_simple<uuid>(a, b);
-      case BINARY: return compare_simple<amqp_binary>(a, b);
-      case STRING: return compare_simple<amqp_string>(a, b);
-      case SYMBOL: return compare_simple<amqp_symbol>(a, b);
+      case BINARY: return compare_simple<amqp::binary_type>(a, b);
+      case STRING: return compare_simple<amqp::string_type>(a, b);
+      case SYMBOL: return compare_simple<amqp::symbol_type>(a, b);
     }
     // Invalid but equal type_id, treat as equal.
     return 0;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/proton-c/bindings/cpp/src/decoder.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/decoder.cpp b/proton-c/bindings/cpp/src/decoder.cpp
index 2246339..17f85da 100644
--- a/proton-c/bindings/cpp/src/decoder.cpp
+++ b/proton-c/bindings/cpp/src/decoder.cpp
@@ -23,6 +23,7 @@
 #include "proton/value.hpp"
 #include "proton/message_id.hpp"
 #include "proton/annotation_key.hpp"
+#include "proton/amqp.hpp"
 #include "proton_bits.hpp"
 
 #include "types_internal.hpp"
@@ -195,12 +196,6 @@ decoder operator>>(decoder d, annotation_key& x) {
     };
 }
 
-decoder operator>>(decoder d, amqp_null) {
-    save_state ss(d.pn_object());
-    bad_type(NULL_TYPE, pre_get(d.pn_object()));
-    return d;
-}
-
 decoder operator>>(decoder d, scalar& x) {
     save_state ss(d.pn_object());
     type_id got = pre_get(d.pn_object());
@@ -211,12 +206,12 @@ decoder operator>>(decoder d, scalar& x) {
     return d;
 }
 
-decoder operator>>(decoder d, amqp_boolean &x) {
+decoder operator>>(decoder d, amqp::boolean_type &x) {
     extract(d.pn_object(), x, pn_data_get_bool);
     return d;
 }
 
-decoder operator>>(decoder d0, amqp_ubyte &x) {
+decoder operator>>(decoder d0, amqp::ubyte_type &x) {
     pn_data_t* d = d0.pn_object();
     save_state ss(d);
     switch (pre_get(d)) {
@@ -227,7 +222,7 @@ decoder operator>>(decoder d0, amqp_ubyte &x) {
     return d0;
 }
 
-decoder operator>>(decoder d0, amqp_byte &x) {
+decoder operator>>(decoder d0, amqp::byte_type &x) {
     pn_data_t* d = d0.pn_object();
     save_state ss(d);
     switch (pre_get(d)) {
@@ -238,7 +233,7 @@ decoder operator>>(decoder d0, amqp_byte &x) {
     return d0;
 }
 
-decoder operator>>(decoder d0, amqp_ushort &x) {
+decoder operator>>(decoder d0, amqp::ushort_type &x) {
     pn_data_t* d = d0.pn_object();
     save_state ss(d);
     switch (pre_get(d)) {
@@ -250,7 +245,7 @@ decoder operator>>(decoder d0, amqp_ushort &x) {
     return d0;
 }
 
-decoder operator>>(decoder d0, amqp_short &x) {
+decoder operator>>(decoder d0, amqp::short_type &x) {
     pn_data_t* d = d0.pn_object();
     save_state ss(d);
     switch (pre_get(d)) {
@@ -262,7 +257,7 @@ decoder operator>>(decoder d0, amqp_short &x) {
     return d0;
 }
 
-decoder operator>>(decoder d0, amqp_uint &x) {
+decoder operator>>(decoder d0, amqp::uint_type &x) {
     pn_data_t* d = d0.pn_object();
     save_state ss(d);
     switch (pre_get(d)) {
@@ -275,7 +270,7 @@ decoder operator>>(decoder d0, amqp_uint &x) {
     return d0;
 }
 
-decoder operator>>(decoder d0, amqp_int &x) {
+decoder operator>>(decoder d0, amqp::int_type &x) {
     pn_data_t* d = d0.pn_object();
     save_state ss(d);
     switch (pre_get(d)) {
@@ -288,7 +283,7 @@ decoder operator>>(decoder d0, amqp_int &x) {
     return d0;
 }
 
-decoder operator>>(decoder d0, amqp_ulong &x) {
+decoder operator>>(decoder d0, amqp::ulong_type &x) {
     pn_data_t* d = d0.pn_object();
     save_state ss(d);
     switch (pre_get(d)) {
@@ -302,7 +297,7 @@ decoder operator>>(decoder d0, amqp_ulong &x) {
     return d0;
 }
 
-decoder operator>>(decoder d0, amqp_long &x) {
+decoder operator>>(decoder d0, amqp::long_type &x) {
     pn_data_t* d = d0.pn_object();
     save_state ss(d);
     switch (pre_get(d)) {
@@ -316,7 +311,7 @@ decoder operator>>(decoder d0, amqp_long &x) {
     return d0;
 }
 
-decoder operator>>(decoder d, amqp_char &x) {
+decoder operator>>(decoder d, amqp::char_type &x) {
     extract(d.pn_object(), x, pn_data_get_char);
     return d;
 }
@@ -326,7 +321,7 @@ decoder operator>>(decoder d, timestamp &x) {
     return d;
 }
 
-decoder operator>>(decoder d0, amqp_float &x) {
+decoder operator>>(decoder d0, amqp::float_type &x) {
     pn_data_t* d = d0.pn_object();
     save_state ss(d);
     switch (pre_get(d)) {
@@ -338,7 +333,7 @@ decoder operator>>(decoder d0, amqp_float &x) {
     return d0;
 }
 
-decoder operator>>(decoder d0, amqp_double &x) {
+decoder operator>>(decoder d0, amqp::double_type &x) {
     pn_data_t* d = d0.pn_object();
     save_state ss(d);
     switch (pre_get(d)) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/proton-c/bindings/cpp/src/encoder.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/encoder.cpp b/proton-c/bindings/cpp/src/encoder.cpp
index fd0a1d3..a7f1498 100644
--- a/proton-c/bindings/cpp/src/encoder.cpp
+++ b/proton-c/bindings/cpp/src/encoder.cpp
@@ -17,12 +17,15 @@
  * under the License.
  */
 
+#include "proton/amqp.hpp"
+#include "proton/annotation_key.hpp"
+#include "proton/binary.hpp"
 #include "proton/data.hpp"
+#include "proton/decimal.hpp"
 #include "proton/encoder.hpp"
 #include "proton/message_id.hpp"
-#include "proton/annotation_key.hpp"
+#include "proton/symbol.hpp"
 #include "proton/value.hpp"
-#include "proton/decimal.hpp"
 
 #include "proton_bits.hpp"
 #include "types_internal.hpp"
@@ -117,33 +120,32 @@ encoder insert(encoder e, pn_data_t* data, const T& x, int (*put)(pn_data_t*, U)
     return e;
 }
 
-int pn_data_put_amqp_string(pn_data_t *d, const amqp_string& x) { return pn_data_put_string(d, pn_bytes(x)); }
-int pn_data_put_amqp_binary(pn_data_t *d, const amqp_binary& x) { return pn_data_put_binary(d, pn_bytes(x)); }
-int pn_data_put_amqp_symbol(pn_data_t *d, const amqp_symbol& x) { return pn_data_put_symbol(d, pn_bytes(x)); }
+int pn_data_put_amqp_string(pn_data_t *d, const amqp::string_type& x) { return pn_data_put_string(d, pn_bytes(x)); }
+int pn_data_put_amqp_binary(pn_data_t *d, const amqp::binary_type& x) { return pn_data_put_binary(d, pn_bytes(x)); }
+int pn_data_put_amqp_symbol(pn_data_t *d, const amqp::symbol_type& x) { return pn_data_put_symbol(d, pn_bytes(x)); }
 }
 
-encoder operator<<(encoder e, amqp_null) { pn_data_put_null(e.pn_object()); return e; }
-encoder operator<<(encoder e, amqp_boolean x) { return insert(e, e.pn_object(), x, pn_data_put_bool); }
-encoder operator<<(encoder e, amqp_ubyte x) { return insert(e, e.pn_object(), x, pn_data_put_ubyte); }
-encoder operator<<(encoder e, amqp_byte x) { return insert(e, e.pn_object(), x, pn_data_put_byte); }
-encoder operator<<(encoder e, amqp_ushort x) { return insert(e, e.pn_object(), x, pn_data_put_ushort); }
-encoder operator<<(encoder e, amqp_short x) { return insert(e, e.pn_object(), x, pn_data_put_short); }
-encoder operator<<(encoder e, amqp_uint x) { return insert(e, e.pn_object(), x, pn_data_put_uint); }
-encoder operator<<(encoder e, amqp_int x) { return insert(e, e.pn_object(), x, pn_data_put_int); }
-encoder operator<<(encoder e, amqp_char x) { return insert(e, e.pn_object(), x, pn_data_put_char); }
-encoder operator<<(encoder e, amqp_ulong x) { return insert(e, e.pn_object(), x, pn_data_put_ulong); }
-encoder operator<<(encoder e, amqp_long x) { return insert(e, e.pn_object(), x, pn_data_put_long); }
+encoder operator<<(encoder e, amqp::boolean_type x) { return insert(e, e.pn_object(), x, pn_data_put_bool); }
+encoder operator<<(encoder e, amqp::ubyte_type x) { return insert(e, e.pn_object(), x, pn_data_put_ubyte); }
+encoder operator<<(encoder e, amqp::byte_type x) { return insert(e, e.pn_object(), x, pn_data_put_byte); }
+encoder operator<<(encoder e, amqp::ushort_type x) { return insert(e, e.pn_object(), x, pn_data_put_ushort); }
+encoder operator<<(encoder e, amqp::short_type x) { return insert(e, e.pn_object(), x, pn_data_put_short); }
+encoder operator<<(encoder e, amqp::uint_type x) { return insert(e, e.pn_object(), x, pn_data_put_uint); }
+encoder operator<<(encoder e, amqp::int_type x) { return insert(e, e.pn_object(), x, pn_data_put_int); }
+encoder operator<<(encoder e, amqp::char_type x) { return insert(e, e.pn_object(), x, pn_data_put_char); }
+encoder operator<<(encoder e, amqp::ulong_type x) { return insert(e, e.pn_object(), x, pn_data_put_ulong); }
+encoder operator<<(encoder e, amqp::long_type x) { return insert(e, e.pn_object(), x, pn_data_put_long); }
 encoder operator<<(encoder e, timestamp x) { return insert(e, e.pn_object(), x.ms(), pn_data_put_timestamp); }
-encoder operator<<(encoder e, amqp_float x) { return insert(e, e.pn_object(), x, pn_data_put_float); }
-encoder operator<<(encoder e, amqp_double x) { return insert(e, e.pn_object(), x, pn_data_put_double); }
+encoder operator<<(encoder e, amqp::float_type x) { return insert(e, e.pn_object(), x, pn_data_put_float); }
+encoder operator<<(encoder e, amqp::double_type x) { return insert(e, e.pn_object(), x, pn_data_put_double); }
 
 encoder operator<<(encoder e, decimal32 x) { return insert(e, e.pn_object(), x, pn_data_put_decimal32); }
 encoder operator<<(encoder e, decimal64 x) { return insert(e, e.pn_object(), x, pn_data_put_decimal64); }
 encoder operator<<(encoder e, decimal128 x) { return insert(e, e.pn_object(), x, pn_data_put_decimal128); }
 encoder operator<<(encoder e, uuid x) { return insert(e, e.pn_object(), x, pn_data_put_uuid); }
-encoder operator<<(encoder e, amqp_string x) { return insert(e, e.pn_object(), x, pn_data_put_amqp_string); }
-encoder operator<<(encoder e, amqp_symbol x) { return insert(e, e.pn_object(), x, pn_data_put_amqp_symbol); }
-encoder operator<<(encoder e, amqp_binary x) { return insert(e, e.pn_object(), x, pn_data_put_amqp_binary); }
+encoder operator<<(encoder e, amqp::string_type x) { return insert(e, e.pn_object(), x, pn_data_put_amqp_string); }
+encoder operator<<(encoder e, amqp::symbol_type x) { return insert(e, e.pn_object(), x, pn_data_put_amqp_symbol); }
+encoder operator<<(encoder e, amqp::binary_type x) { return insert(e, e.pn_object(), x, pn_data_put_amqp_binary); }
 
 encoder operator<<(encoder e, const value& v) {
     data edata = e.data();

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/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 9ac162c..c25dedc 100644
--- a/proton-c/bindings/cpp/src/interop_test.cpp
+++ b/proton-c/bindings/cpp/src/interop_test.cpp
@@ -20,6 +20,7 @@
 #include "proton/decoder.hpp"
 #include "proton/encoder.hpp"
 #include "proton/value.hpp"
+#include "proton/amqp.hpp"
 #include "test_bits.hpp"
 #include <string>
 #include <sstream>
@@ -98,12 +99,12 @@ void test_encoder_primitives() {
 void test_value_conversions() {
     value v;
     ASSERT_EQUAL(true, (v=true).get<bool>());
-    ASSERT_EQUAL(2, (v=amqp_byte(2)).get<int>());
-    ASSERT_EQUAL(3, (v=amqp_byte(3)).get<long>());
-    ASSERT_EQUAL(3, (v=amqp_byte(3)).get<long>());
-    ASSERT_EQUAL(1.0, (v=amqp_float(1.0)).get<double>());
-    ASSERT_EQUAL(1.0, (v=amqp_double(1.0)).get<float>());
-    try { (void)(v = amqp_byte(1)).get<bool>(); FAIL("got byte as bool"); } catch (conversion_error) {}
+    ASSERT_EQUAL(2, (v=amqp::byte_type(2)).get<int>());
+    ASSERT_EQUAL(3, (v=amqp::byte_type(3)).get<long>());
+    ASSERT_EQUAL(3, (v=amqp::byte_type(3)).get<long>());
+    ASSERT_EQUAL(1.0, (v=amqp::float_type(1.0)).get<double>());
+    ASSERT_EQUAL(1.0, (v=amqp::double_type(1.0)).get<float>());
+    try { (void)(v = int8_t(1)).get<bool>(); FAIL("got byte as bool"); } catch (conversion_error) {}
     try { (void)(v = true).get<float>(); FAIL("got bool as float"); } catch (conversion_error) {}
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/proton-c/bindings/cpp/src/link_options.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/link_options.cpp b/proton-c/bindings/cpp/src/link_options.cpp
index 3fc694b..6dd32d7 100644
--- a/proton-c/bindings/cpp/src/link_options.cpp
+++ b/proton-c/bindings/cpp/src/link_options.cpp
@@ -18,6 +18,8 @@
  * under the License.
  *
  */
+
+#include "proton/binary.hpp"
 #include "proton/link.hpp"
 #include "proton/link_options.hpp"
 #include "proton/handler.hpp"
@@ -109,10 +111,10 @@ class link_options::impl {
                         encoder enc = t.node_properties().encode();
                         enc << start::map();
                         if (dm.size())
-                            enc << amqp_symbol("supported-dist-modes") << amqp_string(dm);
+                            enc << symbol("supported-dist-modes") << std::string(dm);
                         if (lp.size())
-                            enc << amqp_symbol("lifetime-policy") << start::described()
-                                << amqp_symbol(lp) << start::list() << finish();
+                            enc << symbol("lifetime-policy") << start::described()
+                                << symbol(lp) << start::list() << finish();
                     }
                 }
             }
@@ -125,8 +127,8 @@ class link_options::impl {
                 }
                 if (selector.set && selector.value.size()) {
                     encoder enc = l.local_source().filter().encode();
-                    enc << start::map() << amqp_symbol("selector") << start::described()
-                        << amqp_symbol("apache.org:selector-filter:string") << amqp_binary(selector.value) << finish();
+                    enc << start::map() << symbol("selector") << start::described()
+                        << symbol("apache.org:selector-filter:string") << binary(selector.value) << finish();
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/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 2b231e4..2a93ac0 100644
--- a/proton-c/bindings/cpp/src/message.cpp
+++ b/proton-c/bindings/cpp/src/message.cpp
@@ -31,6 +31,7 @@
 #include "proton/delivery.h"
 #include "msg.hpp"
 #include "proton_bits.hpp"
+#include "types_internal.hpp"
 
 #include <string>
 #include <algorithm>
@@ -85,25 +86,8 @@ void check(int err) {
 
 void message::id(const message_id& id) { pn_message_set_id(pn_msg(), id.scalar_.atom_); }
 
-namespace {
-inline message_id from_pn_atom(const pn_atom_t& v) {
-  switch (v.type) {
-    case PN_ULONG:
-      return message_id(amqp_ulong(v.u.as_ulong));
-    case PN_UUID:
-      return message_id(uuid::make(reinterpret_cast<const char*>(&v.u.as_uuid)));
-    case PN_BINARY:
-      return message_id(amqp_binary(v.u.as_bytes));
-    case PN_STRING:
-      return message_id(amqp_string(v.u.as_bytes));
-    default:
-      return message_id();
-  }
-}
-}
-
 message_id message::id() const {
-    return from_pn_atom(pn_message_get_id(pn_msg()));
+    return pn_message_get_id(pn_msg());
 }
 
 void message::user_id(const std::string &id) {
@@ -146,7 +130,7 @@ void message::correlation_id(const message_id& id) {
 }
 
 message_id message::correlation_id() const {
-    return from_pn_atom(pn_message_get_correlation_id(pn_msg()));
+    return pn_message_get_correlation_id(pn_msg());
 }
 
 void message::content_type(const std::string &s) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/proton-c/bindings/cpp/src/messaging_adapter.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_adapter.cpp b/proton-c/bindings/cpp/src/messaging_adapter.cpp
index c2fe210..538d419 100644
--- a/proton-c/bindings/cpp/src/messaging_adapter.cpp
+++ b/proton-c/bindings/cpp/src/messaging_adapter.cpp
@@ -133,7 +133,7 @@ void messaging_adapter::on_delivery(proton_event &pe) {
     } else {
         // sender
         if (dlv.updated()) {
-            amqp_ulong rstate = dlv.remote_state();
+            uint64_t rstate = dlv.remote_state();
             if (rstate == PN_ACCEPTED) {
                 messaging_event mevent(messaging_event::DELIVERY_ACCEPT, pe);
                 delegate_.on_delivery_accept(mevent);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/proton-c/bindings/cpp/src/scalar.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/scalar.cpp b/proton-c/bindings/cpp/src/scalar.cpp
index 4306e6b..04e5318 100644
--- a/proton-c/bindings/cpp/src/scalar.cpp
+++ b/proton-c/bindings/cpp/src/scalar.cpp
@@ -20,8 +20,10 @@
 #include "msg.hpp"
 #include "types_internal.hpp"
 
+#include "proton/binary.hpp"
 #include "proton/decimal.hpp"
 #include "proton/scalar.hpp"
+#include "proton/symbol.hpp"
 #include "proton/timestamp.hpp"
 #include "proton/type_traits.hpp"
 #include "proton/uuid.hpp"
@@ -31,7 +33,9 @@
 namespace proton {
 
 scalar::scalar() { atom_.type = PN_NULL; }
+scalar::scalar(const pn_atom_t& a) { set(a); }
 scalar::scalar(const scalar& x) { set(x.atom_); }
+
 scalar& scalar::operator=(const scalar& x) {
     if (this != &x)
         set(x.atom_);
@@ -92,10 +96,9 @@ scalar& scalar::operator=(const uuid& x) {
     return *this;
 }
 
-scalar& scalar::operator=(const amqp_string& x) { set(x, PN_STRING); return *this; }
-scalar& scalar::operator=(const amqp_symbol& x) { set(x, PN_SYMBOL); return *this; }
-scalar& scalar::operator=(const amqp_binary& x) { set(x, PN_BINARY); return *this; }
 scalar& scalar::operator=(const std::string& x) { set(x, PN_STRING); return *this; }
+scalar& scalar::operator=(const symbol& x) { set(x, PN_SYMBOL); return *this; }
+scalar& scalar::operator=(const binary& x) { set(x, PN_BINARY); return *this; }
 scalar& scalar::operator=(const char* x) { set(x, PN_STRING); return *this; }
 
 void scalar::ok(pn_type_t t) const {
@@ -119,10 +122,9 @@ void scalar::get(decimal32& x) const { ok(PN_DECIMAL32); byte_copy(x, atom_.u.as
 void scalar::get(decimal64& x) const { ok(PN_DECIMAL64); byte_copy(x, atom_.u.as_decimal64); }
 void scalar::get(decimal128& x) const { ok(PN_DECIMAL128); byte_copy(x, atom_.u.as_decimal128); }
 void scalar::get(uuid& x) const { ok(PN_UUID); byte_copy(x, atom_.u.as_uuid); }
-void scalar::get(amqp_string& x) const { ok(PN_STRING); x = amqp_string(str_); }
-void scalar::get(amqp_symbol& x) const { ok(PN_SYMBOL); x = amqp_symbol(str_); }
-void scalar::get(amqp_binary& x) const { ok(PN_BINARY); x = amqp_binary(str_); }
-void scalar::get(std::string& x) const { x = get<amqp_string>(); }
+void scalar::get(std::string& x) const { ok(PN_STRING); x = std::string(str_); }
+void scalar::get(symbol& x) const { ok(PN_SYMBOL); x = symbol(str_); }
+void scalar::get(binary& x) const { ok(PN_BINARY); x = binary(str_); }
 
 int64_t scalar::as_int() const {
     if (type_id_is_floating_point(type()))
@@ -187,9 +189,9 @@ template <class T, class F> T type_switch(const scalar& a, F f) {
       case DECIMAL64: return f(a.get<decimal64>());
       case DECIMAL128: return f(a.get<decimal128>());
       case UUID: return f(a.get<uuid>());
-      case BINARY: return f(a.get<amqp_binary>());
-      case STRING: return f(a.get<amqp_string>());
-      case SYMBOL: return f(a.get<amqp_symbol>());
+      case BINARY: return f(a.get<binary>());
+      case STRING: return f(a.get<std::string>());
+      case SYMBOL: return f(a.get<symbol>());
       default:
         throw error("bad scalar type");
     }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/proton-c/bindings/cpp/src/scalar_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/scalar_test.cpp b/proton-c/bindings/cpp/src/scalar_test.cpp
index 2af58d0..2949dcb 100644
--- a/proton-c/bindings/cpp/src/scalar_test.cpp
+++ b/proton-c/bindings/cpp/src/scalar_test.cpp
@@ -18,6 +18,9 @@
  */
 
 #include "test_bits.hpp"
+
+#include "proton/amqp.hpp"
+#include "proton/binary.hpp"
 #include "proton/type_traits.hpp"
 
 #include <proton/scalar.hpp>
@@ -69,11 +72,11 @@ void convert_test() {
     ASSERT(a.empty());
     ASSERT_MISMATCH(a.get<float>(), FLOAT, NULL_TYPE);
 
-    a = amqp_binary("foo");
+    a = binary("foo");
     ASSERT_MISMATCH(a.get<int16_t>(), SHORT, BINARY);
     ASSERT_MISMATCH(a.as_int(), LONG, BINARY);
     ASSERT_MISMATCH(a.as_double(), DOUBLE, BINARY);
-    ASSERT_MISMATCH(a.get<amqp_string>(), STRING, BINARY); // No strict conversion
+    ASSERT_MISMATCH(a.get<std::string>(), STRING, BINARY); // No strict conversion
     ASSERT_EQUAL(a.as_string(), std::string("foo")); // OK string-like conversion
 
     a = int16_t(42);
@@ -103,7 +106,7 @@ void encode_decode_test() {
 void message_id_test() {
     ASSERT_EQUAL(23, message_id(23).as_int());
     ASSERT_EQUAL(23, message_id(23).get<uint64_t>());
-    ASSERT(message_id("foo") != message_id(amqp_binary("foo")));
+    ASSERT(message_id("foo") != message_id(binary("foo")));
     ASSERT_EQUAL(scalar("foo"), message_id("foo"));
     ASSERT_EQUAL("foo", message_id("foo").as_string());
     ASSERT(message_id("a") < message_id("z"));
@@ -115,7 +118,7 @@ void annotation_key_test() {
     ASSERT_EQUAL(23, annotation_key(23).as_int());
     ASSERT_EQUAL(23, annotation_key(23).get<uint64_t>());
     ASSERT_EQUAL("foo", annotation_key("foo").as_string());
-    ASSERT_EQUAL(scalar(amqp_symbol("foo")), annotation_key("foo"));
+    ASSERT_EQUAL(scalar(symbol("foo")), annotation_key("foo"));
 }
 
 template <class T> T make(const char c) { T x; std::fill(x.begin(), x.end(), c); return x; }
@@ -123,25 +126,25 @@ template <class T> T make(const char c) { T x; std::fill(x.begin(), x.end(), c);
 int main(int, char**) {
     int failed = 0;
     RUN_TEST(failed, type_test(false, BOOLEAN, true));
-    RUN_TEST(failed, type_test(amqp_ubyte(42), UBYTE, amqp_ubyte(50)));
-    RUN_TEST(failed, type_test(amqp_byte('x'), BYTE, amqp_byte('y')));
-    RUN_TEST(failed, type_test(amqp_ushort(4242), USHORT, amqp_ushort(5252)));
-    RUN_TEST(failed, type_test(amqp_short(-4242), SHORT, amqp_short(3)));
-    RUN_TEST(failed, type_test(amqp_uint(4242), UINT, amqp_uint(5252)));
-    RUN_TEST(failed, type_test(amqp_int(-4242), INT, amqp_int(3)));
-    RUN_TEST(failed, type_test(amqp_ulong(4242), ULONG, amqp_ulong(5252)));
-    RUN_TEST(failed, type_test(amqp_long(-4242), LONG, amqp_long(3)));
+    RUN_TEST(failed, type_test(amqp::ubyte_type(42), UBYTE, amqp::ubyte_type(50)));
+    RUN_TEST(failed, type_test(amqp::byte_type('x'), BYTE, amqp::byte_type('y')));
+    RUN_TEST(failed, type_test(amqp::ushort_type(4242), USHORT, amqp::ushort_type(5252)));
+    RUN_TEST(failed, type_test(amqp::short_type(-4242), SHORT, amqp::short_type(3)));
+    RUN_TEST(failed, type_test(amqp::uint_type(4242), UINT, amqp::uint_type(5252)));
+    RUN_TEST(failed, type_test(amqp::int_type(-4242), INT, amqp::int_type(3)));
+    RUN_TEST(failed, type_test(amqp::ulong_type(4242), ULONG, amqp::ulong_type(5252)));
+    RUN_TEST(failed, type_test(amqp::long_type(-4242), LONG, amqp::long_type(3)));
     RUN_TEST(failed, type_test(wchar_t(23), CHAR, wchar_t(24)));
-    RUN_TEST(failed, type_test(amqp_float(1.234), FLOAT, amqp_float(2.345)));
-    RUN_TEST(failed, type_test(amqp_double(11.2233), DOUBLE, amqp_double(12)));
+    RUN_TEST(failed, type_test(amqp::float_type(1.234), FLOAT, amqp::float_type(2.345)));
+    RUN_TEST(failed, type_test(amqp::double_type(11.2233), DOUBLE, amqp::double_type(12)));
     RUN_TEST(failed, type_test(timestamp(0), TIMESTAMP, timestamp(1)));
     RUN_TEST(failed, type_test(make<decimal32>(0), DECIMAL32, make<decimal32>(1)));
     RUN_TEST(failed, type_test(make<decimal64>(0), DECIMAL64, make<decimal64>(1)));
     RUN_TEST(failed, type_test(make<decimal128>(0), DECIMAL128, make<decimal128>(1)));
     RUN_TEST(failed, type_test(uuid::make("a"), UUID, uuid::make("x")));
-    RUN_TEST(failed, type_test(amqp_string("aaa"), STRING, amqp_string("aaaa")));
-    RUN_TEST(failed, type_test(amqp_symbol("aaa"), SYMBOL, amqp_symbol("aaaa")));
-    RUN_TEST(failed, type_test(amqp_binary("aaa"), BINARY, amqp_binary("aaaa")));
+    RUN_TEST(failed, type_test(amqp::string_type("aaa"), STRING, amqp::string_type("aaaa")));
+    RUN_TEST(failed, type_test(amqp::symbol_type("aaa"), SYMBOL, amqp::symbol_type("aaaa")));
+    RUN_TEST(failed, type_test(amqp::binary_type("aaa"), BINARY, amqp::binary_type("aaaa")));
     RUN_TEST(failed, type_test(std::string("xxx"), STRING, std::string("yyy")));
     RUN_TEST(failed, encode_decode_test());
     RUN_TEST(failed, message_id_test());

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/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 64b48ec..6761f4e 100644
--- a/proton-c/bindings/cpp/src/sender.cpp
+++ b/proton-c/bindings/cpp/src/sender.cpp
@@ -38,11 +38,11 @@ namespace proton {
 
 namespace {
 // TODO: revisit if thread safety required
-amqp_ulong tag_counter = 0;
+uint64_t tag_counter = 0;
 }
 
 delivery sender::send(const message &message) {
-    amqp_ulong id = ++tag_counter;
+    uint64_t id = ++tag_counter;
     pn_delivery_t *dlv =
         pn_delivery(pn_object(), pn_dtag(reinterpret_cast<const char*>(&id), sizeof(id)));
     std::vector<char> buf;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/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 cc55531..4f12696 100644
--- a/proton-c/bindings/cpp/src/types.cpp
+++ b/proton-c/bindings/cpp/src/types.cpp
@@ -71,13 +71,6 @@ bool type_id_is_scalar(type_id t) { return type_id_is_integral(t) || type_id_is_
 std::ostream& operator<<(std::ostream& o, type_id t) { return o << type_name(t); }
 
 
-pn_bytes_t pn_bytes(const std::string& s) {
-    pn_bytes_t b = { s.size(), const_cast<char*>(&s[0]) };
-    return b;
-}
-
-std::string str(const pn_bytes_t& b) { return std::string(b.start, b.size); }
-
 start::start(type_id t, type_id e, bool d, size_t s) : type(t), element(e), is_described(d), size(s) {}
 start start::array(type_id element, bool described) { return start(ARRAY, element, described); }
 start start::list() { return start(LIST); }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/proton-c/bindings/cpp/src/types_internal.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/types_internal.hpp b/proton-c/bindings/cpp/src/types_internal.hpp
index a93913a..f17f68c 100644
--- a/proton-c/bindings/cpp/src/types_internal.hpp
+++ b/proton-c/bindings/cpp/src/types_internal.hpp
@@ -43,6 +43,15 @@ make_conversion_error(type_id want, type_id got, const std::string& msg=std::str
     return conversion_error(s.str());
 }
 
+/// Convert std::string to pn_bytes_t
+inline pn_bytes_t pn_bytes(const std::string& s) {
+    pn_bytes_t b = { s.size(), const_cast<char*>(&s[0]) };
+    return b;
+}
+
+/// Convert pn_bytes_t to str
+inline std::string str(const pn_bytes_t& b) { return std::string(b.start, b.size); }
+
 }
 
 #endif // CODEC_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/proton-c/bindings/cpp/src/value_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/value_test.cpp b/proton-c/bindings/cpp/src/value_test.cpp
index cc94950..c482673 100644
--- a/proton-c/bindings/cpp/src/value_test.cpp
+++ b/proton-c/bindings/cpp/src/value_test.cpp
@@ -19,7 +19,11 @@
 
 #include "test_bits.hpp"
 
+#include <proton/amqp.hpp>
+#include <proton/binary.hpp>
+#include <proton/symbol.hpp>
 #include <proton/value.hpp>
+
 #include <algorithm>
 #include <iostream>
 #include <iterator>
@@ -64,8 +68,8 @@ void map_test() {
     ASSERT_EQUAL("{\"a\"=1, \"b\"=2, \"c\"=3}",  str(v));
     std::map<value, value> mv;
     v.get(mv);
-    ASSERT_EQUAL(mv[value("a")], value(amqp_int(1)));
-    mv[value("b")] = amqp_binary("xyz");
+    ASSERT_EQUAL(mv[value("a")], value(amqp::int_type(1)));
+    mv[value("b")] = amqp::binary_type("xyz");
     mv.erase(value("c"));
     v = value(mv);
     ASSERT_EQUAL("{\"a\"=1, \"b\"=b\"xyz\"}",  str(v));
@@ -74,26 +78,26 @@ void map_test() {
     v.get_pairs(vec);
     ASSERT_EQUAL(2, vec.size());
     ASSERT_EQUAL(std::make_pair(std::string("a"), value(1)), vec[0]);
-    ASSERT_EQUAL(std::make_pair(std::string("b"), value(amqp_binary("xyz"))), vec[1]);
+    ASSERT_EQUAL(std::make_pair(std::string("b"), value(amqp::binary_type("xyz"))), vec[1]);
 }
 
 int main(int, char**) {
     int failed = 0;
     RUN_TEST(failed, value_test(false, BOOLEAN, "false", true));
-    RUN_TEST(failed, value_test(amqp_ubyte(42), UBYTE, "42", amqp_ubyte(50)));
-    RUN_TEST(failed, value_test(amqp_byte(-42), BYTE, "-42", amqp_byte(-40)));
-    RUN_TEST(failed, value_test(amqp_ushort(4242), USHORT, "4242", amqp_ushort(5252)));
-    RUN_TEST(failed, value_test(amqp_short(-4242), SHORT, "-4242", amqp_short(3)));
-    RUN_TEST(failed, value_test(amqp_uint(4242), UINT, "4242", amqp_uint(5252)));
-    RUN_TEST(failed, value_test(amqp_int(-4242), INT, "-4242", amqp_int(3)));
-    RUN_TEST(failed, value_test(amqp_ulong(4242), ULONG, "4242", amqp_ulong(5252)));
-    RUN_TEST(failed, value_test(amqp_long(-4242), LONG, "-4242", amqp_long(3)));
-    RUN_TEST(failed, value_test(amqp_float(1.234), FLOAT, "1.234", amqp_float(2.345)));
-    RUN_TEST(failed, value_test(amqp_double(11.2233), DOUBLE, "11.2233", amqp_double(12)));
-    RUN_TEST(failed, value_test(amqp_string("aaa"), STRING, "aaa", amqp_string("aaaa")));
+    RUN_TEST(failed, value_test(amqp::ubyte_type(42), UBYTE, "42", amqp::ubyte_type(50)));
+    RUN_TEST(failed, value_test(amqp::byte_type(-42), BYTE, "-42", amqp::byte_type(-40)));
+    RUN_TEST(failed, value_test(amqp::ushort_type(4242), USHORT, "4242", amqp::ushort_type(5252)));
+    RUN_TEST(failed, value_test(amqp::short_type(-4242), SHORT, "-4242", amqp::short_type(3)));
+    RUN_TEST(failed, value_test(amqp::uint_type(4242), UINT, "4242", amqp::uint_type(5252)));
+    RUN_TEST(failed, value_test(amqp::int_type(-4242), INT, "-4242", amqp::int_type(3)));
+    RUN_TEST(failed, value_test(amqp::ulong_type(4242), ULONG, "4242", amqp::ulong_type(5252)));
+    RUN_TEST(failed, value_test(amqp::long_type(-4242), LONG, "-4242", amqp::long_type(3)));
+    RUN_TEST(failed, value_test(amqp::float_type(1.234), FLOAT, "1.234", amqp::float_type(2.345)));
+    RUN_TEST(failed, value_test(amqp::double_type(11.2233), DOUBLE, "11.2233", amqp::double_type(12)));
+    RUN_TEST(failed, value_test(amqp::string_type("aaa"), STRING, "aaa", amqp::string_type("aaaa")));
     RUN_TEST(failed, value_test(std::string("xxx"), STRING, "xxx", std::string("yyy")));
-    RUN_TEST(failed, value_test(amqp_symbol("aaa"), SYMBOL, "aaa", amqp_symbol("aaaa")));
-    RUN_TEST(failed, value_test(amqp_binary("aaa"), BINARY, "b\"aaa\"", amqp_binary("aaaa")));
+    RUN_TEST(failed, value_test(amqp::symbol_type("aaa"), SYMBOL, "aaa", amqp::symbol_type("aaaa")));
+    RUN_TEST(failed, value_test(amqp::binary_type("aaa"), BINARY, "b\"aaa\"", amqp::binary_type("aaaa")));
     RUN_TEST(failed, map_test());
     return failed;
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a0fa5ce2/tests/tools/apps/cpp/reactor_send.cpp
----------------------------------------------------------------------
diff --git a/tests/tools/apps/cpp/reactor_send.cpp b/tests/tools/apps/cpp/reactor_send.cpp
index 6a6e8b6..ec4eb14 100644
--- a/tests/tools/apps/cpp/reactor_send.cpp
+++ b/tests/tools/apps/cpp/reactor_send.cpp
@@ -21,6 +21,7 @@
 
 #include "options.hpp"
 
+#include "proton/binary.hpp"
 #include "proton/container.hpp"
 #include "proton/handler.hpp"
 #include "proton/connection.hpp"
@@ -46,7 +47,7 @@ class reactor_send : public proton::handler {
     int total_;
     int received_;
     size_t received_bytes_;
-    proton::amqp_binary received_content_;
+    proton::binary received_content_;
     bool replying_;
     proton::message_id id_value_;
     proton::reactor reactor_;
@@ -58,7 +59,7 @@ class reactor_send : public proton::handler {
           received_(0), received_bytes_(0), replying_(replying) {
         if (replying_)
             message_.reply_to("localhost/test");
-        proton::amqp_binary content;
+        proton::binary content;
         content.assign((size_t) size, 'X');
         message_.body(content);
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[3/6] qpid-proton git commit: PROTON-1138: c++: Extend_CXX_FLAGS in CMakeLists.txt, don't overwrite user setting.

Posted by ac...@apache.org.
PROTON-1138: c++: Extend_CXX_FLAGS in CMakeLists.txt, don't overwrite user setting.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/1de2f11f
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/1de2f11f
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/1de2f11f

Branch: refs/heads/master
Commit: 1de2f11f32bfa45ce0bad3b768b3d0f94aadb540
Parents: c7f3f55
Author: Alan Conway <ac...@redhat.com>
Authored: Mon Feb 22 13:56:16 2016 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Thu Feb 25 17:50:55 2016 -0500

----------------------------------------------------------------------
 proton-c/CMakeLists.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1de2f11f/proton-c/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/CMakeLists.txt b/proton-c/CMakeLists.txt
index 6e755a9..a446db7 100644
--- a/proton-c/CMakeLists.txt
+++ b/proton-c/CMakeLists.txt
@@ -239,8 +239,8 @@ if (CMAKE_COMPILER_IS_GNUCC)
   endif (ENABLE_LINKTIME_OPTIMIZATION)
 
   if (ENABLE_HIDE_UNEXPORTED_SYMBOLS)
-    set (CMAKE_C_FLAGS "-fvisibility=hidden")
-    set (CMAKE_CXX_FLAGS "-fvisibility=hidden")
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
   endif (ENABLE_HIDE_UNEXPORTED_SYMBOLS)
 endif (CMAKE_COMPILER_IS_GNUCC)
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[2/6] qpid-proton git commit: PROTON-1138: c++: Make id_generator class private

Posted by ac...@apache.org.
PROTON-1138: c++: Make id_generator class private


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/6e857089
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/6e857089
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/6e857089

Branch: refs/heads/master
Commit: 6e8570898998beea953628238c897989a0344ca1
Parents: 1de2f11
Author: Alan Conway <ac...@redhat.com>
Authored: Tue Feb 23 12:17:06 2016 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Thu Feb 25 17:50:55 2016 -0500

----------------------------------------------------------------------
 .../cpp/include/proton/connection_engine.hpp    |  8 ++--
 .../cpp/include/proton/id_generator.hpp         | 47 --------------------
 proton-c/bindings/cpp/src/connection_engine.cpp | 24 +++++++---
 proton-c/bindings/cpp/src/container_impl.hpp    | 12 ++---
 proton-c/bindings/cpp/src/contexts.hpp          |  2 +-
 proton-c/bindings/cpp/src/id_generator.cpp      |  2 +-
 proton-c/bindings/cpp/src/id_generator.hpp      | 47 ++++++++++++++++++++
 7 files changed, 76 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6e857089/proton-c/bindings/cpp/include/proton/connection_engine.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/connection_engine.hpp b/proton-c/bindings/cpp/include/proton/connection_engine.hpp
index beeefc5..0c509d2 100644
--- a/proton-c/bindings/cpp/include/proton/connection_engine.hpp
+++ b/proton-c/bindings/cpp/include/proton/connection_engine.hpp
@@ -23,7 +23,6 @@
 #include "proton/connection.hpp"
 #include "proton/connection_options.hpp"
 #include "proton/export.hpp"
-#include "proton/id_generator.hpp"
 #include "proton/pn_unique_ptr.hpp"
 #include "proton/types.hpp"
 
@@ -70,6 +69,7 @@ PN_CPP_CLASS_EXTERN connection_engine {
         /// Create a container with id.  Default to random UUID if id
         /// == "".
         PN_CPP_EXTERN container(const std::string &id = "");
+        PN_CPP_EXTERN ~container();
 
         /// Return the container-id
         PN_CPP_EXTERN std::string id() const;
@@ -86,11 +86,9 @@ PN_CPP_CLASS_EXTERN connection_engine {
         PN_CPP_EXTERN void options(const connection_options&);
 
       private:
-        const std::string id_;
-        id_generator id_gen_;
-        connection_options options_;
+        class impl;
+        pn_unique_ptr<impl> impl_;
     };
-
     /// Create a connection engine that dispatches to handler.
     PN_CPP_EXTERN connection_engine(handler&, const connection_options& = no_opts);
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6e857089/proton-c/bindings/cpp/include/proton/id_generator.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/id_generator.hpp b/proton-c/bindings/cpp/include/proton/id_generator.hpp
deleted file mode 100644
index 687d27e..0000000
--- a/proton-c/bindings/cpp/include/proton/id_generator.hpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-///@internal
-#include "proton/types.hpp"
-
-#ifndef ID_GENERATOR_HPP
-#define ID_GENERATOR_HPP
-
-namespace proton {
-
-/// @cond INTERNAL
-/// XXX should this be in the interface at all?
-/// XXX decision - make this private
-class id_generator {
-  public:
-    PN_CPP_EXTERN id_generator(const std::string &prefix="");
-    PN_CPP_EXTERN std::string next();
-    void prefix(const std::string &p) { prefix_ = p; }
-    const std::string& prefix() const { return prefix_; }
-
-  private:
-    std::string prefix_;
-    uint64_t count_;
-};
-
-}
-
-/// @endcond
-
-#endif

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6e857089/proton-c/bindings/cpp/src/connection_engine.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connection_engine.cpp b/proton-c/bindings/cpp/src/connection_engine.cpp
index 940bca6..a15fe95 100644
--- a/proton-c/bindings/cpp/src/connection_engine.cpp
+++ b/proton-c/bindings/cpp/src/connection_engine.cpp
@@ -23,10 +23,11 @@
 #include "proton/uuid.hpp"
 
 #include "contexts.hpp"
+#include "id_generator.hpp"
 #include "messaging_adapter.hpp"
+#include "messaging_event.hpp"
 #include "msg.hpp"
 #include "proton_bits.hpp"
-#include "messaging_event.hpp"
 #include "proton_bits.hpp"
 
 #include <proton/connection.h>
@@ -56,18 +57,29 @@ void close_transport(connection_engine_context *ctx_) {
 std::string  make_id(const std::string s="") { return s.empty() ? uuid::random().str() : s; }
 }
 
-connection_engine::container::container(const std::string& s) : id_(make_id(s)) {}
+class connection_engine::container::impl {
+  public:
+    impl(const std::string s="") : id_(make_id(s)) {}
+
+    const std::string id_;
+    id_generator id_gen_;
+    connection_options options_;
+};
+
+connection_engine::container::container(const std::string& s) : impl_(new impl(s)) {}
+
+connection_engine::container::~container() {}
 
-std::string connection_engine::container::id() const { return id_; }
+std::string connection_engine::container::id() const { return impl_->id_; }
 
 connection_options connection_engine::container::make_options() {
-    connection_options opts = options_;
-    opts.container_id(id()).link_prefix(id_gen_.next()+"/");
+    connection_options opts = impl_->options_;
+    opts.container_id(id()).link_prefix(impl_->id_gen_.next()+"/");
     return opts;
 }
 
 void connection_engine::container::options(const connection_options &opts) {
-    options_ = opts;
+    impl_->options_ = opts;
 }
 
 connection_engine::connection_engine(class handler &h, const connection_options& opts) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6e857089/proton-c/bindings/cpp/src/container_impl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/container_impl.hpp b/proton-c/bindings/cpp/src/container_impl.hpp
index 8d4eb9d..049493e 100644
--- a/proton-c/bindings/cpp/src/container_impl.hpp
+++ b/proton-c/bindings/cpp/src/container_impl.hpp
@@ -21,18 +21,18 @@
  * under the License.
  *
  */
+
+#include "id_generator.hpp"
+
+#include "proton/connection.hpp"
+#include "proton/duration.hpp"
 #include "proton/export.hpp"
 #include "proton/handler.hpp"
-#include "proton/connection.hpp"
 #include "proton/link.hpp"
-#include "proton/duration.hpp"
+#include "proton/reactor.h"
 #include "proton/reactor.hpp"
-#include "proton/id_generator.hpp"
-
 #include "proton_handler.hpp"
 
-#include "proton/reactor.h"
-
 #include <string>
 
 namespace proton {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6e857089/proton-c/bindings/cpp/src/contexts.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/contexts.hpp b/proton-c/bindings/cpp/src/contexts.hpp
index e558158..219a909 100644
--- a/proton-c/bindings/cpp/src/contexts.hpp
+++ b/proton-c/bindings/cpp/src/contexts.hpp
@@ -27,8 +27,8 @@
 #include "proton/connection.hpp"
 #include "proton/container.hpp"
 #include "proton/connection_engine.hpp"
-#include "proton/id_generator.hpp"
 
+#include "id_generator.hpp"
 #include "proton_handler.hpp"
 
 struct pn_session_t;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6e857089/proton-c/bindings/cpp/src/id_generator.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/id_generator.cpp b/proton-c/bindings/cpp/src/id_generator.cpp
index b1b4d06..c12d5a4 100644
--- a/proton-c/bindings/cpp/src/id_generator.cpp
+++ b/proton-c/bindings/cpp/src/id_generator.cpp
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-#include "proton/id_generator.hpp"
+#include "id_generator.hpp"
 #include <sstream>
 
 namespace proton {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6e857089/proton-c/bindings/cpp/src/id_generator.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/id_generator.hpp b/proton-c/bindings/cpp/src/id_generator.hpp
new file mode 100644
index 0000000..687d27e
--- /dev/null
+++ b/proton-c/bindings/cpp/src/id_generator.hpp
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+///@internal
+#include "proton/types.hpp"
+
+#ifndef ID_GENERATOR_HPP
+#define ID_GENERATOR_HPP
+
+namespace proton {
+
+/// @cond INTERNAL
+/// XXX should this be in the interface at all?
+/// XXX decision - make this private
+class id_generator {
+  public:
+    PN_CPP_EXTERN id_generator(const std::string &prefix="");
+    PN_CPP_EXTERN std::string next();
+    void prefix(const std::string &p) { prefix_ = p; }
+    const std::string& prefix() const { return prefix_; }
+
+  private:
+    std::string prefix_;
+    uint64_t count_;
+};
+
+}
+
+/// @endcond
+
+#endif


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[5/6] qpid-proton git commit: PROTON-1138: c++: Clean up error types.

Posted by ac...@apache.org.
PROTON-1138: c++: Clean up error types.

Removed proton::closed_error
Renamed proton::io_error as proton::connection_engine::io_error
Replaced encode_error, decode_error and type_error with proton::conversion_error


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/8cbde662
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/8cbde662
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/8cbde662

Branch: refs/heads/master
Commit: 8cbde66258b1389c85fc467d5c0ed65301587250
Parents: 6e85708
Author: Alan Conway <ac...@redhat.com>
Authored: Tue Feb 23 12:57:02 2016 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Thu Feb 25 17:50:56 2016 -0500

----------------------------------------------------------------------
 examples/cpp/engine/broker.cpp                  |  2 +-
 .../cpp/include/proton/connection_engine.hpp    | 10 +++-
 proton-c/bindings/cpp/include/proton/error.hpp  | 50 ++------------------
 proton-c/bindings/cpp/include/proton/io.hpp     | 12 +++--
 .../bindings/cpp/include/proton/message_id.hpp  |  2 +-
 proton-c/bindings/cpp/include/proton/scalar.hpp |  6 +--
 proton-c/bindings/cpp/include/proton/types.hpp  |  9 ----
 proton-c/bindings/cpp/include/proton/value.hpp  |  2 +-
 proton-c/bindings/cpp/src/connection_engine.cpp |  4 +-
 proton-c/bindings/cpp/src/decoder.cpp           | 24 +++++-----
 proton-c/bindings/cpp/src/encoder.cpp           |  6 +--
 proton-c/bindings/cpp/src/error.cpp             |  9 +---
 proton-c/bindings/cpp/src/interop_test.cpp      | 16 +++----
 proton-c/bindings/cpp/src/posix/io.cpp          |  4 +-
 proton-c/bindings/cpp/src/scalar.cpp            | 10 ++--
 proton-c/bindings/cpp/src/scalar_test.cpp       | 15 +++---
 proton-c/bindings/cpp/src/types.cpp             | 14 ------
 proton-c/bindings/cpp/src/types_internal.hpp    |  9 ++++
 proton-c/bindings/cpp/src/windows/io.cpp        |  6 +--
 19 files changed, 78 insertions(+), 132 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8cbde662/examples/cpp/engine/broker.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/engine/broker.cpp b/examples/cpp/engine/broker.cpp
index 528bf86..09345de 100644
--- a/examples/cpp/engine/broker.cpp
+++ b/examples/cpp/engine/broker.cpp
@@ -80,7 +80,7 @@ int main(int argc, char **argv) {
 
 template <class T> T check(T result, const std::string& msg="io_error: ") {
     if (result < 0)
-        throw proton::io_error(msg + proton::io::error_str());
+        throw proton::connection_engine::io_error(msg + proton::io::error_str());
     return result;
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8cbde662/proton-c/bindings/cpp/include/proton/connection_engine.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/connection_engine.hpp b/proton-c/bindings/cpp/include/proton/connection_engine.hpp
index 0c509d2..4834c18 100644
--- a/proton-c/bindings/cpp/include/proton/connection_engine.hpp
+++ b/proton-c/bindings/cpp/include/proton/connection_engine.hpp
@@ -22,6 +22,7 @@
 
 #include "proton/connection.hpp"
 #include "proton/connection_options.hpp"
+#include "proton/error.hpp"
 #include "proton/export.hpp"
 #include "proton/pn_unique_ptr.hpp"
 #include "proton/types.hpp"
@@ -123,6 +124,11 @@ PN_CPP_CLASS_EXTERN connection_engine {
     /// Get the AMQP connection associated with this connection_engine.
     PN_CPP_EXTERN class connection connection() const;
 
+    /// Thrown by io_read and io_write functions to indicate an error.
+    struct PN_CPP_CLASS_EXTERN io_error : public error {
+        PN_CPP_EXTERN explicit io_error(const std::string&);
+    };
+
   protected:
     /// Do a non-blocking read on the IO stream.
     ///
@@ -130,7 +136,7 @@ PN_CPP_CLASS_EXTERN connection_engine {
     /// size==0 means no data could be read without blocking, the stream is still open.
     /// Returns pair(0, false) if the stream closed.
     ///
-    ///@throw proton::io_error if there is a read error.
+    ///@throw proton::connection_engine::io_error if there is a read error.
     virtual std::pair<size_t, bool> io_read(char* buf, size_t max) = 0;
 
     /// Do a non-blocking write of up to max bytes from buf.
@@ -138,7 +144,7 @@ PN_CPP_CLASS_EXTERN connection_engine {
     /// Return the number of byes written , 0 if no data could be written
     /// without blocking.
     ///
-    ///throw proton::io_error if there is a write error.
+    ///throw proton::connection_engine::io_error if there is a write error.
     virtual size_t io_write(const char*, size_t) = 0;
 
     /// Close the io, no more _io methods will be called after this is called.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8cbde662/proton-c/bindings/cpp/include/proton/error.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/error.hpp b/proton-c/bindings/cpp/include/proton/error.hpp
index 6877bcc..b947ba6 100644
--- a/proton-c/bindings/cpp/include/proton/error.hpp
+++ b/proton-c/bindings/cpp/include/proton/error.hpp
@@ -31,67 +31,25 @@
 namespace proton {
 
 /// The base proton error.
-///    
+///
 /// All exceptions thrown from functions in the proton namespace are
 /// subclasses of proton::error.
 struct
 PN_CPP_CLASS_EXTERN error : public std::runtime_error {
-    /// @cond INTERNAL
-    /// XXX do we intend users to construct these (and subclasses)?
-    /// XXX don't need to be extern?
     PN_CPP_EXTERN explicit error(const std::string&);
-    /// @endcond
 };
 
 /// Raised if a timeout expires.
 struct
 PN_CPP_CLASS_EXTERN timeout_error : public error {
-    /// @cond INTERNAL
     PN_CPP_EXTERN explicit timeout_error(const std::string&);
-    /// @endcond
 };
 
-/// @cond INTERNAL
-/// XXX change namespace to proton::amqp with encoder and decoder?
-
-/// Raised if there is an error decoding AMQP data as a C++ value.
-struct
-PN_CPP_CLASS_EXTERN decode_error : public error {
-    PN_CPP_EXTERN explicit decode_error(const std::string&);
-};
-
-/// Raised if there is an error encoding a C++ value as AMQP data.
-struct
-PN_CPP_CLASS_EXTERN encode_error : public error {
-    PN_CPP_EXTERN explicit encode_error(const std::string&);
-};
-
-/// @endcond
-
-/// @cond INTERNAL
-/// XXX need to discuss
-
-/// XXX move this with connection_engine to an io package?
-/// Error reading or writing external IO.
+/// Raised if there is an error converting between AMQP and C++ data.
 struct
-PN_CPP_CLASS_EXTERN io_error : public error {
-    // XXX needs to remain public and exposed - it's part of the connection_engine SPI
-    PN_CPP_EXTERN explicit io_error(const std::string&);
+PN_CPP_CLASS_EXTERN conversion_error : public error {
+    PN_CPP_EXTERN explicit conversion_error(const std::string&);
 };
-
-/// XXX do we need something this fine grained? and is it really an
-/// *io* error?
-/// XXX doesn't appear to be thrown anywhere - consider removing
-/// Attempt to use a closed resource (connnection, session, or link).
-/// XXX decision - remove
-struct
-PN_CPP_CLASS_EXTERN closed_error : public io_error {
-    PN_CPP_EXTERN explicit closed_error(const std::string& = default_msg);
-    static const std::string default_msg;
-};
-
-/// @endcond
-
 }
 
 #endif // PROTON_CPP_EXCEPTIONS_H

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8cbde662/proton-c/bindings/cpp/include/proton/io.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/io.hpp b/proton-c/bindings/cpp/include/proton/io.hpp
index 63c78a6..e559504 100644
--- a/proton-c/bindings/cpp/include/proton/io.hpp
+++ b/proton-c/bindings/cpp/include/proton/io.hpp
@@ -24,11 +24,13 @@
 
 namespace proton {
 
-/// IO using sockets, file descriptors, or handles.
-
-/// Note that you can use proton::connection_engine to communicate
-/// using AMQP over your own IO implementation or to integrate an
-/// existing IO framework of your choice.
+/// IO using sockets, file descriptors, or handles, for use with
+/// proton::connection_engine.
+///
+/// Note that you can use proton::connection_engine to communicate using AMQP
+/// over your own IO implementation or to integrate an existing IO framework of
+/// your choice, this implementation is provided as a convenience if sockets is
+/// sufficient for your needs.
 
 namespace io {
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8cbde662/proton-c/bindings/cpp/include/proton/message_id.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/message_id.hpp b/proton-c/bindings/cpp/include/proton/message_id.hpp
index fcfd125..ace58f9 100644
--- a/proton-c/bindings/cpp/include/proton/message_id.hpp
+++ b/proton-c/bindings/cpp/include/proton/message_id.hpp
@@ -62,7 +62,7 @@ class message_id : public restricted_scalar {
     /// @name Get methods
     ///
     /// get(T&) extracts the value if the types match exactly and
-    /// throws type_error otherwise.
+    /// throws conversion_error otherwise.
     ///
     /// @{
     void get(uint64_t& x) const { scalar_.get(x); }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8cbde662/proton-c/bindings/cpp/include/proton/scalar.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/scalar.hpp b/proton-c/bindings/cpp/include/proton/scalar.hpp
index 6d8ed8c..822efc6 100644
--- a/proton-c/bindings/cpp/include/proton/scalar.hpp
+++ b/proton-c/bindings/cpp/include/proton/scalar.hpp
@@ -89,7 +89,7 @@ class scalar : private comparable<scalar> {
     /// @name Get methods
     ///
     /// get(T&) extracts the value if the types match exactly and
-    /// throws type_error otherwise.
+    /// throws conversion_error otherwise.
     ///
     /// @{
     PN_CPP_EXTERN void get(bool&) const;
@@ -122,7 +122,7 @@ class scalar : private comparable<scalar> {
     ///
     /// As methods do "loose" conversion.  They will convert the
     /// scalar's value to the requested type if possible, else throw
-    /// type_error.
+    /// conversion_error.
     ///
     /// @{
     PN_CPP_EXTERN int64_t as_int() const;        ///< Allowed if type_id_is_integral(type())
@@ -169,7 +169,7 @@ class restricted_scalar : private comparable<restricted_scalar> {
     ///
     /// As methods do "loose" conversion.  They will convert the
     /// scalar's value to the requested type if possible, else throw
-    /// type_error.
+    /// conversion_error.
     ///
     /// @{
     int64_t as_int() const { return scalar_.as_int(); }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8cbde662/proton-c/bindings/cpp/include/proton/types.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/types.hpp b/proton-c/bindings/cpp/include/proton/types.hpp
index 312ac75..c052cd1 100644
--- a/proton-c/bindings/cpp/include/proton/types.hpp
+++ b/proton-c/bindings/cpp/include/proton/types.hpp
@@ -73,15 +73,6 @@ PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, type_id);
 
 /// @cond INTERNAL
 
-/// XXX change namespace
-/// Raised when there is a type mismatch, with the expected and actual
-/// type ID.
-struct type_error : public decode_error {
-    PN_CPP_EXTERN explicit type_error(type_id want, type_id got, const std::string& =std::string());
-    type_id want; ///< Expected type_id
-    type_id got;  ///< Actual type_id
-};
-
 PN_CPP_EXTERN pn_bytes_t pn_bytes(const std::string&);
 PN_CPP_EXTERN std::string str(const pn_bytes_t& b);
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8cbde662/proton-c/bindings/cpp/include/proton/value.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/value.hpp b/proton-c/bindings/cpp/include/proton/value.hpp
index e6cfec0..8de6962 100644
--- a/proton-c/bindings/cpp/include/proton/value.hpp
+++ b/proton-c/bindings/cpp/include/proton/value.hpp
@@ -91,7 +91,7 @@ class value : private comparable<value> {
     /// @name As methods
     ///
     /// As methods do "loose" conversion, they will convert the scalar
-    /// value to the requested type if possible, else throw type_error.
+    /// value to the requested type if possible, else throw conversion_error.
     ///
     /// @{
     PN_CPP_EXTERN int64_t as_int() const;        ///< Allowed if `type_id_is_integral(type())`

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8cbde662/proton-c/bindings/cpp/src/connection_engine.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connection_engine.cpp b/proton-c/bindings/cpp/src/connection_engine.cpp
index a15fe95..043c96e 100644
--- a/proton-c/bindings/cpp/src/connection_engine.cpp
+++ b/proton-c/bindings/cpp/src/connection_engine.cpp
@@ -57,6 +57,8 @@ void close_transport(connection_engine_context *ctx_) {
 std::string  make_id(const std::string s="") { return s.empty() ? uuid::random().str() : s; }
 }
 
+connection_engine::io_error::io_error(const std::string& msg) : error(msg) {}
+
 class connection_engine::container::impl {
   public:
     impl(const std::string s="") : id_(make_id(s)) {}
@@ -189,8 +191,6 @@ void connection_engine::try_write() {
             throw io_error(msg() << "write invalid size: " << n << " > " << max);
         }
         pn_transport_pop(ctx_->transport, n);
-    } catch (const closed_error&) {
-        pn_transport_close_head(ctx_->transport);
     } catch (const io_error& e) {
         set_error(ctx_, e.what());
         pn_transport_close_head(ctx_->transport);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8cbde662/proton-c/bindings/cpp/src/decoder.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/decoder.cpp b/proton-c/bindings/cpp/src/decoder.cpp
index 9056674..2246339 100644
--- a/proton-c/bindings/cpp/src/decoder.cpp
+++ b/proton-c/bindings/cpp/src/decoder.cpp
@@ -55,7 +55,7 @@ struct narrow {
 
 template <class T> T check(T result) {
     if (result < 0)
-        throw decode_error("" + error_str(result));
+        throw conversion_error("" + error_str(result));
     return result;
 }
 
@@ -89,13 +89,13 @@ data decoder::data() { return proton::data(pn_object()); }
 namespace {
 
 void bad_type(type_id want, type_id got) {
-    if (want != got) throw type_error(want, got);
+    if (want != got) throw make_conversion_error(want, got);
 }
 
 type_id pre_get(pn_data_t* data) {
-    if (!pn_data_next(data)) throw decode_error("no more data");
+    if (!pn_data_next(data)) throw conversion_error("no more data");
     type_id t = type_id(pn_data_type(data));
-    if (t < 0) throw decode_error("invalid data");
+    if (t < 0) throw conversion_error("invalid data");
     return t;
 }
 
@@ -145,7 +145,7 @@ decoder operator>>(decoder d0, start& s) {
         s.size = 1;
         break;
       default:
-        throw decode_error(MSG("" << s.type << " is not a container type"));
+        throw conversion_error(MSG("" << s.type << " is not a container type"));
     }
     pn_data_enter(d);
     ss.cancel();
@@ -163,12 +163,12 @@ decoder operator>>(decoder d, rewind) { d.rewind(); return d; }
 decoder operator>>(decoder d, value& v) {
     data ddata = d.data();
     data vdata = v.encode().data();
-    if (d.data() == v.data_) throw decode_error("extract into self");
+    if (d.data() == v.data_) throw conversion_error("extract into self");
     {
         narrow n(ddata);
         check(vdata.appendn(ddata, 1));
     }
-    if (!ddata.next()) throw decode_error("no more data");
+    if (!ddata.next()) throw conversion_error("no more data");
     return d;
 }
 
@@ -180,7 +180,7 @@ decoder operator>>(decoder d, message_id& x) {
       case STRING:
         return d >> x.scalar_;
       default:
-        throw decode_error("expected one of ulong, uuid, binary or string but found " +
+        throw conversion_error("expected one of ulong, uuid, binary or string but found " +
                            type_name(d.type()));
     };
 }
@@ -191,7 +191,7 @@ decoder operator>>(decoder d, annotation_key& x) {
       case SYMBOL:
         return d >> x.scalar_;
       default:
-        throw decode_error("expected one of ulong or symbol but found " + type_name(d.type()));
+        throw conversion_error("expected one of ulong or symbol but found " + type_name(d.type()));
     };
 }
 
@@ -205,7 +205,7 @@ decoder operator>>(decoder d, scalar& x) {
     save_state ss(d.pn_object());
     type_id got = pre_get(d.pn_object());
     if (!type_id_is_scalar(got))
-        throw decode_error("expected scalar, found "+type_name(got));
+        throw conversion_error("expected scalar, found "+type_name(got));
     x.set(pn_data_get_atom(d.pn_object()));
     ss.cancel();                // No error, no rewind
     return d;
@@ -385,9 +385,9 @@ decoder operator>>(decoder d0, std::string &x) {
 
 void assert_map_scope(const scope& s) {
     if (s.type != MAP)
-        throw decode_error("cannot decode "+type_name(s.type)+" as map");
+        throw conversion_error("cannot decode "+type_name(s.type)+" as map");
     if (s.size % 2 != 0)
-        throw decode_error("odd number of elements in map");
+        throw conversion_error("odd number of elements in map");
 }
 
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8cbde662/proton-c/bindings/cpp/src/encoder.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/encoder.cpp b/proton-c/bindings/cpp/src/encoder.cpp
index 58246d7..fd0a1d3 100644
--- a/proton-c/bindings/cpp/src/encoder.cpp
+++ b/proton-c/bindings/cpp/src/encoder.cpp
@@ -45,7 +45,7 @@ struct save_state {
 
 void check(long result, pn_data_t* data) {
     if (result < 0)
-        throw encode_error(error_str(pn_data_error(data), result));
+        throw conversion_error(error_str(pn_data_error(data), result));
 }
 }
 
@@ -90,7 +90,7 @@ encoder operator<<(encoder e, const start& s) {
       case LIST: pn_data_put_list(e.pn_object()); break;
       case DESCRIBED: pn_data_put_described(e.pn_object()); break;
       default:
-        throw encode_error(MSG("" << s.type << " is not a container type"));
+        throw conversion_error(MSG("" << s.type << " is not a container type"));
     }
     pn_data_enter(e.pn_object());
     return e;
@@ -147,7 +147,7 @@ encoder operator<<(encoder e, amqp_binary x) { return insert(e, e.pn_object(), x
 
 encoder operator<<(encoder e, const value& v) {
     data edata = e.data();
-    if (edata == v.data_) throw encode_error("cannot insert into self");
+    if (edata == v.data_) throw conversion_error("cannot insert into self");
     data vdata = v.decode().data();
     check(edata.append(vdata), e.pn_object());
     return e;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8cbde662/proton-c/bindings/cpp/src/error.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/error.cpp b/proton-c/bindings/cpp/src/error.cpp
index 1dedab1..28fd9f5 100644
--- a/proton-c/bindings/cpp/src/error.cpp
+++ b/proton-c/bindings/cpp/src/error.cpp
@@ -25,13 +25,6 @@ error::error(const std::string& msg) : std::runtime_error(msg) {}
 
 timeout_error::timeout_error(const std::string& msg) : error(msg) {}
 
-decode_error::decode_error(const std::string& msg) : error("decode: "+msg) {}
-
-encode_error::encode_error(const std::string& msg) : error("encode: "+msg) {}
-
-io_error::io_error(const std::string& msg) : error(msg) {}
-
-closed_error::closed_error(const std::string& msg) : io_error(msg) {}
-const std::string closed_error::default_msg("closed");
+conversion_error::conversion_error(const std::string& msg) : error(msg) {}
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8cbde662/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 168677b..9ac162c 100644
--- a/proton-c/bindings/cpp/src/interop_test.cpp
+++ b/proton-c/bindings/cpp/src/interop_test.cpp
@@ -59,22 +59,22 @@ void test_decoder_primitves_exact() {
     dv.decode().decode(read("primitives"));
     decoder d(dv.decode());
     ASSERT(d.more());
-    try { get< ::int8_t>(d); FAIL("got bool as byte"); } catch(decode_error){}
+    try { get< ::int8_t>(d); FAIL("got bool as byte"); } catch(conversion_error){}
     ASSERT_EQUAL(true, get<bool>(d));
     ASSERT_EQUAL(false, get<bool>(d));
-    try { get< ::int8_t>(d); FAIL("got ubyte as byte"); } catch(decode_error){}
+    try { get< ::int8_t>(d); FAIL("got ubyte as byte"); } catch(conversion_error){}
     ASSERT_EQUAL(42, get< ::uint8_t>(d));
-    try { get< ::int32_t>(d); FAIL("got uint as ushort"); } catch(decode_error){}
+    try { get< ::int32_t>(d); FAIL("got uint as ushort"); } catch(conversion_error){}
     ASSERT_EQUAL(42, get< ::uint16_t>(d));
-    try { get< ::uint16_t>(d); FAIL("got short as ushort"); } catch(decode_error){}
+    try { get< ::uint16_t>(d); FAIL("got short as ushort"); } catch(conversion_error){}
     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(decode_error){}
+    try { get<double>(d); FAIL("got float as double"); } catch(conversion_error){}
     ASSERT_EQUAL(0.125, get<float>(d));
-    try { get<float>(d); FAIL("got double as float"); } catch(decode_error){}
+    try { get<float>(d); FAIL("got double as float"); } catch(conversion_error){}
     ASSERT_EQUAL(0.125, get<double>(d));
     ASSERT(!d.more());
 }
@@ -103,8 +103,8 @@ void test_value_conversions() {
     ASSERT_EQUAL(3, (v=amqp_byte(3)).get<long>());
     ASSERT_EQUAL(1.0, (v=amqp_float(1.0)).get<double>());
     ASSERT_EQUAL(1.0, (v=amqp_double(1.0)).get<float>());
-    try { (void)(v = amqp_byte(1)).get<bool>(); FAIL("got byte as bool"); } catch (decode_error) {}
-    try { (void)(v = true).get<float>(); FAIL("got bool as float"); } catch (decode_error) {}
+    try { (void)(v = amqp_byte(1)).get<bool>(); FAIL("got byte as bool"); } catch (conversion_error) {}
+    try { (void)(v = true).get<float>(); FAIL("got bool as float"); } catch (conversion_error) {}
 }
 
 // TODO aconway 2015-06-11: interop test is not complete.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8cbde662/proton-c/bindings/cpp/src/posix/io.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/posix/io.cpp b/proton-c/bindings/cpp/src/posix/io.cpp
index 6da2887..a85972a 100644
--- a/proton-c/bindings/cpp/src/posix/io.cpp
+++ b/proton-c/bindings/cpp/src/posix/io.cpp
@@ -48,12 +48,12 @@ std::string error_str() {
 namespace {
 
 template <class T> T check(T result, const std::string& msg=std::string()) {
-    if (result < 0) throw io_error(msg + error_str());
+    if (result < 0) throw connection_engine::io_error(msg + error_str());
     return result;
 }
 
 void gai_check(int result, const std::string& msg="") {
-    if (result) throw io_error(msg + gai_strerror(result));
+    if (result) throw connection_engine::io_error(msg + gai_strerror(result));
 }
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8cbde662/proton-c/bindings/cpp/src/scalar.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/scalar.cpp b/proton-c/bindings/cpp/src/scalar.cpp
index eab19e6..4306e6b 100644
--- a/proton-c/bindings/cpp/src/scalar.cpp
+++ b/proton-c/bindings/cpp/src/scalar.cpp
@@ -99,7 +99,7 @@ scalar& scalar::operator=(const std::string& x) { set(x, PN_STRING); return *thi
 scalar& scalar::operator=(const char* x) { set(x, PN_STRING); return *this; }
 
 void scalar::ok(pn_type_t t) const {
-    if (atom_.type != t) throw type_error(type_id(t), type());
+    if (atom_.type != t) throw make_conversion_error(type_id(t), type());
 }
 
 void scalar::get(bool& x) const { ok(PN_BOOL); x = atom_.u.as_bool; }
@@ -139,13 +139,13 @@ int64_t scalar::as_int() const {
       case PN_ULONG: return int64_t(atom_.u.as_ulong);
       case PN_LONG: return atom_.u.as_long;
       case PN_TIMESTAMP: return atom_.u.as_timestamp;
-      default: throw type_error(LONG, type(), "cannot convert");
+      default: throw make_conversion_error(LONG, type());
     }
 }
 
 uint64_t scalar::as_uint() const {
     if  (!type_id_is_integral(type()))
-        throw type_error(ULONG, type(), "cannot convert");
+        throw make_conversion_error(ULONG, type());
     return uint64_t(as_int());
 }
 
@@ -156,14 +156,14 @@ double scalar::as_double() const {
     switch (atom_.type) {
       case PN_DOUBLE: return atom_.u.as_double;
       case PN_FLOAT: return atom_.u.as_float;
-      default: throw type_error(DOUBLE, type(), "cannot convert");
+      default: throw make_conversion_error(DOUBLE, type());
     }
 }
 
 std::string scalar::as_string() const {
     if (type_id_is_string_like(type()))
         return str_;
-    throw type_error(STRING, type(), "cannot convert");
+    throw make_conversion_error(STRING, type());
 }
 
 namespace {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8cbde662/proton-c/bindings/cpp/src/scalar_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/scalar_test.cpp b/proton-c/bindings/cpp/src/scalar_test.cpp
index c444acd..2af58d0 100644
--- a/proton-c/bindings/cpp/src/scalar_test.cpp
+++ b/proton-c/bindings/cpp/src/scalar_test.cpp
@@ -53,13 +53,14 @@ template <class T> void type_test(T x, type_id tid, T y) {
     ASSERT(v2 > s);
 }
 
-#define ASSERT_MISMATCH(EXPR, WANT, GOT)                        \
-    try {                                                       \
-        (void)(EXPR);                                           \
-        FAIL("expected type_error: " #EXPR);                    \
-    } catch (const type_error& e) {                             \
-        ASSERT_EQUAL(WANT, e.want);                             \
-        ASSERT_EQUAL(GOT, e.got);                               \
+#define ASSERT_MISMATCH(EXPR, WANT, GOT)                                \
+    try {                                                               \
+        (void)(EXPR);                                                   \
+        FAIL("expected conversion_error: " #EXPR);                      \
+    } catch (const conversion_error& e) {                               \
+        std::ostringstream want;                                        \
+        want << "unexpected type, want: " << (WANT) << " got: " << (GOT); \
+        ASSERT_EQUAL(want.str(), std::string(e.what()));                \
     }
 
 void convert_test() {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8cbde662/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 6f5b0d9..cc55531 100644
--- a/proton-c/bindings/cpp/src/types.cpp
+++ b/proton-c/bindings/cpp/src/types.cpp
@@ -26,20 +26,6 @@
 
 namespace proton {
 
-namespace {
-
-std::string mismatch_message(type_id want, type_id got, const std::string& msg=std::string()) {
-    std::ostringstream s;
-    s << "want " << want << " got " << got;
-    if (!msg.empty()) s << ": " << msg;
-    return s.str();
-}
-} // namespace
-
-type_error::type_error(type_id want_, type_id got_, const std::string &msg)
-    : decode_error(mismatch_message(want_, got_, msg)), want(want_), got(got_)
-{}
-
 std::string type_name(type_id t) {
     switch (t) {
       case NULL_TYPE: return "null";

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8cbde662/proton-c/bindings/cpp/src/types_internal.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/types_internal.hpp b/proton-c/bindings/cpp/src/types_internal.hpp
index a77168d..a93913a 100644
--- a/proton-c/bindings/cpp/src/types_internal.hpp
+++ b/proton-c/bindings/cpp/src/types_internal.hpp
@@ -20,6 +20,8 @@
  */
 
 #include "proton/type_traits.hpp"
+#include "proton/error.hpp"
+#include <sstream>
 
 ///@file
 /// Internal helpers for encode/decode/type conversion.
@@ -33,6 +35,13 @@ typename enable_if<sizeof(T) == sizeof(U)>::type byte_copy(T &to, const U &from)
     std::copy(p, p + sizeof(T), reinterpret_cast<char*>(&to));
 }
 
+inline conversion_error
+make_conversion_error(type_id want, type_id got, const std::string& msg=std::string()) {
+    std::ostringstream s;
+    s << "unexpected type, want: " << want << " got: " << got;
+    if (!msg.empty()) s << ": " << msg;
+    return conversion_error(s.str());
+}
 
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8cbde662/proton-c/bindings/cpp/src/windows/io.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/windows/io.cpp b/proton-c/bindings/cpp/src/windows/io.cpp
index 1bdccef..52f5fc0 100644
--- a/proton-c/bindings/cpp/src/windows/io.cpp
+++ b/proton-c/bindings/cpp/src/windows/io.cpp
@@ -54,13 +54,13 @@ namespace {
 
 template <class T> T check(T result, const std::string& msg=std::string()) {
     if (result == SOCKET_ERROR)
-        throw io_error(msg + error_str());
+        throw connection_engine::io_error(msg + error_str());
     return result;
 }
 
 void gai_check(int result, const std::string& msg="") {
     if (result)
-        throw io_error(msg + gai_strerror(result));
+        throw connection_engine::io_error(msg + gai_strerror(result));
 }
 } // namespace
 
@@ -98,7 +98,7 @@ std::pair<size_t, bool> socket_engine::io_read(char *buf, size_t size) {
     if (n == 0) return std::make_pair(0, false);
     if (n == SOCKET_ERROR && WSAGetLastError() == WSAEWOULDBLOCK)
         return std::make_pair(0, true);
-    throw io_error("read: " + error_str());
+    throw connection_engine::io_error("read: " + error_str());
 }
 
 size_t socket_engine::io_write(const char *buf, size_t size) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org