You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by jr...@apache.org on 2016/05/17 02:45:02 UTC
[4/4] qpid-proton git commit: PROTON-1200: Improve C++ binding
documentation and header formatting
PROTON-1200: Improve C++ binding documentation and header formatting
- Add lots of documentation
- Eliminate doxygen warnings
- Update pages for correct links and revise the content
- Move codec::* and internal::* classes into corresponding include
directories
- Move AMQP type defines from amqp:: to codec::
- Clearly mark experimental parts of the API as such in the API docs
- Hide some API elements that aren't ready for broader use.
- Make the typed ranges and iterators undocumented (but present)
- Shorten some of the class summaries so that they look nice in the
index
- Style stuff
- Use one pattern throughout for header guards
- Make imports uniform
- Use the Oxford comma, because it's better that way
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/2dc4afe0
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/2dc4afe0
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/2dc4afe0
Branch: refs/heads/master
Commit: 2dc4afe08c091a71df04e9faf61df3bc013d5c6c
Parents: 552f439
Author: Justin Ross <jr...@apache.org>
Authored: Mon May 16 19:44:31 2016 -0700
Committer: Justin Ross <jr...@apache.org>
Committed: Mon May 16 19:44:31 2016 -0700
----------------------------------------------------------------------
examples/cpp/README.dox | 31 +--
examples/cpp/client.cpp | 4 +-
examples/cpp/encode_decode.cpp | 4 +-
proton-c/bindings/cpp/docs/io.md | 21 ++
proton-c/bindings/cpp/docs/main.md | 146 +++++++++++++
proton-c/bindings/cpp/docs/mainpage.md | 138 ------------
proton-c/bindings/cpp/docs/mt.md | 29 +++
proton-c/bindings/cpp/docs/mt_page.md | 23 --
proton-c/bindings/cpp/docs/types.md | 76 +++++++
proton-c/bindings/cpp/include/proton/amqp.hpp | 94 ---------
.../cpp/include/proton/annotation_key.hpp | 51 +++--
proton-c/bindings/cpp/include/proton/binary.hpp | 22 +-
.../bindings/cpp/include/proton/byte_array.hpp | 42 ++--
.../cpp/include/proton/codec/amqp_types.hpp | 106 ++++++++++
.../cpp/include/proton/codec/decoder.hpp | 211 +++++++++++++++++++
.../bindings/cpp/include/proton/codec/deque.hpp | 60 ++++++
.../cpp/include/proton/codec/encoder.hpp | 199 +++++++++++++++++
.../cpp/include/proton/codec/forward_list.hpp | 60 ++++++
.../bindings/cpp/include/proton/codec/list.hpp | 62 ++++++
.../bindings/cpp/include/proton/codec/map.hpp | 44 ++++
.../cpp/include/proton/codec/unordered_map.hpp | 44 ++++
.../cpp/include/proton/codec/vector.hpp | 58 +++++
.../bindings/cpp/include/proton/comparable.hpp | 41 ----
proton-c/bindings/cpp/include/proton/config.hpp | 8 +-
.../bindings/cpp/include/proton/connection.hpp | 49 +++--
.../cpp/include/proton/connection_options.hpp | 47 ++---
.../bindings/cpp/include/proton/container.hpp | 122 ++++++-----
proton-c/bindings/cpp/include/proton/data.hpp | 49 +++--
.../bindings/cpp/include/proton/decimal.hpp | 24 ++-
.../bindings/cpp/include/proton/decoder.hpp | 195 -----------------
.../cpp/include/proton/default_container.hpp | 18 +-
.../bindings/cpp/include/proton/delivery.hpp | 30 +--
.../cpp/include/proton/delivery_mode.hpp | 53 ++---
proton-c/bindings/cpp/include/proton/deque.hpp | 58 -----
.../bindings/cpp/include/proton/duration.hpp | 36 ++--
.../bindings/cpp/include/proton/encoder.hpp | 194 -----------------
.../bindings/cpp/include/proton/endpoint.hpp | 40 ++--
proton-c/bindings/cpp/include/proton/error.hpp | 29 +--
.../cpp/include/proton/error_condition.hpp | 35 +--
.../bindings/cpp/include/proton/event_loop.hpp | 31 ++-
proton-c/bindings/cpp/include/proton/export.hpp | 6 +-
.../cpp/include/proton/forward_list.hpp | 58 -----
.../bindings/cpp/include/proton/handler.hpp | 100 +++++----
.../cpp/include/proton/internal/comparable.hpp | 40 ++++
.../cpp/include/proton/internal/object.hpp | 108 ++++++++++
.../include/proton/internal/pn_unique_ptr.hpp | 68 ++++++
.../cpp/include/proton/internal/scalar_base.hpp | 181 ++++++++++++++++
.../cpp/include/proton/internal/type_traits.hpp | 153 ++++++++++++++
.../cpp/include/proton/io/connection_engine.hpp | 72 +++----
.../include/proton/io/container_impl_base.hpp | 38 +++-
.../cpp/include/proton/io/link_namer.hpp | 19 +-
proton-c/bindings/cpp/include/proton/link.hpp | 61 +++---
proton-c/bindings/cpp/include/proton/list.hpp | 58 -----
.../cpp/include/proton/listen_handler.hpp | 12 +-
.../bindings/cpp/include/proton/listener.hpp | 17 +-
proton-c/bindings/cpp/include/proton/map.hpp | 40 ----
.../bindings/cpp/include/proton/message.hpp | 143 +++++++++----
.../bindings/cpp/include/proton/message_id.hpp | 27 ++-
.../bindings/cpp/include/proton/namespaces.hpp | 44 ++++
proton-c/bindings/cpp/include/proton/object.hpp | 108 ----------
.../cpp/include/proton/pn_unique_ptr.hpp | 67 ------
.../bindings/cpp/include/proton/receiver.hpp | 33 +--
.../cpp/include/proton/receiver_options.hpp | 19 +-
.../cpp/include/proton/reconnect_timer.hpp | 30 +--
proton-c/bindings/cpp/include/proton/sasl.hpp | 11 +-
proton-c/bindings/cpp/include/proton/scalar.hpp | 27 +--
.../bindings/cpp/include/proton/scalar_base.hpp | 177 ----------------
proton-c/bindings/cpp/include/proton/sender.hpp | 40 ++--
.../cpp/include/proton/sender_options.hpp | 14 +-
.../bindings/cpp/include/proton/session.hpp | 57 ++---
.../cpp/include/proton/session_options.hpp | 16 +-
proton-c/bindings/cpp/include/proton/source.hpp | 37 ++--
.../cpp/include/proton/source_options.hpp | 24 +--
proton-c/bindings/cpp/include/proton/ssl.hpp | 39 ++--
proton-c/bindings/cpp/include/proton/symbol.hpp | 23 +-
proton-c/bindings/cpp/include/proton/target.hpp | 19 +-
.../cpp/include/proton/target_options.hpp | 22 +-
proton-c/bindings/cpp/include/proton/task.hpp | 14 +-
.../bindings/cpp/include/proton/terminus.hpp | 39 ++--
.../bindings/cpp/include/proton/thread_safe.hpp | 58 +++--
.../bindings/cpp/include/proton/timestamp.hpp | 39 ++--
.../bindings/cpp/include/proton/tracker.hpp | 21 +-
.../bindings/cpp/include/proton/transfer.hpp | 23 +-
.../bindings/cpp/include/proton/transport.hpp | 12 +-
.../bindings/cpp/include/proton/type_id.hpp | 63 +++---
.../bindings/cpp/include/proton/type_traits.hpp | 153 --------------
proton-c/bindings/cpp/include/proton/types.hpp | 126 +++--------
.../bindings/cpp/include/proton/types_fwd.hpp | 17 +-
.../cpp/include/proton/unordered_map.hpp | 40 ----
proton-c/bindings/cpp/include/proton/url.hpp | 58 +++--
proton-c/bindings/cpp/include/proton/uuid.hpp | 35 +--
proton-c/bindings/cpp/include/proton/value.hpp | 77 ++++---
proton-c/bindings/cpp/include/proton/vector.hpp | 55 -----
proton-c/bindings/cpp/src/acceptor.hpp | 17 +-
proton-c/bindings/cpp/src/data.cpp | 2 +-
proton-c/bindings/cpp/src/decoder.cpp | 2 +-
proton-c/bindings/cpp/src/encoder.cpp | 4 +-
proton-c/bindings/cpp/src/interop_test.cpp | 4 +-
proton-c/bindings/cpp/src/object.cpp | 2 +-
proton-c/bindings/cpp/src/reactor.hpp | 2 +-
proton-c/bindings/cpp/src/scalar_base.cpp | 4 +-
proton-c/bindings/cpp/src/scalar_test.cpp | 2 +-
proton-c/bindings/cpp/src/types_internal.hpp | 2 +-
tests/tools/apps/cpp/reactor_send.cpp | 2 +-
104 files changed, 2974 insertions(+), 2491 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/examples/cpp/README.dox
----------------------------------------------------------------------
diff --git a/examples/cpp/README.dox b/examples/cpp/README.dox
index 97e0619..1b7020b 100644
--- a/examples/cpp/README.dox
+++ b/examples/cpp/README.dox
@@ -102,12 +102,6 @@ alternatives.
*/
-/** @example recurring_timer.cpp
-
-Shows how to implement recurring time-based events using the scheduler.
-
-*/
-
/** @example broker.hpp
Common logic for a simple "mini broker" that creates creates queues
@@ -128,9 +122,10 @@ subscribe.
/** @example mt/epoll_container.cpp
-An example implementation of the proton::container API that shows how to use the
-prton::io::connection_engine SPI to adapt the proton API to native IO. In this
-case using a multi-threaded Linux epoll poller as the implementation.
+An example implementation of the proton::container API that shows how
+to use the proton::io::connection_engine SPI to adapt the proton API
+to native IO, in this case using a multithreaded Linux epoll poller as
+the implementation.
__Requires C++11__
@@ -138,26 +133,10 @@ __Requires C++11__
/** @example mt/broker.cpp
-A multi-threaded broker, using the proton::mt extensions. This broker is
+A multithreaded broker, using the proton::mt extensions. This broker is
portable over any implementation of the proton::mt API, see @ref
mt/epoll_container.cpp for an example.
__Requires C++11__
*/
-
-/** @example mt/simple_send.cpp
-
-A multi-threaded sender client. Sends messages concurrently to multiple addresses.
-
-__Requires C++11__
-
-*/
-
-/** @example mt/simple_recv.cpp
-
-A multi-threaded receiver client. Receives messages concurrently to multiple addresses.
-
-__Requires C++11__
-
-*/
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/examples/cpp/client.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/client.cpp b/examples/cpp/client.cpp
index bf7c7c8..ab6ae12 100644
--- a/examples/cpp/client.cpp
+++ b/examples/cpp/client.cpp
@@ -49,8 +49,8 @@ class client : public proton::handler {
sender = c.open_sender(url);
// Create a receiver requesting a dynamically created queue
// for the message source.
- receiver_options dynamic_addr = receiver_options().source(source_options().dynamic(true));
- receiver = sender.connection().open_receiver("", dynamic_addr);
+ receiver_options opts = receiver_options().source(source_options().dynamic(true));
+ receiver = sender.connection().open_receiver("", opts);
}
void send_request() {
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/examples/cpp/encode_decode.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/encode_decode.cpp b/examples/cpp/encode_decode.cpp
index 832c78a..67fb0fc 100644
--- a/examples/cpp/encode_decode.cpp
+++ b/examples/cpp/encode_decode.cpp
@@ -18,8 +18,8 @@
*/
#include <proton/types.hpp>
-#include <proton/encoder.hpp>
-#include <proton/decoder.hpp>
+#include <proton/codec/encoder.hpp>
+#include <proton/codec/decoder.hpp>
#include <algorithm>
#include <iostream>
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/docs/io.md
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/docs/io.md b/proton-c/bindings/cpp/docs/io.md
new file mode 100644
index 0000000..e6ee386
--- /dev/null
+++ b/proton-c/bindings/cpp/docs/io.md
@@ -0,0 +1,21 @@
+# IO integration {#io_page}
+
+**Experimental**
+
+The proton::io namespace contains a low-level service provider
+interface (SPI) that can be used to implement the proton API over any
+native or third-party IO library.
+
+The proton::io::connection_engine is the core engine that converts raw
+AMQP bytes read from any IO source into proton::messaging_handler
+event calls and generates AMQP byte-encoded output that can be written
+to any IO destination.
+
+Integrations need to implement two user-visible interfaces:
+
+ - proton::container lets the user initiate or listen for connections.
+
+ - proton::event_loop lets the user serialize their own work with a
+ connection.
+
+@see @ref mt/epoll\_container.cpp for an example of an integration.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/docs/main.md
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/docs/main.md b/proton-c/bindings/cpp/docs/main.md
new file mode 100644
index 0000000..3ff00a1
--- /dev/null
+++ b/proton-c/bindings/cpp/docs/main.md
@@ -0,0 +1,146 @@
+# Introduction {#mainpage}
+
+This is the C++ API for the Proton AMQP protocol engine. It allows you
+to write client and server applications that send and receive AMQP
+messages.
+
+The best way to start is with the @ref tutorial.
+
+## An overview of the AMQP model
+
+Messages are transferred between connected peers over *links*. The
+sending end of a link is a `proton::sender`, and the receiving end is
+a `proton::receiver`. Links have named 'source' and 'target'
+addresses. See "Sources and Targets" below for more information.
+
+Links are grouped in a `proton::session`. Messages for links in the
+same session are sent sequentially. Messages on different sessions
+can be interleaved, so a large message being sent on one session does
+not block messages being sent on other sessions.
+
+Sessions are created over a `proton::connection`, which represents the
+network connection. You can create links directly on a connection
+using its default session if you don't need multiple sessions.
+
+`proton::message` represents the message: the body (content), properties,
+headers and annotations. A `proton::delivery` represents the act of transferring
+a message over a link. The receiver acknowledges the delivery by accepting or
+rejecting it. The delivery is *settled* when both ends are done with it.
+Different settlement methods give different levels of reliability:
+*at-most-once*, *at-least-once*, and *exactly-once*. See "Delivery Guarantees"
+below for details.
+
+## Sources and targets
+
+Every link has two addresses, *source* and *target*. The most common
+pattern for using these addresses is as follows:
+
+When a client creates a *receiver* link, it sets the *source*
+address. This means "I want to receive messages from this source."
+This is often referred to as "subscribing" to the source. When a
+client creates a *sender* link, it sets the *target* address. This
+means "I want to send to this target."
+
+In the case of a broker, the source or target usually refers to a
+queue or topic. In general they can refer to any AMQP-capable node.
+
+In the *request-response* pattern, a request message carries a
+*reply-to* address for the response message. This can be any AMQP
+address, but it is often useful to create a temporary address for just
+the response message.
+
+The most common approach is for the client to create a *receiver* for
+the response with the *dynamic* flag set. This asks the server to
+generate a unique *source* address automatically and discard it when
+the link closes. The client uses this "dynamic" source address as the
+reply-to when it sends the request, and the response is delivered to
+the client's dynamic receiver.
+
+In the case of a broker, a dynamic address usually corresponds to a
+temporary queue, but any AMQP request-response server can use this
+technique. The @ref server_direct.cpp example illustrates how to
+implement a queueless request-response server.
+
+## Delivery guarantees
+
+For *at-most-once*, the sender settles the message as soon as it sends
+it. If the connection is lost before the message is received by the
+receiver, the message will not be delivered.
+
+For *at-least-once*, the receiver accepts and settles the message on
+receipt. If the connection is lost before the sender is informed of
+the settlement, then the delivery is considered in-doubt and should be
+retried. This will ensure it eventually gets delivered (provided of
+course the connection and link can be reestablished). It may mean that
+it is delivered multiple times though.
+
+Finally, for *exactly-once*, the receiver accepts the message but
+doesn't settle it. The sender settles once it is aware that the
+receiver accepted it. In this way the receiver retains knowledge of an
+accepted message until it is sure the sender knows it has been
+accepted. If the connection is lost before settlement, the receiver
+informs the sender of all the unsettled deliveries it knows about, and
+from this the sender can deduce which need to be redelivered. The
+sender likewise informs the receiver which deliveries it knows about,
+from which the receiver can deduce which have already been settled.
+
+## Anatomy of a Proton application
+
+To send AMQP commands, call methods on classes like `proton::connection`,
+`proton::sender`, `proton::receiver`, or `proton::delivery`.
+
+To handle incoming commands, subclass the `proton::messaging_handler`
+interface. The handler member functions are called when AMQP protocol
+events occur on a connection. For example
+`proton::messaging_handler::on_message` is called when a message is
+received.
+
+Messages are represented by `proton::message`. AMQP defines a type
+encoding that you can use for interoperability, but you can also use
+any encoding you wish and pass binary data as the
+`proton::message::body`. `proton::value` and `proton::scalar` provide
+conversion between AMQP and C++ data types.
+
+There are several ways to manage handlers and AMQP objects, for
+different types of application. All of them use the same
+`proton::messaging_handler` sub-classes so code can be re-used if you
+change your approach.
+
+### %proton::container - Easy single-threaded applications
+
+`proton::container` is the top level object in a proton application.
+Use proton::connection::connect() and proton::container::listen() to
+create connections. The container polls multiple connections and calls
+protocol events on your `proton::messaging_handler` sub-classes.
+
+<!-- XXX This is wrong?
+The default container implementation is created by
+`proton::new_default_container()`.
+-->
+
+You can implement your own container to integrate proton with
+arbitrary your own container using the
+`proton::io::connection_engine`.
+
+### %proton::io::connection_engine - Integrating with foreign IO
+
+The `proton::io::connection_engine` is different from the other proton
+APIs. You might think of it as more like an SPI (service provider
+interface).
+
+The engine provides a very low-level way of driving a
+`proton::messaging_handler`: You feed raw byte-sequence fragments of
+an AMQP-encoded stream to the engine and it converts that into calls
+on a proton::handler. The engine provides you with outgoing protocol
+stream bytes in return.
+
+The engine is deliberately very simple and low level. It does no IO, no
+thread-related locking, and is written in simple C++98-compatible code.
+
+You can use the engine directly to connect your application to any
+kind of IO framework or library, memory-based streams, or any other
+source or sink for byte-stream data.
+
+You can also use the engine to build a custom implementation of
+`proton::container` so portable proton applications can run without
+modification on your platform.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/docs/mainpage.md
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/docs/mainpage.md b/proton-c/bindings/cpp/docs/mainpage.md
deleted file mode 100644
index 2ba2eaf..0000000
--- a/proton-c/bindings/cpp/docs/mainpage.md
+++ /dev/null
@@ -1,138 +0,0 @@
-# Introduction {#mainpage}
-
-This is the C++ API for the Proton AMQP protocol engine. It allows you
-to write client and server applications that send and receive AMQP
-messages.
-
-The best way to start is with the @ref tutorial
-
-## An overview of the AMQP model
-
-Messages are transferred between connected peers over *links*. The
-sending end of a link is a `proton::sender`, and the receiving end is
-a `proton::receiver`. Links have named 'source' and 'target'
-addresses. See "Sources and Targets" below for more information.
-
-Links are grouped in a `proton::session`. Messages for links in the
-same session are sent sequentially. Messages on different sessions
-can be interleaved, so a large message being sent on one session does
-not block messages being sent on other sessions.
-
-Sessions are created over a `proton::connection`, which represents the
-network connection. You can create links directly on a connection
-using its default session if you don't need multiple sessions.
-
-`proton::message` represents the message: the body (content), properties,
-headers and annotations. A `proton::delivery` represents the act of transferring
-a message over a link. The receiver acknowledges the delivery by accepting or
-rejecting it. The delivery is *settled* when both ends are done with it.
-Different settlement methods give different levels of reliability:
-*at-most-once*, *at-least-once*, and *exactly-once*. See "Delivery Guarantees"
-below for details.
-
-## Sources and targets
-
-Every link has two addresses, *source* and *target*. The most common
-pattern for using these addresses is as follows:
-
-When a client creates a *receiver* link, it sets the *source*
-address. This means "I want to receive messages from this source."
-This is often referred to as "subscribing" to the source. When a
-client creates a *sender* link, it sets the *target* address. This
-means "I want to send to this target."
-
-In the case of a broker, the source or target usually refers to a
-queue or topic. In general they can refer to any AMQP-capable node.
-
-In the *request-response* pattern, a request message carries a
-*reply-to* address for the response message. This can be any AMQP
-address, but it is often useful to create a temporary address for just
-the response message.
-
-The most common approach is for the client to create a *receiver* for
-the response with the *dynamic* flag set. This asks the server to
-generate a unique *source* address automatically and discard it when
-the link closes. The client uses this "dynamic" source address as the
-reply-to when it sends the request, and the response is delivered to
-the client's dynamic receiver.
-
-In the case of a broker, a dynamic address usually corresponds to a
-temporary queue, but any AMQP request-response server can use this
-technique. The @ref server_direct.cpp example illustrates how to
-implement a queueless request-response server.
-
-## Delivery guarantees
-
-For *at-most-once*, the sender settles the message as soon as it sends
-it. If the connection is lost before the message is received by the
-receiver, the message will not be delivered.
-
-For *at-least-once*, the receiver accepts and settles the message on
-receipt. If the connection is lost before the sender is informed of
-the settlement, then the delivery is considered in-doubt and should be
-retried. This will ensure it eventually gets delivered (provided of
-course the connection and link can be reestablished). It may mean that
-it is delivered multiple times though.
-
-Finally, for *exactly-once*, the receiver accepts the message but
-doesn't settle it. The sender settles once it is aware that the
-receiver accepted it. In this way the receiver retains knowledge of an
-accepted message until it is sure the sender knows it has been
-accepted. If the connection is lost before settlement, the receiver
-informs the sender of all the unsettled deliveries it knows about, and
-from this the sender can deduce which need to be redelivered. The
-sender likewise informs the receiver which deliveries it knows about,
-from which the receiver can deduce which have already been settled.
-
-## Anatomy of a Proton application
-
-To send AMQP commands, call methods on classes like `proton::connection`,
-`proton::sender`, `proton::receiver`, or `proton::delivery`.
-
-To handle incoming commands, subclass the `proton::handler` interface. The
-handler member functions are called when AMQP protocol events occur on a
-connection. For example `proton::handler::on_message` is called when a message
-is received.
-
-Messages are represented by `proton::message`. AMQP defines a type
-encoding that you can use for interoperability, but you can also use
-any encoding you wish and pass binary data as the
-`proton::message::body`. `proton::value` and `proton::scalar` provide
-conversion between AMQP and C++ data types.
-
-There are several ways to manage handlers and AMQP objects, for different types
-of application. All of them use the same `proton::handler` sub-classes so code
-can be re-used if you change your approach.
-
-### %proton::container - easy single-threaded applications
-
-`proton::container` is the top level object in a proton application. Use
-proton::connection::connect() and proton::container::listen() to create
-connections. The container polls multiple connections and calls protocol events
-on your `proton::handler` sub-classes.
-
-The default container implementation is created by `proton::new_default_container()`.
-
-You can implement your own container to integrate proton with arbitrary your own
-container using the proton::io::connection_engine.
-
-### %proton::io::connection_engine - integrating with foreign IO
-
-The `proton::io::connection_engine` is different from the other proton APIs. You
-might think of it as more like an SPI (Service Provided Interface).
-
-The engine provides a very low-level way of driving a proton::handler: You feed
-raw byte-sequence fragments of an AMQP-encoded stream to the engine and it
-converts that into calls on a proton::handler. The engine provides you with
-outgoing protocol stream bytes in return.
-
-The engine is deliberately very simple and low level. It does no IO, no
-thread-related locking, and is written in simple C++98 compatible code.
-
-You can use the engine directly to connect your application to any kind of IO
-framework or library, memory-based streams or any other source/sink for byte
-stream data.
-
-You can also use the engine to build a custom implementation of
-proton::container and so portable proton applications can run without
-modification on your platform.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/docs/mt.md
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/docs/mt.md b/proton-c/bindings/cpp/docs/mt.md
new file mode 100644
index 0000000..73239e5
--- /dev/null
+++ b/proton-c/bindings/cpp/docs/mt.md
@@ -0,0 +1,29 @@
+# Multithreaded Proton {#mt_page}
+
+**Experimental**
+
+<!-- FIXME aconway 2016-05-04: doc -->
+
+Most classes in namespace @ref proton are not thread-safe. Objects
+associated with a single connection *must not* be used
+concurrently. However, objects associated with *different* connections
+*can* be used concurrently in separate threads.
+
+The recommended way to use proton multithreaded is to *serialize* the
+work for each connection but allow different connections to be
+processed concurrently.
+
+proton::container allows you to manage connections in a multithreaded
+way. You supply a proton::messaging_handler for each
+connection. Proton will ensure that the
+`proton::messaging_handler::on_*()` functions are never called
+concurrently so per-connection handlers do not need a lock even if
+they have state.
+
+proton::event_loop allows you to make calls to arbitrary functions or
+other code, serialized in the same way as
+`proton::messaging_handler::on_*()` calls. Typically this is used to
+call your own handler's member functions in the same way as
+proton::messaging_handler override functions.
+
+For an example see @ref mt/broker.cpp.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/docs/mt_page.md
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/docs/mt_page.md b/proton-c/bindings/cpp/docs/mt_page.md
deleted file mode 100644
index a1ac849..0000000
--- a/proton-c/bindings/cpp/docs/mt_page.md
+++ /dev/null
@@ -1,23 +0,0 @@
-# Multi-threaded proton {#mt_page}
-
-<!-- FIXME aconway 2016-05-04: doc -->
-
-Most classes in namespace @ref proton are not thread-safe. Objects associated
-with a single connection *must not* be used concurrently. However objects
-associated with *different* connections *can* be used concurrently in separate
-threads.
-
-The recommended way to use proton multi-threaded is to *serialize* the work for
-each connection but allow different connections to be processed concurrently.
-
-proton::container allows you to manage connections in a multi-threaded way. You
-supply a proton::handler for each connection. Proton will ensure that the
-`proton::handler::on_*()` functions are never called concurrently so
-per-connection handlers do not need a lock even if they have state.
-
-proton::work_queue allows you to make calls to arbitrary functions or other
-code, serialized in the same way as `proton::handler::on_()` calls. Typically
-this is used to call your own handler's member functions in the same way as
-proton::handler override functions.
-
-For examples see @ref mt/broker.cpp, mt/simple\_send.cpp and mt/simple\_recv.cpp
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/docs/types.md
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/docs/types.md b/proton-c/bindings/cpp/docs/types.md
new file mode 100644
index 0000000..7a643bc
--- /dev/null
+++ b/proton-c/bindings/cpp/docs/types.md
@@ -0,0 +1,76 @@
+# AMQP and C++ types {#types_page}
+
+An AMQP message body can hold binary data using any encoding you
+like. AMQP also defines its own encoding and types. The AMQP encoding
+is often used in message bodies because it is supported by AMQP
+libraries on many languages and platforms. You also need to use the
+AMQP types to set and examine message properties.
+
+## Scalar types
+
+Each type is identified by a proton::type_id.
+
+C++ type | AMQP type_id | Description
+--------------------|----------------------|-----------------------
+bool | proton::BOOLEAN | Boolean true or false
+uint8_t | proton::UBYTE | 8-bit unsigned byte
+int8_t | proton::BYTE | 8-bit signed byte
+uint16_t | proton::USHORT | 16-bit unsigned integer
+int16_t | proton::SHORT | 16-bit signed integer
+uint32_t | proton::UINT | 32-bit unsigned integer
+int32_t | proton::INT | 32-bit signed integer
+uint64_t | proton::ULONG | 64-bit unsigned integer
+int64_t | proton::LONG | 64-bit signed integer
+wchar_t | proton::CHAR | 32-bit unicode code point
+float | proton::FLOAT | 32-bit binary floating point
+double | proton::DOUBLE | 64-bit binary floating point
+proton::timestamp | proton::TIMESTAMP | 64-bit signed milliseconds since 00:00:00 (UTC), 1 January 1970.
+proton::decimal32 | proton::DECIMAL32 | 32-bit decimal floating point
+proton::decimal64 | proton::DECIMAL64 | 64-bit decimal floating point
+proton::decimal128 | proton::DECIMAL128 | 128-bit decimal floating point
+proton::uuid | proton::UUID | 128-bit universally-unique identifier
+std::string | proton::STRING | UTF-8 encoded unicode string
+proton::symbol | proton::SYMBOL | 7-bit ASCII encoded string
+proton::binary | proton::BINARY | Variable-length binary data
+
+proton::scalar is a holder that can hold a scalar value of any type.
+
+## Compound types
+
+C++ type | AMQP type_id | Description
+--------------------|----------------------|-----------------------
+See below | proton::ARRAY | Sequence of values of the same type
+See below | proton::LIST | Sequence of values of mixed types
+See below | proton::MAP | Map of key-value pairs
+
+proton::value is a holder that can hold any AMQP value, scalar, or
+compound.
+
+proton::ARRAY converts to and from C++ sequences: std::vector,
+std::deque, std::list, and std::forward_list.
+
+proton::LIST converts to and from sequences of proton::value or
+proton::scalar, which can hold mixed types of data.
+
+proton::MAP converts to and from std::map, std::unordered_map, and
+sequences of std::pair.
+
+When decoding, the encoded map types must be convertible to the element type of the
+C++ sequence or the key-value types of the C++ map. Use proton::value as the
+element or key-value type to decode any ARRAY, LIST, or MAP.
+
+For example you can decode any AMQP MAP into:
+
+ std::map<proton::value, proton::value>
+
+You can decode any AMQP LIST or ARRAY into:
+
+ std::vector<proton::value>
+
+## Include files
+
+You can simply include proton/types.hpp to include all the type definitions and
+conversions. Alternatively, you can selectively include only what you need:
+
+ - Include proton/types_fwd.hpp: forward declarations for all types.
+ - Include individual `.hpp` files as per the table above.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/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
deleted file mode 100644
index 990bf06..0000000
--- a/proton-c/bindings/cpp/include/proton/amqp.hpp
+++ /dev/null
@@ -1,94 +0,0 @@
-#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_fwd.hpp>
-
-#include <string>
-
-namespace proton {
-
-/// AMQP typedefs for C++ types
-///
-/// 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;
-
-/// 32 bit decimal floating point
-typedef proton::decimal32 decimal32_type;
-
-/// 64 bit decimal floating point
-typedef proton::decimal64 decimal64_type;
-
-/// 128 bit decimal floating point
-typedef proton::decimal128 decimal128_type;
-
-}}
-
-#endif // PROTON_AMQP_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/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 042e95d..e63db3c 100644
--- a/proton-c/bindings/cpp/include/proton/annotation_key.hpp
+++ b/proton-c/bindings/cpp/include/proton/annotation_key.hpp
@@ -1,7 +1,8 @@
-#ifndef ANNOTATION_KEY_HPP
-#define ANNOTATION_KEY_HPP
+#ifndef PROTON_ANNOTATION_KEY_HPP
+#define PROTON_ANNOTATION_KEY_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
@@ -18,10 +19,11 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
+ *
*/
-#include <proton/scalar_base.hpp>
-#include <proton/symbol.hpp>
+#include "proton/internal/scalar_base.hpp"
+#include "proton/symbol.hpp"
namespace proton {
@@ -35,39 +37,48 @@ class annotation_key : public internal::scalar_base {
/// An empty annotation key has a uint64_t == 0 value.
annotation_key() { put_(uint64_t(0)); }
- /// Construct from any type that can be assigned
+ /// Construct from any type that can be assigned.
template <class T> annotation_key(const T& x) { *this = x; }
- ///@name Assign from a uint64_t or symbol.
- ///@{
+ /// @name Assign from a uint64_t or symbol.
+ /// @{
annotation_key& operator=(uint64_t x) { put_(x); return *this; }
annotation_key& operator=(const symbol& x) { put_(x); return *this; }
- ///@}
- ///@name Extra conversions for strings, treated as amqp::SYMBOL.
- ///@{
+ /// @}
+
+ /// @name Extra conversions for strings, treated as codec::SYMBOL.
+ /// @{
annotation_key& operator=(const std::string& x) { put_(symbol(x)); return *this; }
annotation_key& operator=(const char *x) { put_(symbol(x)); return *this; }
- ///@}
+ /// @}
- ///@cond INTERNAL
+ /// @cond INTERNAL
friend class message;
friend class codec::decoder;
- ///@endcond
+ /// @endcond
};
-///@cond internal
+/// @cond INTERNAL
+/// XXX Document this?
template <class T> T get(const annotation_key& x);
-///@endcond
+/// @endcond
-/// Get the uint64_t value or throw conversion_error. @related annotation_key
+/// Get the uint64_t value or throw conversion_error.
+///
+/// @related annotation_key
template<> inline uint64_t get<uint64_t>(const annotation_key& x) { return internal::get<uint64_t>(x); }
-/// Get the @ref symbol value or throw conversion_error. @related annotation_key
+
+/// Get the @ref symbol value or throw conversion_error.
+///
+/// @related annotation_key
template<> inline symbol get<symbol>(const annotation_key& x) { return internal::get<symbol>(x); }
-/// Get the @ref binary value or throw conversion_error. @related annotation_key
+/// Get the @ref binary value or throw conversion_error.
+///
/// @copydoc scalar::coerce
/// @related annotation_key
template<class T> T coerce(const annotation_key& x) { return internal::coerce<T>(x); }
-}
-#endif // ANNOTATION_KEY_HPP
+} // proton
+
+#endif // PROTON_ANNOTATION_KEY_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/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
index a72ac75..40969f4 100644
--- a/proton-c/bindings/cpp/include/proton/binary.hpp
+++ b/proton-c/bindings/cpp/include/proton/binary.hpp
@@ -1,6 +1,8 @@
-#ifndef BINARY_HPP
-#define BINARY_HPP
+#ifndef PROTON_BINARY_HPP
+#define PROTON_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
@@ -17,10 +19,11 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
+ *
*/
-#include <proton/export.hpp>
-#include <proton/types_fwd.hpp>
+#include "proton/export.hpp"
+#include "proton/types_fwd.hpp"
#include <iosfwd>
#include <vector>
@@ -30,13 +33,14 @@ namespace proton {
/// Arbitrary binary data.
class binary : public std::vector<uint8_t> {
public:
- ///@name Constructors @{
+ /// @name Constructors
+ /// @{
explicit binary() : std::vector<value_type>() {}
explicit binary(size_t n) : std::vector<value_type>(n) {}
explicit binary(size_t n, value_type x) : std::vector<value_type>(n, x) {}
explicit binary(const std::string& s) : std::vector<value_type>(s.begin(), s.end()) {}
template <class Iter> binary(Iter first, Iter last) : std::vector<value_type>(first, last) {}
- ///@}
+ /// @}
/// Convert to std::string
operator std::string() const { return std::string(begin(), end()); }
@@ -45,9 +49,9 @@ class binary : public std::vector<uint8_t> {
binary& operator=(const std::string& x) { assign(x.begin(), x.end()); return *this; }
};
-/// Print binary value
+/// Print a binary value
PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const binary&);
-}
+} // proton
-#endif // BINARY_HPP
+#endif // PROTON_BINARY_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/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 e5c5dbf..2fd638d 100644
--- a/proton-c/bindings/cpp/include/proton/byte_array.hpp
+++ b/proton-c/bindings/cpp/include/proton/byte_array.hpp
@@ -1,5 +1,6 @@
-#ifndef BYTE_ARRAY_HPP
-#define BYTE_ARRAY_HPP
+#ifndef PROTON_BYTE_ARRAY_HPP
+#define PROTON_BYTE_ARRAY_HPP
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -20,23 +21,26 @@
*/
#include "proton/export.hpp"
-#include <proton/types_fwd.hpp>
-#include <proton/comparable.hpp>
+#include "proton/internal/comparable.hpp"
+#include "proton/types_fwd.hpp"
#include <algorithm>
#include <iterator>
namespace proton {
+
namespace internal {
PN_CPP_EXTERN void print_hex(std::ostream& o, const uint8_t* p, size_t n);
}
-/// Used to represent fixed-sized data types that don't have a natural C++ representation
-/// as an array of bytes.
+/// Arbitrary fixed-size data.
+///
+/// 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 : private internal::comparable<byte_array<N> > {
public:
- ///@name Sequence container typedefs
- ///@{
+ /// @name Sequence container typedefs
+ /// @{
typedef uint8_t value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
@@ -48,16 +52,16 @@ template <size_t N> class byte_array : private internal::comparable<byte_array<N
typedef std::ptrdiff_t difference_type;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
- ///@}
+ /// @}
- /// 0-initialized byte array
+ /// Zero-initialized byte array
byte_array() { std::fill(bytes_, bytes_+N, '\0'); }
/// Size of the array
static size_t size() { return N; }
- ///@name Array operators
- ///@{
+ /// @name Array operators
+ /// @{
value_type* begin() { return bytes_; }
value_type* end() { return bytes_+N; }
value_type& operator[](size_t i) { return bytes_[i]; }
@@ -65,10 +69,10 @@ template <size_t N> class byte_array : private internal::comparable<byte_array<N
const value_type* begin() const { return bytes_; }
const value_type* end() const { return bytes_+N; }
const value_type& operator[](size_t i) const { return bytes_[i]; }
- ///@}
+ /// @}
- ///@name Comparison operators
- ///@{
+ /// @name Comparison operators
+ /// @{
friend bool operator==(const byte_array& x, const byte_array& y) {
return std::equal(x.begin(), x.end(), y.begin());
}
@@ -76,9 +80,9 @@ template <size_t N> class byte_array : private internal::comparable<byte_array<N
friend bool operator<(const byte_array& x, const byte_array& y) {
return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
}
- ///@}
+ /// @}
- /// Print byte array in hex.
+ /// Print byte array in hex
friend std::ostream& operator<<(std::ostream& o, const byte_array& b) {
internal::print_hex(o, b.begin(), b.size());
return o;
@@ -88,6 +92,6 @@ template <size_t N> class byte_array : private internal::comparable<byte_array<N
value_type bytes_[N];
};
-}
+} // proton
-#endif // BYTE_ARRAY_HPP
+#endif // PROTON_BYTE_ARRAY_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/codec/amqp_types.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/codec/amqp_types.hpp b/proton-c/bindings/cpp/include/proton/codec/amqp_types.hpp
new file mode 100644
index 0000000..b245690
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/codec/amqp_types.hpp
@@ -0,0 +1,106 @@
+#ifndef PROTON_CODEC_AMQP_TYPES_HPP
+#define PROTON_CODEC_AMQP_TYPES_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 {
+namespace codec {
+
+/// @name Experimental - Typedefs for AMQP scalar types.
+///
+/// These typedefs associate AMQP scalar type names with the
+/// corresponding C++ types. They are provided as a convenience for
+/// those familiar with AMQP, but 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.
+///
+/// @{
+
+// XXX Consider prefixing these with amqp_ and dropping _type, now
+// that they're in the codec namespace
+
+/// 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 symbol 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;
+
+/// 32-bit decimal floating point
+typedef proton::decimal32 decimal32_type;
+
+/// 64-bit decimal floating point
+typedef proton::decimal64 decimal64_type;
+
+/// 128-bit decimal floating point
+typedef proton::decimal128 decimal128_type;
+
+} // codec
+} // proton
+
+#endif // PROTON_CODEC_AMQP_TYPES_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/codec/decoder.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/codec/decoder.hpp b/proton-c/bindings/cpp/include/proton/codec/decoder.hpp
new file mode 100644
index 0000000..7904982
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/codec/decoder.hpp
@@ -0,0 +1,211 @@
+#ifndef PROTON_CODEC_DECODER_HPP
+#define PROTON_CODEC_DECODER_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/data.hpp"
+#include "proton/internal/type_traits.hpp"
+#include "proton/types_fwd.hpp"
+
+#include <utility>
+
+namespace proton {
+
+class annotation_key;
+class message_id;
+class scalar;
+class value;
+
+namespace internal {
+class value_base;
+}
+
+namespace codec {
+
+/// **Experimental** - Stream-like decoder from AMQP bytes to C++
+/// values.
+///
+/// For internal use only.
+///
+/// @see @ref types_page for the recommended ways to manage AMQP data
+class decoder : public data {
+ public:
+ /// Wrap a Proton C data object. The exact flag if set means
+ /// decode only when there is an exact match between the AMQP and
+ /// C++ type. If not set then perform automatic conversions.
+ explicit decoder(const data& d, bool exact=false) : data(d), exact_(exact) {}
+
+ /// Attach decoder to a proton::value. The decoder is rewound to
+ /// the start of the data.
+ PN_CPP_EXTERN explicit decoder(const internal::value_base&, bool exact=false);
+
+ /// Decode AMQP data from a buffer and add it to the end of the
+ /// decoders stream.
+ PN_CPP_EXTERN void decode(const char* buffer, size_t size);
+
+ /// Decode AMQP data from a std::string and add it to the end of
+ /// the decoders stream.
+ PN_CPP_EXTERN void decode(const std::string&);
+
+ /// Return true if there are more value to extract at the current level.
+ PN_CPP_EXTERN bool more();
+
+ /// Get the type of the next value that will be read by
+ /// operator>>.
+ ///
+ /// @throw conversion_error if no more values. @see
+ /// decoder::more().
+ PN_CPP_EXTERN type_id next_type();
+
+ /// @name Extract built-in types
+ ///
+ /// @throw conversion_error if the decoder is empty or has an
+ /// incompatible type.
+ ///
+ /// @{
+ PN_CPP_EXTERN decoder& operator>>(bool&);
+ PN_CPP_EXTERN decoder& operator>>(uint8_t&);
+ PN_CPP_EXTERN decoder& operator>>(int8_t&);
+ PN_CPP_EXTERN decoder& operator>>(uint16_t&);
+ PN_CPP_EXTERN decoder& operator>>(int16_t&);
+ PN_CPP_EXTERN decoder& operator>>(uint32_t&);
+ PN_CPP_EXTERN decoder& operator>>(int32_t&);
+ PN_CPP_EXTERN decoder& operator>>(wchar_t&);
+ PN_CPP_EXTERN decoder& operator>>(uint64_t&);
+ PN_CPP_EXTERN decoder& operator>>(int64_t&);
+ PN_CPP_EXTERN decoder& operator>>(timestamp&);
+ PN_CPP_EXTERN decoder& operator>>(float&);
+ PN_CPP_EXTERN decoder& operator>>(double&);
+ PN_CPP_EXTERN decoder& operator>>(decimal32&);
+ PN_CPP_EXTERN decoder& operator>>(decimal64&);
+ PN_CPP_EXTERN decoder& operator>>(decimal128&);
+ PN_CPP_EXTERN decoder& operator>>(uuid&);
+ PN_CPP_EXTERN decoder& operator>>(std::string&);
+ PN_CPP_EXTERN decoder& operator>>(symbol&);
+ PN_CPP_EXTERN decoder& operator>>(binary&);
+ PN_CPP_EXTERN decoder& operator>>(message_id&);
+ PN_CPP_EXTERN decoder& operator>>(annotation_key&);
+ PN_CPP_EXTERN decoder& operator>>(scalar&);
+ PN_CPP_EXTERN decoder& operator>>(internal::value_base&);
+ PN_CPP_EXTERN decoder& operator>>(null&);
+ ///@}
+
+ /// Start decoding a container type, such as an ARRAY, LIST or
+ /// MAP. This "enters" the container, more() will return false at
+ /// the end of the container. Call finish() to "exit" the
+ /// container and move on to the next value.
+ PN_CPP_EXTERN decoder& operator>>(start&);
+
+ /// Finish decoding a container type, and move on to the next
+ /// value in the stream.
+ PN_CPP_EXTERN decoder& operator>>(const finish&);
+
+ /// @cond INTERNAL
+ template <class T> struct sequence_ref { T& ref; sequence_ref(T& r) : ref(r) {} };
+ template <class T> struct associative_ref { T& ref; associative_ref(T& r) : ref(r) {} };
+ template <class T> struct pair_sequence_ref { T& ref; pair_sequence_ref(T& r) : ref(r) {} };
+
+ template <class T> static sequence_ref<T> sequence(T& x) { return sequence_ref<T>(x); }
+ template <class T> static associative_ref<T> associative(T& x) { return associative_ref<T>(x); }
+ template <class T> static pair_sequence_ref<T> pair_sequence(T& x) { return pair_sequence_ref<T>(x); }
+ /// @endcond
+
+ /// Extract any AMQP sequence (ARRAY, LIST or MAP) to a C++
+ /// sequence container of T if the elements types are convertible
+ /// to T. A MAP is extracted as `[key1, value1, key2, value2...]`.
+ template <class T> decoder& operator>>(sequence_ref<T> r) {
+ start s;
+ *this >> s;
+ if (s.is_described) next();
+ r.ref.resize(s.size);
+ for (typename T::iterator i = r.ref.begin(); i != r.ref.end(); ++i)
+ *this >> *i;
+ return *this;
+ }
+
+ /// Extract an AMQP MAP to a C++ associative container
+ template <class T> decoder& operator>>(associative_ref<T> r) {
+ using namespace internal;
+ start s;
+ *this >> s;
+ assert_type_equal(MAP, s.type);
+ r.ref.clear();
+ for (size_t i = 0; i < s.size/2; ++i) {
+ typename remove_const<typename T::key_type>::type k;
+ typename remove_const<typename T::mapped_type>::type v;
+ *this >> k >> v;
+ r.ref[k] = v;
+ }
+ return *this;
+ }
+
+ /// Extract an AMQP MAP to a C++ push_back sequence of pairs
+ /// preserving encoded order.
+ template <class T> decoder& operator>>(pair_sequence_ref<T> r) {
+ using namespace internal;
+ start s;
+ *this >> s;
+ assert_type_equal(MAP, s.type);
+ r.ref.clear();
+ for (size_t i = 0; i < s.size/2; ++i) {
+ typedef typename T::value_type value_type;
+ typename remove_const<typename value_type::first_type>::type k;
+ typename remove_const<typename value_type::second_type>::type v;
+ *this >> k >> v;
+ r.ref.push_back(value_type(k, v));
+ }
+ return *this;
+ }
+
+ private:
+ type_id pre_get();
+ template <class T, class U> decoder& extract(T& x, U (*get)(pn_data_t*));
+ bool exact_;
+
+ friend class message;
+};
+
+/// @cond INTERNAL
+/// XXX Document this
+template<class T> T get(decoder& d) {
+ assert_type_equal(internal::type_id_of<T>::value, d.next_type());
+ T x;
+ d >> x;
+ return x;
+}
+/// @endcond
+
+/// operator>> for integer types that are not covered by the standard
+/// overrides.
+template <class T> typename internal::enable_if<internal::is_unknown_integer<T>::value, decoder&>::type
+operator>>(decoder& d, T& i) {
+ using namespace internal;
+ typename integer_type<sizeof(T), is_signed<T>::value>::type v;
+ d >> v; // Extract as a known integer type
+ i = v; // C++ conversion to the target type.
+ return d;
+}
+
+} // codec
+} // proton
+
+#endif // PROTON_CODEC_DECODER_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/codec/deque.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/codec/deque.hpp b/proton-c/bindings/cpp/include/proton/codec/deque.hpp
new file mode 100644
index 0000000..2b64b0d
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/codec/deque.hpp
@@ -0,0 +1,60 @@
+#ifndef PROTON_CODEC_DEQUE_HPP
+#define PROTON_CODEC_DEQUE_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/codec/encoder.hpp"
+#include "proton/codec/decoder.hpp"
+
+#include <deque>
+#include <utility>
+
+namespace proton {
+namespace codec {
+
+/// std::deque<T> for most T is encoded as an amqp::ARRAY (same type elements)
+template <class T, class A>
+encoder& operator<<(encoder& e, const std::deque<T, A>& x) {
+ return e << encoder::array(x, internal::type_id_of<T>::value);
+}
+
+/// std::deque<value> encodes as codec::list_type (mixed type elements)
+template <class A>
+encoder& operator<<(encoder& e, const std::deque<value, A>& x) { return e << encoder::list(x); }
+
+/// std::deque<scalar> encodes as codec::list_type (mixed type elements)
+template <class A>
+encoder& operator<<(encoder& e, const std::deque<scalar, A>& x) { return e << encoder::list(x); }
+
+/// std::deque<std::pair<k,t> > encodes as codec::map_type.
+/// Map entries are encoded in order they appear in the list.
+template <class A, class K, class T>
+encoder& operator<<(encoder& e, const std::deque<std::pair<K,T>, A>& x) { return e << encoder::map(x); }
+
+/// Decode to std::deque<T> from an amqp::LIST or amqp::ARRAY.
+template <class T, class A> decoder& operator>>(decoder& d, std::deque<T, A>& x) { return d >> decoder::sequence(x); }
+
+/// Decode to std::deque<std::pair<K, T> from an amqp::MAP.
+template <class A, class K, class T> decoder& operator>>(decoder& d, std::deque<std::pair<K, T> , A>& x) { return d >> decoder::pair_sequence(x); }
+
+} // codec
+} // proton
+
+#endif // PROTON_CODEC_DEQUE_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/codec/encoder.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/codec/encoder.hpp b/proton-c/bindings/cpp/include/proton/codec/encoder.hpp
new file mode 100644
index 0000000..e174c73
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/codec/encoder.hpp
@@ -0,0 +1,199 @@
+#ifndef PROTON_CODEC_ENCODER_HPP
+#define PROTON_CODEC_ENCODER_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/data.hpp"
+#include "proton/internal/type_traits.hpp"
+#include "proton/types_fwd.hpp"
+
+namespace proton {
+
+namespace internal{
+class scalar_base;
+class value_base;
+}
+
+namespace codec {
+
+/// **Experimental** - Stream-like encoder from AMQP bytes to C++
+/// values.
+///
+/// For internal use only.
+///
+/// @see @ref types_page for the recommended ways to manage AMQP data
+class encoder : public data {
+ public:
+ /// Wrap Proton-C data object.
+ explicit encoder(const data& d) : data(d) {}
+
+ /// Encoder into v. Clears any current value in v.
+ PN_CPP_EXTERN explicit encoder(internal::value_base& v);
+
+ /// Encode the current values into buffer and update size to reflect the
+ /// number of bytes encoded.
+ ///
+ /// Clears the encoder.
+ ///
+ /// @return if buffer == 0 or size is too small, then return false
+ /// and size to the required size. Otherwise, return true and set
+ /// size to the number of bytes encoded.
+ PN_CPP_EXTERN bool encode(char* buffer, size_t& size);
+
+ /// Encode the current values into a std::string and resize the
+ /// string if necessary. Clears the encoder.
+ PN_CPP_EXTERN void encode(std::string&);
+
+ /// Encode the current values into a std::string. Clears the
+ /// encoder.
+ PN_CPP_EXTERN std::string encode();
+
+ /// @name Insert built-in types
+ /// @{
+ PN_CPP_EXTERN encoder& operator<<(bool);
+ PN_CPP_EXTERN encoder& operator<<(uint8_t);
+ PN_CPP_EXTERN encoder& operator<<(int8_t);
+ PN_CPP_EXTERN encoder& operator<<(uint16_t);
+ PN_CPP_EXTERN encoder& operator<<(int16_t);
+ PN_CPP_EXTERN encoder& operator<<(uint32_t);
+ PN_CPP_EXTERN encoder& operator<<(int32_t);
+ PN_CPP_EXTERN encoder& operator<<(wchar_t);
+ PN_CPP_EXTERN encoder& operator<<(uint64_t);
+ PN_CPP_EXTERN encoder& operator<<(int64_t);
+ PN_CPP_EXTERN encoder& operator<<(timestamp);
+ PN_CPP_EXTERN encoder& operator<<(float);
+ PN_CPP_EXTERN encoder& operator<<(double);
+ PN_CPP_EXTERN encoder& operator<<(decimal32);
+ PN_CPP_EXTERN encoder& operator<<(decimal64);
+ PN_CPP_EXTERN encoder& operator<<(decimal128);
+ PN_CPP_EXTERN encoder& operator<<(const uuid&);
+ PN_CPP_EXTERN encoder& operator<<(const std::string&);
+ PN_CPP_EXTERN encoder& operator<<(const symbol&);
+ PN_CPP_EXTERN encoder& operator<<(const binary&);
+ PN_CPP_EXTERN encoder& operator<<(const internal::scalar_base&);
+ PN_CPP_EXTERN encoder& operator<<(const null&);
+ /// @}
+
+ /// Insert a proton::value.
+ ///
+ /// @internal NOTE insert value_base, not value to avoid recursive
+ /// implicit conversions.
+ PN_CPP_EXTERN encoder& operator<<(const internal::value_base&);
+
+ /// Start a complex type
+ PN_CPP_EXTERN encoder& operator<<(const start&);
+
+ /// Finish a complex type
+ PN_CPP_EXTERN encoder& operator<<(const finish&);
+
+ /// @cond INTERNAL
+
+ // Undefined template to prevent pointers being implicitly converted to bool.
+ template <class T> void* operator<<(const T*);
+
+ template <class T> struct list_cref { T& ref; list_cref(T& r) : ref(r) {} };
+ template <class T> struct map_cref { T& ref; map_cref(T& r) : ref(r) {} };
+
+ template <class T> struct array_cref {
+ start array_start;
+ T& ref;
+ array_cref(T& r, type_id el, bool described) : array_start(ARRAY, el, described), ref(r) {}
+ };
+
+ template <class T> static list_cref<T> list(T& x) { return list_cref<T>(x); }
+ template <class T> static map_cref<T> map(T& x) { return map_cref<T>(x); }
+ template <class T> static array_cref<T> array(T& x, type_id element, bool described=false) {
+ return array_cref<T>(x, element, described);
+ }
+
+ template <class T> encoder& operator<<(const map_cref<T>& x) {
+ state_guard sg(*this);
+ *this << start::map();
+ for (typename T::const_iterator i = x.ref.begin(); i != x.ref.end(); ++i)
+ *this << i->first << i->second;
+ *this << finish();
+ return *this;
+ }
+
+ template <class T> encoder& operator<<(const list_cref<T>& x) {
+ state_guard sg(*this);
+ *this << start::list();
+ for (typename T::const_iterator i = x.ref.begin(); i != x.ref.end(); ++i)
+ *this << *i;
+ *this << finish();
+ return *this;
+ }
+
+ template <class T> encoder& operator<<(const array_cref<T>& x) {
+ state_guard sg(*this);
+ *this << x.array_start;
+ for (typename T::const_iterator i = x.ref.begin(); i != x.ref.end(); ++i)
+ *this << *i;
+ *this << finish();
+ return *this;
+ }
+ /// @endcond
+
+ private:
+ template<class T, class U> encoder& insert(const T& x, int (*put)(pn_data_t*, U));
+ void check(long result);
+};
+
+/// Treat char* as string
+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> typename internal::enable_if<internal::is_unknown_integer<T>::value, encoder&>::type
+operator<<(encoder& e, T i) {
+ using namespace internal;
+ return e << static_cast<typename integer_type<sizeof(T), is_signed<T>::value>::type>(i);
+}
+
+/// @cond INTERNAL
+
+namespace is_encodable_impl { // Protected the world from wildcard operator<<
+
+using namespace internal;
+
+sfinae::no operator<<(sfinae::wildcard, sfinae::wildcard); // Fallback
+
+template<typename T> struct is_encodable : public sfinae {
+ static yes test(encoder);
+ static no test(...); // Failed test, no match.
+ static encoder &e;
+ static const T& t;
+ static bool const value = sizeof(test(e << t)) == sizeof(yes);
+};
+
+// Avoid recursion
+template <> struct is_encodable<value> : public true_type {};
+
+} // is_encodable_impl
+
+using is_encodable_impl::is_encodable;
+
+/// @endcond
+
+} // codec
+} // proton
+
+#endif /// PROTON_CODEC_ENCODER_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/codec/forward_list.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/codec/forward_list.hpp b/proton-c/bindings/cpp/include/proton/codec/forward_list.hpp
new file mode 100644
index 0000000..2096ba9
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/codec/forward_list.hpp
@@ -0,0 +1,60 @@
+#ifndef PROTON_CODEC_FORWARD_LIST_HPP
+#define PROTON_CODEC_FORWARD_LIST_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/codec/encoder.hpp"
+#include "proton/codec/decoder.hpp"
+
+#include <forward_list>
+#include <utility>
+
+namespace proton {
+namespace codec {
+
+/// std::forward_list<T> for most T is encoded as an AMQP array.
+template <class T, class A>
+encoder& operator<<(encoder& e, const std::forward_list<T, A>& x) {
+ return e << encoder::array(x, internal::type_id_of<T>::value);
+}
+
+/// Specialize for std::forward_list<value>, encode as AMQP forward_list (variable type)
+template <class A>
+encoder& operator<<(encoder& e, const std::forward_list<value, A>& x) { return e << encoder::list(x); }
+
+/// Specialize for std::forward_list<scalar>, encode as AMQP list (variable type)
+template <class A>
+encoder& operator<<(encoder& e, const std::forward_list<scalar, A>& x) { return e << encoder::list(x); }
+
+/// Specialize for std::forward_list<std::pair<k,t> >, encode as AMQP map.
+/// Allows control over the order of encoding map entries.
+template <class A, class K, class T>
+encoder& operator<<(encoder& e, const std::forward_list<std::pair<K,T>, A>& x) { return e << encoder::map(x); }
+
+/// Decode to std::forward_list<T> from an amqp::LIST or amqp::ARRAY.
+template <class T, class A> decoder& operator>>(decoder& d, std::forward_list<T, A>& x) { return d >> decoder::sequence(x); }
+
+/// Decode to std::forward_list<std::pair<K, T> from an amqp::MAP.
+template <class A, class K, class T> decoder& operator>>(decoder& d, std::forward_list<std::pair<K, T> , A>& x) { return d >> decoder::pair_sequence(x); }
+
+} // codec
+} // proton
+
+#endif // PROTON_CODEC_FORWARD_LIST_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/codec/list.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/codec/list.hpp b/proton-c/bindings/cpp/include/proton/codec/list.hpp
new file mode 100644
index 0000000..40d2e7a
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/codec/list.hpp
@@ -0,0 +1,62 @@
+#ifndef PROTON_CODEC_LIST_HPP
+#define PROTON_CODEC_LIST_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/codec/encoder.hpp"
+#include "proton/codec/decoder.hpp"
+
+#include <list>
+#include <utility>
+
+namespace proton {
+namespace codec {
+
+/// std::list<T> for most T is encoded as an AMQP array.
+template <class T, class A>
+encoder& operator<<(encoder& e, const std::list<T, A>& x) {
+ return e << encoder::array(x, internal::type_id_of<T>::value);
+}
+
+/// Specialize for std::list<value>, encode as AMQP list (variable type)
+template <class A>
+encoder& operator<<(encoder& e, const std::list<value, A>& x) { return e << encoder::list(x); }
+
+/// Specialize for std::list<scalar>, encode as AMQP list (variable type)
+template <class A>
+encoder& operator<<(encoder& e, const std::list<scalar, A>& x) { return e << encoder::list(x); }
+
+/// Specialize for std::list<std::pair<k,t> >, encode as AMQP map.
+/// Allows control over the order of encoding map entries.
+template <class A, class K, class T>
+encoder& operator<<(encoder& e, const std::list<std::pair<K,T>, A>& x) { return e << encoder::map(x); }
+
+/// Decode to std::list<T> from an amqp::LIST or amqp::ARRAY.
+template <class T, class A> decoder& operator>>(decoder& d, std::list<T, A>& x) { return d >> decoder::sequence(x); }
+
+/// Decode to std::list<std::pair<K, T> from an amqp::MAP.
+template <class A, class K, class T> decoder& operator>>(decoder& d, std::list<std::pair<K, T> , A>& x) { return d >> decoder::pair_sequence(x); }
+
+} // codec
+} // proton
+
+#endif // PROTON_CODEC_LIST_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/codec/map.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/codec/map.hpp b/proton-c/bindings/cpp/include/proton/codec/map.hpp
new file mode 100644
index 0000000..c9287c0
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/codec/map.hpp
@@ -0,0 +1,44 @@
+#ifndef PROTON_CODEC_MAP_HPP
+#define PROTON_CODEC_MAP_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/codec/encoder.hpp"
+#include "proton/codec/decoder.hpp"
+
+#include <map>
+
+namespace proton {
+namespace codec {
+
+/// Encode std::map<K, T> as amqp::MAP.
+template <class K, class T, class C, class A>
+encoder& operator<<(encoder& e, const std::map<K, T, C, A>& m) { return e << encoder::map(m); }
+
+/// Decode to std::map<K, T> from amqp::MAP.
+template <class K, class T, class C, class A>
+decoder& operator>>(decoder& d, std::map<K, T, C, A>& m) { return d >> decoder::associative(m); }
+
+} // codec
+} // proton
+
+#endif // PROTON_CODEC_MAP_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/codec/unordered_map.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/codec/unordered_map.hpp b/proton-c/bindings/cpp/include/proton/codec/unordered_map.hpp
new file mode 100644
index 0000000..9be856f
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/codec/unordered_map.hpp
@@ -0,0 +1,44 @@
+#ifndef PROTON_CODEC_UNORDERED_MAP_HPP
+#define PROTON_CODEC_UNORDERED_MAP_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/codec/encoder.hpp"
+#include "proton/codec/decoder.hpp"
+
+#include <unordered_map>
+
+namespace proton {
+namespace codec {
+
+/// Encode std::unordered_map<K, T> as amqp::UNORDERED_MAP.
+template <class K, class T, class C, class A>
+encoder& operator<<(encoder& e, const std::unordered_map<K, T, C, A>& m) { return e << encoder::map(m); }
+
+/// Decode to std::unordered_map<K, T> from amqp::UNORDERED_MAP.
+template <class K, class T, class C, class A>
+decoder& operator>>(decoder& d, std::unordered_map<K, T, C, A>& m) { return d >> decoder::associative(m); }
+
+} // codec
+} // proton
+
+#endif // PROTON_CODEC_UNORDERED_MAP_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/codec/vector.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/codec/vector.hpp b/proton-c/bindings/cpp/include/proton/codec/vector.hpp
new file mode 100644
index 0000000..0808229
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/codec/vector.hpp
@@ -0,0 +1,58 @@
+#ifndef PROTON_CODEC_VECTOR_HPP
+#define PROTON_CODEC_VECTOR_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/codec/encoder.hpp"
+#include "proton/codec/decoder.hpp"
+
+#include <vector>
+#include <utility>
+
+namespace proton {
+namespace codec {
+
+/// Encode std::vector<T> as amqp::ARRAY (same type elements)
+template <class T, class A> encoder& operator<<(encoder& e, const std::vector<T, A>& x) {
+ return e << encoder::array(x, internal::type_id_of<T>::value);
+}
+
+/// Encode std::vector<value> encode as amqp::LIST (mixed type elements)
+template <class A> encoder& operator<<(encoder& e, const std::vector<value, A>& x) { return e << encoder::list(x); }
+
+/// Encode std::vector<scalar> as amqp::LIST (mixed type elements)
+template <class A> encoder& operator<<(encoder& e, const std::vector<scalar, A>& x) { return e << encoder::list(x); }
+
+/// Encode std::deque<std::pair<k,t> > as amqp::MAP, preserves order of entries.
+template <class A, class K, class T>
+encoder& operator<<(encoder& e, const std::vector<std::pair<K,T>, A>& x) { return e << encoder::map(x); }
+
+/// Decode to std::vector<T> from an amqp::LIST or amqp::ARRAY.
+template <class T, class A> decoder& operator>>(decoder& d, std::vector<T, A>& x) { return d >> decoder::sequence(x); }
+
+/// Decode to std::vector<std::pair<K, T> from an amqp::MAP.
+template <class A, class K, class T> decoder& operator>>(decoder& d, std::vector<std::pair<K, T> , A>& x) { return d >> decoder::pair_sequence(x); }
+
+} // codec
+} // proton
+
+#endif // PROTON_CODEC_VECTOR_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/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
deleted file mode 100644
index 72bcbb4..0000000
--- a/proton-c/bindings/cpp/include/proton/comparable.hpp
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef COMPARABLE_HPP
-#define COMPARABLE_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 {
-namespace internal {
-
-///@cond INTERNAL
-
-/// Base class for comparable types with operator< and
-/// operator==. Provides remaining operators.
-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); }
-};
-
-///@endcond
-
-}}
-
-#endif // COMPARABLE_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/config.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/config.hpp b/proton-c/bindings/cpp/include/proton/config.hpp
index f6b10d6..2e085d0 100644
--- a/proton-c/bindings/cpp/include/proton/config.hpp
+++ b/proton-c/bindings/cpp/include/proton/config.hpp
@@ -1,7 +1,8 @@
-#ifndef CONFIG_HPP
-#define CONFIG_HPP
+#ifndef PROTON_CONFIG_HPP
+#define PROTON_CONFIG_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
@@ -18,6 +19,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
+ *
*/
/// @cond INTERNAL
@@ -77,6 +79,6 @@
#define PN_CPP_HAS_DELETED_FUNCTIONS PN_CPP_HAS_CPP11
#endif
-#endif // CONFIG_HPP
+#endif // PROTON_CONFIG_HPP
/// @endcond
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/connection.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/connection.hpp b/proton-c/bindings/cpp/include/proton/connection.hpp
index 1851625..bfe4000 100644
--- a/proton-c/bindings/cpp/include/proton/connection.hpp
+++ b/proton-c/bindings/cpp/include/proton/connection.hpp
@@ -1,5 +1,5 @@
-#ifndef PROTON_CPP_CONNECTION_H
-#define PROTON_CPP_CONNECTION_H
+#ifndef PROTON_CONNECTION_HPP
+#define PROTON_CONNECTION_HPP
/*
*
@@ -24,8 +24,9 @@
#include "proton/export.hpp"
#include "proton/endpoint.hpp"
-#include "proton/object.hpp"
+#include "proton/internal/object.hpp"
#include "proton/session.hpp"
+
#include "proton/types.h"
#include <string>
@@ -51,9 +52,9 @@ PN_CPP_CLASS_EXTERN connection : public internal::object<pn_connection_t>, publi
/// @endcond
public:
+ /// Create an empty connection.
connection() : internal::object<pn_connection_t>(0) {}
- /// Get the state of this connection.
PN_CPP_EXTERN bool uninitialized() const;
PN_CPP_EXTERN bool active() const;
PN_CPP_EXTERN bool closed() const;
@@ -69,27 +70,27 @@ PN_CPP_CLASS_EXTERN connection : public internal::object<pn_connection_t>, publi
/// Get the transport for the connection.
PN_CPP_EXTERN class transport transport() const;
- /// Return the AMQP host name for the connection.
+ /// Return the AMQP hostname attribute for the connection.
PN_CPP_EXTERN std::string virtual_host() const;
/// Return the container ID for the connection.
PN_CPP_EXTERN std::string container_id() const;
- /// Initiate local open. The operation is not complete till
- /// handler::on_connection_open().
+ /// Open the connection.
+ ///
+ /// @see endpoint_lifecycle
PN_CPP_EXTERN void open();
+
+ /// @copydoc open
PN_CPP_EXTERN void open(const connection_options &);
- /// Initiate local close. The operation is not complete till
- /// handler::on_connection_close().
PN_CPP_EXTERN void close();
-
- /// Initiate close with an error condition.
- /// The operation is not complete till handler::on_connection_close().
PN_CPP_EXTERN void close(const error_condition&);
/// Open a new session.
PN_CPP_EXTERN session open_session();
+
+ /// @copydoc open_session
PN_CPP_EXTERN session open_session(const session_options &);
/// Get the default session. A default session is created on the
@@ -98,10 +99,14 @@ PN_CPP_CLASS_EXTERN connection : public internal::object<pn_connection_t>, publi
/// Open a sender for `addr` on default_session().
PN_CPP_EXTERN sender open_sender(const std::string &addr);
+
+ /// @copydoc open_sender
PN_CPP_EXTERN sender open_sender(const std::string &addr, const sender_options &);
/// Open a receiver for `addr` on default_session().
PN_CPP_EXTERN receiver open_receiver(const std::string &addr);
+
+ /// @copydoc open_receiver
PN_CPP_EXTERN receiver open_receiver(const std::string &addr,
const receiver_options &);
@@ -114,20 +119,32 @@ PN_CPP_CLASS_EXTERN connection : public internal::object<pn_connection_t>, publi
/// Return all senders on this connection.
PN_CPP_EXTERN sender_range senders() const;
+ /// Get the maximum frame size.
+ ///
+ /// @see @ref connection_options::max_frame_size
PN_CPP_EXTERN uint32_t max_frame_size() const;
+
+ /// Get the maximum number of open sessions.
+ ///
+ /// @see @ref connection_options::max_sessions
PN_CPP_EXTERN uint16_t max_sessions() const;
+
+ /// Get the idle timeout.
+ ///
+ /// @see @ref connection_options::idle_timeout
PN_CPP_EXTERN uint32_t idle_timeout() const;
private:
void user(const std::string &);
void password(const std::string &);
- friend class internal::factory<connection>;
- friend class connector;
+ /// @cond INTERNAL
+ friend class internal::factory<connection>;
+ friend class connector;
friend class proton::thread_safe<connection>;
/// @endcond
};
-}
+} // proton
-#endif // PROTON_CPP_CONNECTION_H
+#endif // PROTON_CONNECTION_HPP
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org