qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject [6/6] qpid-proton git commit: PROTON-1138: c++: Remove value_* types, add amqp:: typedefs.
Date Thu, 25 Feb 2016 23:36:40 GMT
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 <aconway@redhat.com>
Authored: Thu Feb 25 17:14:43 2016 -0500
Committer: Alan Conway <aconway@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


Mime
View raw message