You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2015/07/16 07:23:48 UTC
[1/3] qpid-proton git commit: NO-JIRA: Fix minor doxygen warnings in
the proton-c headers.
Repository: qpid-proton
Updated Branches:
refs/heads/cjansen-cpp-client f9bcbb5a5 -> 035b6957c
NO-JIRA: Fix minor doxygen warnings in the proton-c headers.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/cdad4dd7
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/cdad4dd7
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/cdad4dd7
Branch: refs/heads/cjansen-cpp-client
Commit: cdad4dd766460aa38f12e0b54ef902a20e8d77ea
Parents: f9bcbb5
Author: Alan Conway <ac...@redhat.com>
Authored: Tue Jul 14 18:52:37 2015 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Jul 14 18:52:37 2015 -0400
----------------------------------------------------------------------
proton-c/include/proton/codec.h | 11 +++++------
proton-c/include/proton/event.h | 3 ++-
proton-c/include/proton/handlers.h | 1 -
proton-c/include/proton/reactor.h | 1 -
proton-c/include/proton/selectable.h | 5 ++---
5 files changed, 9 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cdad4dd7/proton-c/include/proton/codec.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/codec.h b/proton-c/include/proton/codec.h
index 05b8f6f..3f6a6dc 100644
--- a/proton-c/include/proton/codec.h
+++ b/proton-c/include/proton/codec.h
@@ -509,8 +509,7 @@ PN_EXTERN int pn_data_format(pn_data_t *data, char *bytes, size_t *size);
* @param bytes the buffer for encoded data
* @param size the size of the buffer
*
- * @param ssize_t returns the size of the encoded data on success or
- * an error code on failure
+ * @return the size of the encoded data on success or an error code on failure
*/
PN_EXTERN ssize_t pn_data_encode(pn_data_t *data, char *bytes, size_t size);
@@ -519,7 +518,7 @@ PN_EXTERN ssize_t pn_data_encode(pn_data_t *data, char *bytes, size_t size);
*
* @param data the data object
*
- * @param ssize_t returns the size of the encoded data or an error code if data is invalid.
+ * @return the size of the encoded data or an error code if data is invalid.
*/
PN_EXTERN ssize_t pn_data_encoded_size(pn_data_t *data);
@@ -545,7 +544,7 @@ PN_EXTERN ssize_t pn_data_decode(pn_data_t *data, const char *bytes, size_t size
/**
* Puts an empty list value into a pn_data_t. Elements may be filled
* by entering the list node using ::pn_data_enter() and using
- * ::pn_data_put_* to add the desired contents. Once done,
+ * pn_data_put_* to add the desired contents. Once done,
* ::pn_data_exit() may be used to return to the current level in the
* tree and put more values.
*
@@ -915,7 +914,7 @@ PN_EXTERN size_t pn_data_get_map(pn_data_t *data);
* If the current node is an array, return the number of elements in
* the array, otherwise return 0. Array data can be accessed by
* entering the array. If the array is described, the first child node
- * will be the descriptor, and the remaining @var count child nodes
+ * will be the descriptor, and the remaining count child nodes
* will be the elements of the array.
*
* @code
@@ -1249,7 +1248,7 @@ PN_EXTERN pn_handle_t pn_data_point(pn_data_t *data);
* otherwise it will return true.
*
* @param data a pn_data_t object
- * @param handle a handle referencing the saved navigational state
+ * @param point a handle referencing the saved navigational state
* @return true iff the prior navigational state was restored
*/
PN_EXTERN bool pn_data_restore(pn_data_t *data, pn_handle_t point);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cdad4dd7/proton-c/include/proton/event.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/event.h b/proton-c/include/proton/event.h
index 43329c4..d10927b 100644
--- a/proton-c/include/proton/event.h
+++ b/proton-c/include/proton/event.h
@@ -350,8 +350,9 @@ PN_EXTERN void pn_collector_release(pn_collector_t *collector);
* this happens, this operation will return a NULL pointer.
*
* @param[in] collector a collector object
- * @param[in] type the event type
+ * @param[in] clazz class of the context
* @param[in] context the event context
+ * @param[in] type the event type
*
* @return a pointer to the newly created event or NULL if the event
* was elided
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cdad4dd7/proton-c/include/proton/handlers.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/handlers.h b/proton-c/include/proton/handlers.h
index 304d0e6..f61e04c 100644
--- a/proton-c/include/proton/handlers.h
+++ b/proton-c/include/proton/handlers.h
@@ -36,7 +36,6 @@ extern "C" {
* Reactor API for proton.
*
* @defgroup handlers Handlers
- * @ingroup handlers
* @{
*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cdad4dd7/proton-c/include/proton/reactor.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/reactor.h b/proton-c/include/proton/reactor.h
index 6f52d22..ed223e7 100644
--- a/proton-c/include/proton/reactor.h
+++ b/proton-c/include/proton/reactor.h
@@ -38,7 +38,6 @@ extern "C" {
* Reactor API for proton.
*
* @defgroup reactor Reactor
- * @ingroup reactor
* @{
*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cdad4dd7/proton-c/include/proton/selectable.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/selectable.h b/proton-c/include/proton/selectable.h
index 07cb212..7b0fa02 100644
--- a/proton-c/include/proton/selectable.h
+++ b/proton-c/include/proton/selectable.h
@@ -53,9 +53,7 @@ typedef pn_iterator_t pn_selectables_t;
*
* Every selectable is associated with exactly one file descriptor.
* Selectables may be interested in three kinds of events, read
- * events, write events, and timer events. A selectable will express
- * its interest in these events through the ::pn_selectable_capacity(),
- * ::pn_selectable_pending(), and ::pn_selectable_deadline() calls.
+ * events, write events, and timer events.
*
* When a read, write, or timer event occurs, the selectable must be
* notified by calling ::pn_selectable_readable(),
@@ -237,6 +235,7 @@ PN_EXTERN void pn_selectable_free(pn_selectable_t *selectable);
* writable, and expired events into the supplied collector.
*
* @param[in] selectable a selectable objet
+ * @param[in] collector a collector object
*/
PN_EXTERN void pn_selectable_collect(pn_selectable_t *selectable, pn_collector_t *collector);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[3/3] qpid-proton git commit: PROTON-865: C++ binding API
documentation and cleanup.
Posted by ac...@apache.org.
PROTON-865: C++ binding API documentation and cleanup.
- API doc comments on most of API, some TODO notes left in headers.
- Use proton::url consistently rather than std::string in API where appropriate.
- Fix some const issues.
- Clean up messaging_event enum names, add event_type constants to proton_event.
- Consistent option parsing for examples, python compatible.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/035b6957
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/035b6957
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/035b6957
Branch: refs/heads/cjansen-cpp-client
Commit: 035b6957ce92ed033876ca81b149014d7c5cc0d6
Parents: cdad4dd
Author: Alan Conway <ac...@redhat.com>
Authored: Tue Jul 14 18:53:11 2015 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Thu Jul 16 01:20:25 2015 -0400
----------------------------------------------------------------------
examples/cpp/broker.cpp | 13 +-
examples/cpp/direct_recv.cpp | 55 +----
examples/cpp/direct_send.cpp | 54 +----
examples/cpp/encode_decode.cpp | 3 +-
examples/cpp/example_test.py | 2 +-
examples/cpp/helloworld.cpp | 15 +-
examples/cpp/helloworld_blocking.cpp | 23 +-
examples/cpp/helloworld_direct.cpp | 20 +-
examples/cpp/options.hpp | 173 +++++++++++++
examples/cpp/simple_recv.cpp | 55 ++---
examples/cpp/simple_send.cpp | 54 +----
proton-c/bindings/cpp/README.md | 8 +-
proton-c/bindings/cpp/docs/tutorial.md | 38 +--
.../bindings/cpp/include/proton/acceptor.hpp | 3 +
proton-c/bindings/cpp/include/proton/acking.hpp | 9 +
.../cpp/include/proton/blocking_connection.hpp | 9 +-
.../cpp/include/proton/blocking_link.hpp | 1 +
.../cpp/include/proton/blocking_sender.hpp | 1 +
proton-c/bindings/cpp/include/proton/config.hpp | 30 +++
.../bindings/cpp/include/proton/connection.hpp | 26 +-
.../bindings/cpp/include/proton/container.hpp | 49 +++-
proton-c/bindings/cpp/include/proton/data.hpp | 2 +-
.../bindings/cpp/include/proton/decoder.hpp | 10 +-
.../bindings/cpp/include/proton/delivery.hpp | 21 +-
.../bindings/cpp/include/proton/duration.hpp | 12 +-
.../bindings/cpp/include/proton/encoder.hpp | 5 +-
.../bindings/cpp/include/proton/endpoint.hpp | 35 ++-
proton-c/bindings/cpp/include/proton/error.hpp | 7 +-
proton-c/bindings/cpp/include/proton/event.hpp | 20 +-
proton-c/bindings/cpp/include/proton/export.hpp | 2 +
proton-c/bindings/cpp/include/proton/handle.hpp | 4 +-
.../bindings/cpp/include/proton/handler.hpp | 7 +-
proton-c/bindings/cpp/include/proton/link.hpp | 27 ++-
.../bindings/cpp/include/proton/message.hpp | 32 ++-
.../cpp/include/proton/messaging_adapter.hpp | 4 +-
.../cpp/include/proton/messaging_event.hpp | 95 ++++----
.../cpp/include/proton/messaging_handler.hpp | 19 +-
.../cpp/include/proton/proton_event.hpp | 242 ++++++++++++++++++-
.../cpp/include/proton/proton_handle.hpp | 2 +
.../cpp/include/proton/proton_handler.hpp | 7 +-
.../bindings/cpp/include/proton/receiver.hpp | 1 +
proton-c/bindings/cpp/include/proton/sender.hpp | 4 +-
.../bindings/cpp/include/proton/session.hpp | 29 ++-
.../bindings/cpp/include/proton/terminus.hpp | 8 +-
.../bindings/cpp/include/proton/transport.hpp | 3 +
.../bindings/cpp/include/proton/type_traits.hpp | 19 +-
proton-c/bindings/cpp/include/proton/types.hpp | 86 +++----
proton-c/bindings/cpp/include/proton/url.hpp | 28 ++-
.../cpp/include/proton/wait_condition.hpp | 3 +
.../bindings/cpp/src/blocking_connection.cpp | 5 +-
.../cpp/src/blocking_connection_impl.cpp | 3 +-
proton-c/bindings/cpp/src/connection.cpp | 2 +-
proton-c/bindings/cpp/src/connection_impl.cpp | 2 +-
proton-c/bindings/cpp/src/connection_impl.hpp | 2 +-
proton-c/bindings/cpp/src/container.cpp | 6 +-
proton-c/bindings/cpp/src/container_impl.cpp | 12 +-
proton-c/bindings/cpp/src/container_impl.hpp | 4 +-
proton-c/bindings/cpp/src/decoder.cpp | 1 -
proton-c/bindings/cpp/src/endpoint.cpp | 10 +
proton-c/bindings/cpp/src/error.cpp | 2 +
proton-c/bindings/cpp/src/link.cpp | 2 +-
proton-c/bindings/cpp/src/message.cpp | 11 +-
proton-c/bindings/cpp/src/messaging_adapter.cpp | 54 ++---
proton-c/bindings/cpp/src/messaging_event.cpp | 83 ++++---
proton-c/bindings/cpp/src/proton_event.cpp | 144 +++++++----
proton-c/bindings/cpp/src/session.cpp | 4 +-
proton-c/bindings/cpp/src/url.cpp | 21 ++
proton-c/include/proton/message.h | 2 +-
68 files changed, 1200 insertions(+), 545 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/examples/cpp/broker.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/broker.cpp b/examples/cpp/broker.cpp
index 86f5b89..a57fff9 100644
--- a/examples/cpp/broker.cpp
+++ b/examples/cpp/broker.cpp
@@ -19,6 +19,8 @@
*
*/
+#include "options.hpp"
+
#include "proton/container.hpp"
#include "proton/messaging_handler.hpp"
#include "proton/url.hpp"
@@ -196,12 +198,19 @@ class broker : public proton::messaging_handler {
};
int main(int argc, char **argv) {
+ // Command line options
+ proton::url url("0.0.0.0");
+ options opts(argc, argv);
+ opts.add_value(url, 'a', "address", "listen on URL", "URL");
try {
- std::string url(argc > 1 ? argv[1] : "0.0.0.0");
+ opts.parse();
broker broker(url);
proton::container(broker).run();
+ return 0;
+ } catch (const bad_option& e) {
+ std::cout << opts << std::endl << e.what() << std::endl;
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
- return 1;
}
+ return 1;
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/examples/cpp/direct_recv.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/direct_recv.cpp b/examples/cpp/direct_recv.cpp
index 5c8c808..9eead92 100644
--- a/examples/cpp/direct_recv.cpp
+++ b/examples/cpp/direct_recv.cpp
@@ -19,6 +19,8 @@
*
*/
+#include "options.hpp"
+
#include "proton/container.hpp"
#include "proton/messaging_handler.hpp"
#include "proton/link.hpp"
@@ -30,8 +32,6 @@
#include <stdio.h>
#include <string.h>
-
-
class direct_recv : public proton::messaging_handler {
private:
proton::url url;
@@ -66,52 +66,23 @@ class direct_recv : public proton::messaging_handler {
}
};
-static void parse_options(int argc, char **argv, int &count, std::string &addr);
-
int main(int argc, char **argv) {
+ // Command line options
+ std::string address("127.0.0.1:5672/examples");
+ int message_count = 100;
+ options opts(argc, argv);
+ opts.add_value(address, 'a', "address", "listen and receive on URL", "URL");
+ opts.add_value(message_count, 'm', "messages", "receive COUNT messages", "COUNT");
try {
- int message_count = 100;
- std::string address("127.0.0.1:5672/examples");
- parse_options(argc, argv, message_count, address);
+ opts.parse();
direct_recv recv(address, message_count);
proton::container(recv).run();
+ return 0;
+ } catch (const bad_option& e) {
+ std::cout << opts << std::endl << e.what() << std::endl;
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
- return 1;
}
+ return 1;
}
-
-static void usage() {
- std::cout << "Usage: direct_recv -m message_count -a address:" << std::endl;
- exit (1);
-}
-
-
-static void parse_options(int argc, char **argv, int &count, std::string &addr) {
- int c, i;
- for (i = 1; i < argc; i++) {
- if (strlen(argv[i]) == 2 && argv[i][0] == '-') {
- c = argv[i][1];
- const char *nextarg = i < argc ? argv[i+1] : NULL;
-
- switch (c) {
- case 'a':
- if (!nextarg) usage();
- addr = nextarg;
- i++;
- break;
- case 'm':
- if (!nextarg) usage();
- unsigned newc;
- if (sscanf( nextarg, "%d", &newc) != 1) usage();
- count = newc;
- i++;
- break;
- default:
- usage();
- }
- }
- else usage();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/examples/cpp/direct_send.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/direct_send.cpp b/examples/cpp/direct_send.cpp
index 9ffa28a..a4e572c 100644
--- a/examples/cpp/direct_send.cpp
+++ b/examples/cpp/direct_send.cpp
@@ -19,6 +19,8 @@
*
*/
+#include "options.hpp"
+
#include "proton/container.hpp"
#include "proton/messaging_handler.hpp"
#include "proton/connection.hpp"
@@ -74,52 +76,22 @@ class simple_send : public proton::messaging_handler {
}
};
-static void parse_options(int argc, char **argv, int &count, std::string &addr);
-
int main(int argc, char **argv) {
+ // Command line options
+ std::string address("127.0.0.1:5672/examples");
+ int message_count = 100;
+ options opts(argc, argv);
+ opts.add_value(address, 'a', "address", "listen and send on URL", "URL");
+ opts.add_value(message_count, 'm', "messages", "send COUNT messages", "COUNT");
try {
- int message_count = 100;
- std::string address("127.0.0.1:5672/examples");
- parse_options(argc, argv, message_count, address);
+ opts.parse();
simple_send send(address, message_count);
proton::container(send).run();
+ return 0;
+ } catch (const bad_option& e) {
+ std::cout << opts << std::endl << e.what() << std::endl;
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
- return 1;
- }
-}
-
-
-static void usage() {
- std::cout << "Usage: simple_send -m message_count -a address:" << std::endl;
- exit (1);
-}
-
-
-static void parse_options(int argc, char **argv, int &count, std::string &addr) {
- int c, i;
- for (i = 1; i < argc; i++) {
- if (strlen(argv[i]) == 2 && argv[i][0] == '-') {
- c = argv[i][1];
- const char *nextarg = i < argc ? argv[i+1] : NULL;
-
- switch (c) {
- case 'a':
- if (!nextarg) usage();
- addr = nextarg;
- i++;
- break;
- case 'm':
- if (!nextarg) usage();
- unsigned newc;
- if (sscanf( nextarg, "%d", &newc) != 1) usage();
- count = newc;
- i++;
- break;
- default:
- usage();
- }
- }
- else usage();
}
+ return 1;
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/examples/cpp/encode_decode.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/encode_decode.cpp b/examples/cpp/encode_decode.cpp
index df9ad15..ea0f471 100644
--- a/examples/cpp/encode_decode.cpp
+++ b/examples/cpp/encode_decode.cpp
@@ -175,10 +175,11 @@ int main(int, char**) {
insert_extract_containers();
mixed_containers();
insert_extract_stream_operators();
+ return 0;
} catch (const exception& e) {
cerr << endl << "error: " << e.what() << endl;
- return 1;
}
+ return 1;
}
// print_next prints the next value from values by recursively descending into complex values.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/examples/cpp/example_test.py
----------------------------------------------------------------------
diff --git a/examples/cpp/example_test.py b/examples/cpp/example_test.py
index b2110f6..8dd4341 100644
--- a/examples/cpp/example_test.py
+++ b/examples/cpp/example_test.py
@@ -94,7 +94,7 @@ class Broker(object):
def __init__(self):
self.addr = pick_addr()
- cmd = [exe_name("broker"), self.addr]
+ cmd = [exe_name("broker"), "-a", self.addr]
try:
self.process = Popen(cmd, stdout=NULL, stderr=NULL)
wait_addr(self.addr)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/examples/cpp/helloworld.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/helloworld.cpp b/examples/cpp/helloworld.cpp
index 13bdbc7..34e5076 100644
--- a/examples/cpp/helloworld.cpp
+++ b/examples/cpp/helloworld.cpp
@@ -27,16 +27,16 @@
class hello_world : public proton::messaging_handler {
private:
- proton::url server;
- std::string address;
+ proton::url url;
+
public:
- hello_world(const proton::url &url) : server(url), address(url.path()) {}
+ hello_world(const proton::url& u) : url(u) {}
void on_start(proton::event &e) {
- proton::connection conn = e.container().connect(server);
- e.container().create_receiver(conn, address);
- e.container().create_sender(conn, address);
+ proton::connection conn = e.container().connect(url);
+ e.container().create_receiver(conn, url.path());
+ e.container().create_sender(conn, url.path());
}
void on_sendable(proton::event &e) {
@@ -58,8 +58,9 @@ int main(int argc, char **argv) {
std::string url = argc > 1 ? argv[1] : "127.0.0.1:5672/examples";
hello_world hw(url);
proton::container(hw).run();
+ return 0;
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
- return 1;
}
+ return 1;
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/examples/cpp/helloworld_blocking.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/helloworld_blocking.cpp b/examples/cpp/helloworld_blocking.cpp
index ff14320..2b6b4db 100644
--- a/examples/cpp/helloworld_blocking.cpp
+++ b/examples/cpp/helloworld_blocking.cpp
@@ -27,15 +27,15 @@
class hello_world_blocking : public proton::messaging_handler {
private:
- std::string server;
- std::string address;
+ proton::url url;
+
public:
- hello_world_blocking(const std::string &s, const std::string &addr) : server(s), address(addr) {}
+ hello_world_blocking(const proton::url& u) : url(u) {}
void on_start(proton::event &e) {
- proton::connection conn = e.container().connect(server);
- e.container().create_receiver(conn, address);
+ proton::connection conn = e.container().connect(url);
+ e.container().create_receiver(conn, url.path());
}
void on_message(proton::event &e) {
@@ -47,20 +47,21 @@ class hello_world_blocking : public proton::messaging_handler {
int main(int argc, char **argv) {
try {
- std::string server = argc > 1 ? argv[1] : ":5672";
- std::string addr = argc > 2 ? argv[2] : "examples";
- proton::blocking_connection conn(server);
- proton::blocking_sender sender = conn.create_sender(addr);
+ proton::url url(argc > 1 ? argv[1] : "127.0.0.1:5672/examples");
+
+ proton::blocking_connection conn(url);
+ proton::blocking_sender sender = conn.create_sender(url.path());
proton::message m;
m.body("Hello World!");
sender.send(m);
conn.close();
// TODO Temporary hack until blocking receiver available
- hello_world_blocking hw(server, addr);
+ hello_world_blocking hw(url);
proton::container(hw).run();
+ return 0;
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
- return 1;
}
+ return 1;
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/examples/cpp/helloworld_direct.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/helloworld_direct.cpp b/examples/cpp/helloworld_direct.cpp
index d81d2b7..2c7792e 100644
--- a/examples/cpp/helloworld_direct.cpp
+++ b/examples/cpp/helloworld_direct.cpp
@@ -27,15 +27,15 @@
class hello_world_direct : public proton::messaging_handler {
private:
- proton::url url_;
- proton::acceptor acceptor_;
+ proton::url url;
+ proton::acceptor acceptor;
public:
- hello_world_direct(const std::string &u) : url_(u) {}
+ hello_world_direct(const proton::url& u) : url(u) {}
void on_start(proton::event &e) {
- acceptor_ = e.container().listen(url_);
- e.container().create_sender(url_);
+ acceptor = e.container().listen(url);
+ e.container().create_sender(url);
}
void on_sendable(proton::event &e) {
@@ -54,18 +54,20 @@ class hello_world_direct : public proton::messaging_handler {
}
void on_connection_closed(proton::event &e) {
- acceptor_.close();
+ acceptor.close();
}
-
};
int main(int argc, char **argv) {
try {
- std::string url = argc > 1 ? argv[1] : ":8888/examples";
+ // Pick an "unusual" port since we are going to be talking to ourselves, not a broker.
+ std::string url = argc > 1 ? argv[1] : "127.0.0.1:8888/examples";
+
hello_world_direct hwd(url);
proton::container(hwd).run();
+ return 0;
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
- return 1;
}
+ return 1;
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/examples/cpp/options.hpp
----------------------------------------------------------------------
diff --git a/examples/cpp/options.hpp b/examples/cpp/options.hpp
new file mode 100644
index 0000000..5378507
--- /dev/null
+++ b/examples/cpp/options.hpp
@@ -0,0 +1,173 @@
+#ifndef OPTIONS_HPP
+#define OPTIONS_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>
+#include <sstream>
+#include <ostream>
+#include <vector>
+#include <stdexcept>
+
+/** bad_option is thrown for option parsing errors */
+struct bad_option : public std::runtime_error {
+ bad_option(const std::string& s) : std::runtime_error(s) {}
+};
+
+/** Simple command-line option parser for example programs */
+class options {
+ public:
+
+ options(int argc, char const * const * argv) : argc_(argc), argv_(argv), prog_(argv[0]), help_() {
+ size_t slash = prog_.find_last_of("/\\");
+ if (slash != std::string::npos)
+ prog_ = prog_.substr(slash+1); // Extract prog name from path
+ add_flag(help_, 'h', "help", "Print the help message");
+ }
+
+ ~options() {
+ for (opts::iterator i = opts_.begin(); i != opts_.end(); ++i)
+ delete *i;
+ }
+
+ /** Updates value when parse() is called if option is present with a value. */
+ template<class T>
+ void add_value(T& value, char short_name, const std::string& long_name, const std::string& description, const std::string var) {
+ opts_.push_back(new option_value<T>(value, short_name, long_name, description, var));
+ }
+
+ /** Sets flag when parse() is called if option is present. */
+ void add_flag(bool& flag, char short_name, const std::string& long_name, const std::string& description) {
+ opts_.push_back(new option_flag(flag, short_name, long_name, description));
+ }
+
+ /** Parse the command line, return the index of the first non-option argument.
+ *@throws bad_option if there is a parsing error or unknown option.
+ */
+ int parse() {
+ int arg = 1;
+ for (; arg < argc_ && argv_[arg][0] == '-'; ++arg) {
+ opts::iterator i = opts_.begin();
+ while (i != opts_.end() && !(*i)->parse(argc_, argv_, arg))
+ ++i;
+ if (i == opts_.end())
+ throw bad_option(std::string("unknown option ") + argv_[arg]);
+ }
+ if (help_) throw bad_option("");
+ return arg;
+ }
+
+ /** Print a usage message */
+ friend std::ostream& operator<<(std::ostream& os, const options& op) {
+ os << std::endl << "usage: " << op.prog_ << " [options]" << std::endl;
+ os << std::endl << "options:" << std::endl;
+ for (opts::const_iterator i = op.opts_.begin(); i < op.opts_.end(); ++i)
+ os << **i << std::endl;
+ return os;
+ }
+
+ private:
+ class option {
+ public:
+ option(char s, const std::string& l, const std::string& d, const std::string v) :
+ short_(std::string("-") + s), long_("--" + l), desc_(d), var_(v) {}
+ virtual ~option() {}
+
+ virtual bool parse(int argc, char const * const * argv, int &i) = 0;
+ virtual void print_default(std::ostream&) const {};
+
+ friend std::ostream& operator<<(std::ostream& os, const option& op) {
+ os << " " << op.short_;
+ if (!op.var_.empty()) os << " " << op.var_;
+ os << ", " << op.long_;
+ if (!op.var_.empty()) os << "=" << op.var_;
+ os << std::endl << " " << op.desc_;
+ op.print_default(os);
+ return os;
+ }
+
+ protected:
+ std::string short_, long_, desc_, var_;
+ };
+
+ template <class T>
+ class option_value : public option {
+ public:
+ option_value(T& value, char s, const std::string& l, const std::string& d, const std::string& v) :
+ option(s, l, d, v), value_(value) {}
+
+ bool parse(int argc, char const * const * argv, int &i) {
+ std::string arg(argv[i]);
+ if (arg == short_ || arg == long_) {
+ if (i < argc-1) {
+ set_value(arg, argv[++i]);
+ return true;
+ } else {
+ throw bad_option("missing value for " + arg);
+ }
+ }
+ if (arg.compare(0, long_.size(), long_) == 0 && arg[long_.size()] == '=' ) {
+ set_value(long_, arg.substr(long_.size()+1));
+ return true;
+ }
+ return false;
+ }
+
+ virtual void print_default(std::ostream& os) const { os << " (default " << value_ << ")"; }
+
+ void set_value(const std::string& opt, const std::string& s) {
+ std::istringstream is(s);
+ is >> value_;
+ if (is.fail() || is.bad())
+ throw bad_option("bad value for " + opt + ": " + s);
+ }
+
+ private:
+ T& value_;
+ };
+
+ class option_flag: public option {
+ public:
+ option_flag(bool& flag, const char s, const std::string& l, const std::string& d) :
+ option(s, l, d, ""), flag_(flag)
+ { flag_ = false; }
+
+ bool parse(int /*argc*/, char const * const * argv, int &i) {
+ if (argv[i] == short_ || argv[i] == long_) {
+ flag_ = true;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ private:
+ bool &flag_;
+ };
+
+ typedef std::vector<option*> opts;
+
+ int argc_;
+ char const * const * argv_;
+ std::string prog_;
+ opts opts_;
+ bool help_;
+};
+
+#endif // OPTIONS_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/examples/cpp/simple_recv.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/simple_recv.cpp b/examples/cpp/simple_recv.cpp
index 8cc8bc4..b2cec63 100644
--- a/examples/cpp/simple_recv.cpp
+++ b/examples/cpp/simple_recv.cpp
@@ -19,6 +19,8 @@
*
*/
+#include "options.hpp"
+
#include "proton/container.hpp"
#include "proton/messaging_handler.hpp"
#include "proton/link.hpp"
@@ -63,52 +65,23 @@ class simple_recv : public proton::messaging_handler {
}
};
-static void parse_options(int argc, char **argv, int &count, std::string &addr);
-
int main(int argc, char **argv) {
+ // Command line options
+ std::string address("127.0.0.1:5672/examples");
+ int message_count = 100;
+ options opts(argc, argv);
+ opts.add_value(address, 'a', "address", "connect to and receive from URL", "URL");
+ opts.add_value(message_count, 'm', "messages", "receive COUNT messages", "COUNT");
+
try {
- int message_count = 100;
- std::string address("127.0.0.1:5672/examples");
- parse_options(argc, argv, message_count, address);
+ opts.parse();
simple_recv recv(address, message_count);
proton::container(recv).run();
+ return 0;
+ } catch (const bad_option& e) {
+ std::cout << opts << std::endl << e.what() << std::endl;
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
- return 1;
- }
-}
-
-
-static void usage() {
- std::cout << "Usage: simple_recv -m message_count -a address:" << std::endl;
- exit (1);
-}
-
-
-static void parse_options(int argc, char **argv, int &count, std::string &addr) {
- int c, i;
- for (i = 1; i < argc; i++) {
- if (strlen(argv[i]) == 2 && argv[i][0] == '-') {
- c = argv[i][1];
- const char *nextarg = i < argc ? argv[i+1] : NULL;
-
- switch (c) {
- case 'a':
- if (!nextarg) usage();
- addr = nextarg;
- i++;
- break;
- case 'm':
- if (!nextarg) usage();
- unsigned newc;
- if (sscanf( nextarg, "%d", &newc) != 1) usage();
- count = newc;
- i++;
- break;
- default:
- usage();
- }
- }
- else usage();
}
+ return 1;
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/examples/cpp/simple_send.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/simple_send.cpp b/examples/cpp/simple_send.cpp
index 0cf4cd3..0bac49b 100644
--- a/examples/cpp/simple_send.cpp
+++ b/examples/cpp/simple_send.cpp
@@ -19,6 +19,8 @@
*
*/
+#include "options.hpp"
+
#include "proton/container.hpp"
#include "proton/messaging_handler.hpp"
#include "proton/connection.hpp"
@@ -71,52 +73,22 @@ class simple_send : public proton::messaging_handler {
}
};
-static void parse_options(int argc, char **argv, int &count, std::string &addr);
-
int main(int argc, char **argv) {
+ // Command line options
+ std::string address("127.0.0.1:5672/examples");
+ int message_count = 100;
+ options opts(argc, argv);
+ opts.add_value(address, 'a', "address", "connect and send to URL", "URL");
+ opts.add_value(message_count, 'm', "messages", "receive COUNT messages", "COUNT");
try {
- int message_count = 100;
- std::string address("127.0.0.1:5672/examples");
- parse_options(argc, argv, message_count, address);
+ opts.parse();
simple_send send(address, message_count);
proton::container(send).run();
+ return 0;
+ } catch (const bad_option& e) {
+ std::cout << opts << std::endl << e.what() << std::endl;
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
- return 1;
- }
-}
-
-
-static void usage() {
- std::cout << "Usage: simple_send -m message_count -a address:" << std::endl;
- exit (1);
-}
-
-
-static void parse_options(int argc, char **argv, int &count, std::string &addr) {
- int c, i;
- for (i = 1; i < argc; i++) {
- if (strlen(argv[i]) == 2 && argv[i][0] == '-') {
- c = argv[i][1];
- const char *nextarg = i < argc ? argv[i+1] : NULL;
-
- switch (c) {
- case 'a':
- if (!nextarg) usage();
- addr = nextarg;
- i++;
- break;
- case 'm':
- if (!nextarg) usage();
- unsigned newc;
- if (sscanf( nextarg, "%d", &newc) != 1) usage();
- count = newc;
- i++;
- break;
- default:
- usage();
- }
- }
- else usage();
}
+ return 1;
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/README.md
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/README.md b/proton-c/bindings/cpp/README.md
index b6640e5..28eabbe 100644
--- a/proton-c/bindings/cpp/README.md
+++ b/proton-c/bindings/cpp/README.md
@@ -8,10 +8,8 @@ API documentation in doxygen format.
# TO DO
Doc & examples
-- Example set with tutorial documentation. Follow pyton examples + C++ encode/decode example.
- - Consistent option parsing for examples, like other languages.
- - Auto tests for all examples validating all statements & code in tutorial.
-- API documentation, fill out & organize for readable doxygen HTML.
+- Finish example set and tutorial documentation, following pyton examples.
+- Auto tests for all examples validating all statements & code in tutorial.
- C++ section on website.
Bugs
@@ -19,7 +17,7 @@ Bugs
- Drop PIMPL pattern in API: pn_foo pointer is already hiding the impl.
- Proper ownership of pn_objects created by user, e.g. Message. Let user choose pointer style?
- Error handling, examples crash on error e.g. queue not found.
-- FIXME and TODO notes in code.
+- TODO notes in code.
Tests
- Interop/type testing for full AMQP type coverage.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/docs/tutorial.md
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/docs/tutorial.md b/proton-c/bindings/cpp/docs/tutorial.md
index 91c3c91..e695aaf 100644
--- a/proton-c/bindings/cpp/docs/tutorial.md
+++ b/proton-c/bindings/cpp/docs/tutorial.md
@@ -5,23 +5,18 @@ This is a brief tutorial that will walk you through the fundamentals of building
messaging applications in incremental steps. There are further examples, in
addition the ones mentioned in the tutorial.
-Note on Brokers and URLs
-------------------------
+Some of the examples require an AMQP *broker* that can receive, store and send
+messages. \ref broker.cpp is a simple example broker which you can use. When run
+without arguments it listens on `0.0.0.0:5672`, the standard AMQP port on all
+network interfaces. To use a different port or network interface:
-Some of the examples require an AMQP *broker* that can receive, store and send messages.
-
-There is a very simple broker included as an example (\ref broker.cpp) which you can use.
-Run it like this:
-
- broker [URL]
-
-The default URL is "0.0.0.0:5672" which listens on the standard AMQP port on all
-network interfaces.
+ broker -a <host>:<port>
Instead of the example broker, you can use any AMQP 1.0 compliant broker. You
must configure your broker to have a queue (or topic) named "examples".
-Most of the examples take an optional URL argument, the simplest form is:
+Most of the examples take an optional URL argument or `-a URL` option the
+URL looks like:
HOST:PORT/ADDRESS
@@ -140,6 +135,11 @@ event loop exits, and the run() method will return.
So now we have our example working without a broker involved!
+Note that for this example we paick an "unusual" port 8888 since we are talking
+to ourselves rather than a broker.
+
+\skipline url =
+
Asynchronous Send and Receive
-----------------------------
@@ -212,7 +212,7 @@ got to.
\dontinclude simple_recv.cpp
-Now let's look at the corresponding receiver \ref simple_recv.cpp:
+Now let's look at the corresponding receiver \ref simple_recv.cpp
This time we'll use an `expected` member variable for for the number of messages we expecct and
a `received` variable to count how many we have received so far.send.
@@ -295,7 +295,7 @@ as a simple broker for testing purposes is an example of this).
Request/Response
----------------
-\todo FIXME missing example in C++
+\todo TODO missing example in C++
A common pattern is to send a request message and expect a response message in
return. AMQP has special support for this pattern. Let's have a look at a simple
@@ -303,7 +303,7 @@ example. We'll start with \ref server.cpp, the program that will process the
request and send the response. Note that we are still using a broker in this
example.
-\todo FIXME insert server snips
+\todo TODO insert server snips
Our server will provide a very simple service: it will respond with the
body of the request converted to uppercase.
@@ -316,7 +316,7 @@ reply\_to.
Now let's create a simple \ref client.cpp to test this service out.
-\todo FIXME insert client snips
+\todo TODO insert client snips
As well as sending requests, we need to be able to get back the
responses. We create a receiver for that (see line 14), but we don't
@@ -335,7 +335,7 @@ Again, we could avoid having any intermediary process here if we wished.
The following code implementas a server to which the client above could
connect directly without any need for a broker or similar.
-\todo FIXME missing server_direct.cpp
+\todo TODO missing server_direct.cpp
Though this requires some more extensive changes than the simple sending
and receiving examples, the essence of the program is still the same.
@@ -349,7 +349,7 @@ Many brokers offer the ability to consume messages based on a 'selector'
that defines which messages are of interest based on particular values
of the headers. The following example shows how that can be achieved:
-\todo FIXME selected_recv.cpp
+\todo TODO selected_recv.cpp
When creating the receiver, we specify a Selector object as an option.
The options argument can take a single object or a list. Another option
@@ -359,4 +359,4 @@ done in AMQP by specifying a distribution mode of 'copy' (instead of
'move' which is the expected default for queues). An example of that is
shown next:
-\todo FIXME queue_browser.cpp
+\todo TODO queue_browser.cpp
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/acceptor.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/acceptor.hpp b/proton-c/bindings/cpp/include/proton/acceptor.hpp
index 0df9589..bc9edbc 100644
--- a/proton-c/bindings/cpp/include/proton/acceptor.hpp
+++ b/proton-c/bindings/cpp/include/proton/acceptor.hpp
@@ -30,6 +30,7 @@ struct pn_connection_t;
namespace proton {
+/** acceptor accepts connections. @see container::listen */
class acceptor : public proton_handle<pn_acceptor_t>
{
public:
@@ -39,7 +40,9 @@ class acceptor : public proton_handle<pn_acceptor_t>
PN_CPP_EXTERN acceptor& operator=(const acceptor&);
PN_CPP_EXTERN ~acceptor();
+ /** close the acceptor */
PN_CPP_EXTERN void close();
+
private:
friend class proton_impl_ref<acceptor>;
};
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/acking.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/acking.hpp b/proton-c/bindings/cpp/include/proton/acking.hpp
index edc2d81..0001a4d 100644
--- a/proton-c/bindings/cpp/include/proton/acking.hpp
+++ b/proton-c/bindings/cpp/include/proton/acking.hpp
@@ -28,12 +28,19 @@
namespace proton {
+/** acking provides simple functions to acknowledge, or settle, a delivery */
class acking
{
public:
+ /** accept a delivery */
PN_CPP_EXTERN virtual void accept(delivery &d);
+ /** reject a delivery */
PN_CPP_EXTERN virtual void reject(delivery &d);
+ /** release a delivery. Mark it delivery::MODIFIED if it has already been delivered,
+ * delivery::RELEASED otherwise.
+ */
PN_CPP_EXTERN virtual void release(delivery &d, bool delivered=true);
+ /** settle a delivery with the given delivery::state */
PN_CPP_EXTERN virtual void settle(delivery &d, delivery::state s = delivery::REJECTED);
};
@@ -41,3 +48,5 @@ class acking
}
#endif /*!PROTON_CPP_ACKING_H*/
+
+
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/blocking_connection.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/blocking_connection.hpp b/proton-c/bindings/cpp/include/proton/blocking_connection.hpp
index 27d7cdd..9aa456f 100644
--- a/proton-c/bindings/cpp/include/proton/blocking_connection.hpp
+++ b/proton-c/bindings/cpp/include/proton/blocking_connection.hpp
@@ -33,13 +33,14 @@
struct pn_connection_t;
namespace proton {
-
+class url;
class container;
class blocking_connection_impl;
class ssl_domain;
class blocking_sender;
class wait_condition;
+// TODO documentation
class blocking_connection : public handle<blocking_connection_impl>
{
public:
@@ -48,11 +49,11 @@ class blocking_connection : public handle<blocking_connection_impl>
PN_CPP_EXTERN blocking_connection& operator=(const blocking_connection& c);
PN_CPP_EXTERN ~blocking_connection();
- PN_CPP_EXTERN blocking_connection(std::string &url, duration = duration::FOREVER,
- ssl_domain *ssld=0, container *c=0);
+ PN_CPP_EXTERN blocking_connection(const proton::url &url, duration = duration::FOREVER,
+ ssl_domain *ssld=0, container *c=0);
PN_CPP_EXTERN void close();
- PN_CPP_EXTERN blocking_sender create_sender(std::string &address, handler *h=0);
+ PN_CPP_EXTERN blocking_sender create_sender(const std::string &address, handler *h=0);
PN_CPP_EXTERN void wait(wait_condition &condition);
PN_CPP_EXTERN void wait(wait_condition &condition, std::string &msg, duration timeout=duration::FOREVER);
PN_CPP_EXTERN duration timeout();
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/blocking_link.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/blocking_link.hpp b/proton-c/bindings/cpp/include/proton/blocking_link.hpp
index c1872a4..0fe5e9a 100644
--- a/proton-c/bindings/cpp/include/proton/blocking_link.hpp
+++ b/proton-c/bindings/cpp/include/proton/blocking_link.hpp
@@ -35,6 +35,7 @@ namespace proton {
class blocking_connection;
+// TODO documentation
class blocking_link
{
public:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/blocking_sender.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/blocking_sender.hpp b/proton-c/bindings/cpp/include/proton/blocking_sender.hpp
index 0df5a9c..0fa89d9 100644
--- a/proton-c/bindings/cpp/include/proton/blocking_sender.hpp
+++ b/proton-c/bindings/cpp/include/proton/blocking_sender.hpp
@@ -37,6 +37,7 @@ namespace proton {
class blocking_connection;
class blocking_link;
+// TODO documentation
class blocking_sender : public blocking_link
{
public:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/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
new file mode 100644
index 0000000..70260b7
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/config.hpp
@@ -0,0 +1,30 @@
+#ifndef CONFIG_HPP
+#define 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
+ * 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.
+ */
+
+/**@file
+ * @internal
+ */
+
+#if (defined(__cplusplus) && __cplusplus >= 201100) || (defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 150030729)
+#define USE_CPP11
+#endif
+
+#endif // CONFIG_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/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 9998a0a..af3c585 100644
--- a/proton-c/bindings/cpp/include/proton/connection.hpp
+++ b/proton-c/bindings/cpp/include/proton/connection.hpp
@@ -36,6 +36,7 @@ class handler;
class transport;
class connection_impl;
+/** connection is the local end of a connectoin to a remote AMQP peer. */
class connection : public endpoint, public handle<connection_impl>
{
public:
@@ -47,15 +48,32 @@ class connection : public endpoint, public handle<connection_impl>
PN_CPP_EXTERN connection& operator=(const connection& c);
+ ///@name getters @{
PN_CPP_EXTERN class transport& transport();
PN_CPP_EXTERN handler *override();
- PN_CPP_EXTERN void override(handler *h);
- PN_CPP_EXTERN void open();
- PN_CPP_EXTERN void close();
PN_CPP_EXTERN pn_connection_t *pn_connection();
PN_CPP_EXTERN class container &container();
PN_CPP_EXTERN std::string hostname();
- PN_CPP_EXTERN link link_head(endpoint::State mask);
+ ///@}
+
+ /** override the handler for this connection */
+ PN_CPP_EXTERN void override(handler *h);
+
+ /** Initiate local open, not complete till messaging_handler::on_connection_opened()
+ * or proton_handler::on_connection_remote_open()
+ */
+ PN_CPP_EXTERN void open();
+
+ /** Initiate local close, not complete till messaging_handler::on_connection_closed()
+ * or proton_handler::on_connection_remote_close()
+ */
+ PN_CPP_EXTERN void close();
+
+ /** Get the first link on this connection matching the state mask.
+ * @see link::next, endpoint::state
+ */
+ PN_CPP_EXTERN link link_head(endpoint::state mask);
+
private:
friend class private_impl_ref<connection>;
friend class connector;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/container.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/container.hpp b/proton-c/bindings/cpp/include/proton/container.hpp
index 2aaa289..ec55167 100644
--- a/proton-c/bindings/cpp/include/proton/container.hpp
+++ b/proton-c/bindings/cpp/include/proton/container.hpp
@@ -40,35 +40,70 @@ class messaging_handler;
class sender;
class receiver;
class link;
- class handler;
+class handler;
+/** Top level container for connections and other objects, runs the event loop */
class container : public handle<container_impl>
{
public:
+ ///@name internal @internal @{
PN_CPP_EXTERN container(container_impl *);
PN_CPP_EXTERN container(const container& c);
PN_CPP_EXTERN container& operator=(const container& c);
PN_CPP_EXTERN ~container();
+ ///@}
+ /** Create a container */
PN_CPP_EXTERN container();
+
+ /** Create a container and set the top-level messaging_handler */
PN_CPP_EXTERN container(messaging_handler &mhandler);
+
+ /** Locally open a connection @see connection::open */
PN_CPP_EXTERN connection connect(const proton::url&, handler *h=0);
+
+ /** Run the event loop, return when all connections and acceptors are closed. */
PN_CPP_EXTERN void run();
+
+ /** Start the reactor, you must call process() to process events */
PN_CPP_EXTERN void start();
+
+ /** Process events, return true if there are more events to process. */
PN_CPP_EXTERN bool process();
+
+ /** Stop the reactor, causes run() to return and process() to return false. */
PN_CPP_EXTERN void stop();
- PN_CPP_EXTERN void wakeup();
- PN_CPP_EXTERN bool is_quiesced();
- PN_CPP_EXTERN pn_reactor_t *reactor();
- PN_CPP_EXTERN sender create_sender(connection &connection, std::string &addr, handler *h=0);
+
+ /** Create a sender on connection with target=addr and optional handler h */
+ PN_CPP_EXTERN sender create_sender(connection &connection, const std::string &addr, handler *h=0);
+
+ /** Open a connection to url and create a sender with target=url.path() */
PN_CPP_EXTERN sender create_sender(const proton::url &);
- PN_CPP_EXTERN receiver create_receiver(connection &connection, std::string &addr);
+
+ /** Create a receiver on connection with target=addr and optional handler h */
+ PN_CPP_EXTERN receiver create_receiver(connection &connection, const std::string &addr, handler *h=0);
+
+ /** Create a receiver on connection with source=addr and optional handler h */
PN_CPP_EXTERN receiver create_receiver(const url &);
+
+ /** Open a connection to url and create a receiver with source=url.path() */
PN_CPP_EXTERN acceptor listen(const proton::url &);
+
+ /// Identifier for the container
PN_CPP_EXTERN std::string container_id();
+
+ /// Get timeout, process() will return if there is no activity within the timeout.
PN_CPP_EXTERN duration timeout();
+
+ /// Set timeout, process() will return if there is no activity within the timeout.
PN_CPP_EXTERN void timeout(duration timeout);
- private:
+
+ /// Get the reactor
+ PN_CPP_EXTERN pn_reactor_t *reactor();
+
+ PN_CPP_EXTERN void wakeup();
+ PN_CPP_EXTERN bool is_quiesced();
+private:
friend class private_impl_ref<container>;
};
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/data.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/data.hpp b/proton-c/bindings/cpp/include/proton/data.hpp
index c0d3e8c..638315a 100644
--- a/proton-c/bindings/cpp/include/proton/data.hpp
+++ b/proton-c/bindings/cpp/include/proton/data.hpp
@@ -26,7 +26,7 @@ struct pn_data_t;
namespace proton {
-/** Base for classes that hold AMQP data. */
+/** Base for classes that hold AMQP data, not for direct use. @see value, encoder, decoder. */
class data {
public:
PN_CPP_EXTERN explicit data();
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/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 22effe3..6761653 100644
--- a/proton-c/bindings/cpp/include/proton/decoder.hpp
+++ b/proton-c/bindings/cpp/include/proton/decoder.hpp
@@ -29,13 +29,13 @@ namespace proton {
class value;
-/** Raised by decoder operations on error. @ingroup cpp*/
+/** Raised by decoder operations on error.*/
struct decode_error : public error { PN_CPP_EXTERN explicit decode_error(const std::string&) throw(); };
-/** Skips a value with `decoder >> skip()`. @ingroup cpp */
+/** Skips a value with `decoder >> skip()`. */
struct skip{};
-/** Rewind the decoder with `decoder >> rewind()`. @ingroup cpp */
+/** Rewind the decoder with `decoder >> rewind()`. */
struct rewind{};
/**
@@ -64,7 +64,7 @@ struct rewind{};
* extracting AMQP maps.
*
* You can also extract container values element-by-element, see decoder::operator>>(decoder&, start&)
- * @ingroup cpp
+ *
*/
class decoder : public virtual data {
public:
@@ -126,7 +126,7 @@ class decoder : public virtual data {
template <class T, type_id A> T get_as() { T value; *this >> as<A>(value); return value; }
/** Call decoder::start() in constructor, decoder::finish in destructor().
- * @ingroup cpp
+ *
*/
struct scope : public start {
decoder& decoder_;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/delivery.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/delivery.hpp b/proton-c/bindings/cpp/include/proton/delivery.hpp
index 0dc80da..3f4dafc 100644
--- a/proton-c/bindings/cpp/include/proton/delivery.hpp
+++ b/proton-c/bindings/cpp/include/proton/delivery.hpp
@@ -29,17 +29,19 @@
namespace proton {
+/** delivery status of a message */
class delivery : public proton_handle<pn_delivery_t>
{
public:
+ /** Delivery state of a message */
enum state {
- NONE = 0,
- RECEIVED = PN_RECEIVED,
- ACCEPTED = PN_ACCEPTED,
- REJECTED = PN_REJECTED,
- RELEASED = PN_RELEASED,
- MODIFIED = PN_MODIFIED
+ NONE = 0, ///< Unknown state
+ RECEIVED = PN_RECEIVED, ///< Received but not yet settled
+ ACCEPTED = PN_ACCEPTED, ///< Settled as accepted
+ REJECTED = PN_REJECTED, ///< Settled as rejected
+ RELEASED = PN_RELEASED, ///< Settled as released
+ MODIFIED = PN_MODIFIED ///< Settled as modified
}; // AMQP spec 3.4 delivery State
PN_CPP_EXTERN delivery(pn_delivery_t *d);
@@ -47,8 +49,15 @@ class delivery : public proton_handle<pn_delivery_t>
PN_CPP_EXTERN ~delivery();
PN_CPP_EXTERN delivery(const delivery&);
PN_CPP_EXTERN delivery& operator=(const delivery&);
+
+ /** Return true if the delivery has been settled. */
PN_CPP_EXTERN bool settled();
+
+ /** Settle the delivery, informs the remote end. */
PN_CPP_EXTERN void settle();
+
+ // TODO aconway 2015-07-15: add update() here?
+
PN_CPP_EXTERN pn_delivery_t *pn_delivery();
private:
friend class proton_impl_ref<delivery>;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/duration.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/duration.hpp b/proton-c/bindings/cpp/include/proton/duration.hpp
index b5bd59b..8b7d1ad 100644
--- a/proton-c/bindings/cpp/include/proton/duration.hpp
+++ b/proton-c/bindings/cpp/include/proton/duration.hpp
@@ -27,9 +27,7 @@
namespace proton {
-/** @ingroup cpp
- * A duration is a time in milliseconds.
- */
+/** Duration in milliseconds. */
class duration : public comparable<duration>
{
public:
@@ -39,10 +37,10 @@ class duration : public comparable<duration>
bool operator<(duration d) { return milliseconds < d.milliseconds; }
bool operator==(duration d) { return milliseconds == d.milliseconds; }
- PN_CPP_EXTERN static const duration FOREVER;
- PN_CPP_EXTERN static const duration IMMEDIATE;
- PN_CPP_EXTERN static const duration SECOND;
- PN_CPP_EXTERN static const duration MINUTE;
+ PN_CPP_EXTERN static const duration FOREVER; ///< Wait for ever
+ PN_CPP_EXTERN static const duration IMMEDIATE; ///< Don't wait at all
+ PN_CPP_EXTERN static const duration SECOND; ///< One second
+ PN_CPP_EXTERN static const duration MINUTE; ///< One minute
};
inline duration operator*(duration d, std::uint64_t n) { return duration(d.milliseconds*n); }
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/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 57f3c45..b3e2ab4 100644
--- a/proton-c/bindings/cpp/include/proton/encoder.hpp
+++ b/proton-c/bindings/cpp/include/proton/encoder.hpp
@@ -25,8 +25,6 @@
#include "proton/type_traits.hpp"
#include <iosfwd>
-#include <iostream> // FIXME aconway 2015-06-18:
-
struct pn_data_t;
namespace proton {
@@ -60,7 +58,6 @@ struct encode_error : public error { PN_CPP_EXTERN explicit encode_error(const s
* You can also insert containers element-by-element, see operator<<(encoder&, const start&)
*
*@throw decoder::error if the curent value is not a container type.
- *@ingroup cpp
*/
class encoder : public virtual data {
public:
@@ -137,7 +134,7 @@ class encoder : public virtual data {
template <class T> friend encoder& operator<<(encoder&, cref<T, ARRAY>);
template <class T> friend encoder& operator<<(encoder&, cref<T, LIST>);
template <class T> friend encoder& operator<<(encoder&, cref<T, MAP>);
- // TODO aconway 2015-06-16: DESCRIBED.
+ // TODO aconway 2015-06-16: described values.
///@}
/** Copy data from a raw pn_data_t */
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/endpoint.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/endpoint.hpp b/proton-c/bindings/cpp/include/proton/endpoint.hpp
index 89904ba..11970c7 100644
--- a/proton-c/bindings/cpp/include/proton/endpoint.hpp
+++ b/proton-c/bindings/cpp/include/proton/endpoint.hpp
@@ -30,21 +30,36 @@ class handler;
class connection;
class transport;
+/** endpoint is a base class for session, connection and link */
class endpoint
{
public:
- enum {
- LOCAL_UNINIT = PN_LOCAL_UNINIT,
- REMOTE_UNINIT = PN_REMOTE_UNINIT,
- LOCAL_ACTIVE = PN_LOCAL_ACTIVE,
- REMOTE_ACTIVE = PN_REMOTE_ACTIVE,
- LOCAL_CLOSED = PN_LOCAL_CLOSED,
- REMOTE_CLOSED = PN_REMOTE_CLOSED
- };
- typedef int State;
+ /** state is a bit mask of state_bit values.
+ *
+ * A state mask is matched against an endpoint as follows: If the state mask
+ * contains both local and remote flags, then an exact match against those
+ * flags is performed. If state contains only local or only remote flags,
+ * then a match occurs if any of the local or remote flags are set
+ * respectively.
+ *
+ * @see connection::link_head, connection::session_head, link::next, session::next
+ */
+ typedef int state;
+
+ /// endpoint state bit values @{
+ static const int LOCAL_UNINIT; ///< Local endpoint is un-initialized
+ static const int REMOTE_UNINIT; ///< Remote endpoint is un-initialized
+ static const int LOCAL_ACTIVE; ///< Local endpoint is active
+ static const int REMOTE_ACTIVE; ///< Remote endpoint is active
+ static const int LOCAL_CLOSED; ///< Local endpoint has been closed
+ static const int REMOTE_CLOSED; ///< Remote endpoint has been closed
+ static const int LOCAL_MASK; ///< Mask including all LOCAL_ bits (UNINIT, ACTIVE, CLOSED)
+ static const int REMOTE_MASK; ///< Mask including all REMOTE_ bits (UNINIT, ACTIVE, CLOSED)
+ ///@}
// TODO: condition, remote_condition, update_condition, get/handler
-protected:
+
+ protected:
PN_CPP_EXTERN endpoint();
PN_CPP_EXTERN ~endpoint();
};
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/error.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/error.hpp b/proton-c/bindings/cpp/include/proton/error.hpp
index 2e2ac17..6432b71 100644
--- a/proton-c/bindings/cpp/include/proton/error.hpp
+++ b/proton-c/bindings/cpp/include/proton/error.hpp
@@ -27,11 +27,12 @@
namespace proton {
-/** @ingroup cpp
- * Functions in the proton namespace throw a subclass of proton::error on error.
- */
+/** Functions in the proton namespace throw a subclass of proton::error on error. */
struct error : public std::runtime_error { PN_CPP_EXTERN explicit error(const std::string&) throw(); };
+/** Raised if timeout expires */
+struct timeout_error : public error { PN_CPP_EXTERN explicit timeout_error(const std::string&) throw(); };
+
/** Raised if a message is rejected */
struct message_reject : public error { PN_CPP_EXTERN explicit message_reject(const std::string&) throw(); };
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/event.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/event.hpp b/proton-c/bindings/cpp/include/proton/event.hpp
index 2feff2b..c4c5d7c 100644
--- a/proton-c/bindings/cpp/include/proton/event.hpp
+++ b/proton-c/bindings/cpp/include/proton/event.hpp
@@ -34,20 +34,32 @@ class handler;
class container;
class connection;
-class event
-{
+/** Context information about a proton event */
+class event {
public:
+ virtual PN_CPP_EXTERN ~event();
+
+ /// Dispatch this event to a handler.
virtual PN_CPP_EXTERN void dispatch(handler &h) = 0;
+
+ /// Get container.
virtual PN_CPP_EXTERN class container &container();
+ /// Get connection.
virtual PN_CPP_EXTERN class connection &connection();
+ /// Get sender @throws error if no sender.
virtual PN_CPP_EXTERN class sender sender();
+ /// Get receiver @throws error if no receiver.
virtual PN_CPP_EXTERN class receiver receiver();
+ /// Get link @throws error if no link.
virtual PN_CPP_EXTERN class link link();
+ /// Get message @throws error if no message.
virtual PN_CPP_EXTERN class message message();
- virtual PN_CPP_EXTERN void message(class message &);
- virtual PN_CPP_EXTERN ~event();
+ /// Get message @throws error if no message.
+ virtual PN_CPP_EXTERN void message(class message&);
+
protected:
PN_CPP_EXTERN event();
+
private:
event(const event&);
event& operator=(const event&);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/export.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/export.hpp b/proton-c/bindings/cpp/include/proton/export.hpp
index 0be5187..bb211ae 100644
--- a/proton-c/bindings/cpp/include/proton/export.hpp
+++ b/proton-c/bindings/cpp/include/proton/export.hpp
@@ -22,6 +22,7 @@
*
*/
+/// Internal: import/export macros @cond INTERNAL
#if defined(WIN32) && !defined(PN_CPP_DECLARE_STATIC)
//
// Import and Export definitions for Windows:
@@ -42,5 +43,6 @@
#else
# define PN_CPP_EXTERN PN_CPP_IMPORT
#endif
+///@endcond
#endif /*!PN_CPP_IMPORTEXPORT_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/handle.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/handle.hpp b/proton-c/bindings/cpp/include/proton/handle.hpp
index 0a23b01..e0542ef 100644
--- a/proton-c/bindings/cpp/include/proton/handle.hpp
+++ b/proton-c/bindings/cpp/include/proton/handle.hpp
@@ -26,10 +26,10 @@
namespace proton {
+///@cond INTERNAL
template <class> class private_impl_ref;
template <class> class proton_impl_ref;
-
-// FIXME aconway 2015-06-09: don't need handle, get rid of it.
+///@endcond INTERNAL
/**
* A handle is like a pointer: refers to an underlying implementation object.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/handler.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/handler.hpp b/proton-c/bindings/cpp/include/proton/handler.hpp
index eb019e3..cb4ff81 100644
--- a/proton-c/bindings/cpp/include/proton/handler.hpp
+++ b/proton-c/bindings/cpp/include/proton/handler.hpp
@@ -28,14 +28,19 @@
namespace proton {
+/// Base class for event handlers.
+/// Handlers form a tree, a handler is a vector of pointers to child handlers.
class handler : public std::vector<handler*> {
public:
PN_CPP_EXTERN handler();
PN_CPP_EXTERN virtual ~handler();
+ /// Called if a handler function is not over-ridden to handle an event.
PN_CPP_EXTERN virtual void on_unhandled(event &e);
- PN_CPP_EXTERN virtual void add_child_handler(handler &e);
+ /// Add a child handler, equivalent to this->push_back(&h)
+ /// h must not be deleted before this handler.
+ PN_CPP_EXTERN virtual void add_child_handler(handler &h);
};
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/link.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/link.hpp b/proton-c/bindings/cpp/include/proton/link.hpp
index ba17584..feabfec 100644
--- a/proton-c/bindings/cpp/include/proton/link.hpp
+++ b/proton-c/bindings/cpp/include/proton/link.hpp
@@ -32,6 +32,7 @@ struct pn_connection_t;
namespace proton {
+/** Messages are transferred across a link. Base class for sender, receiver. */
class link : public endpoint, public proton_handle<pn_link_t>
{
public:
@@ -40,20 +41,42 @@ class link : public endpoint, public proton_handle<pn_link_t>
PN_CPP_EXTERN ~link();
PN_CPP_EXTERN link(const link&);
PN_CPP_EXTERN link& operator=(const link&);
+
+ /** Locally open the link, not complete till messaging_handler::on_link_opened or
+ * proton_handler::link_remote_open
+ */
PN_CPP_EXTERN void open();
+
+ /** Locally close the link, not complete till messaging_handler::on_link_closeed or
+ * proton_handler::link_remote_close
+ */
PN_CPP_EXTERN void close();
+
+ /** True if link is a sender */
PN_CPP_EXTERN bool is_sender();
+ /** True if link is a receiver */
PN_CPP_EXTERN bool is_receiver();
+ /** Credit available on the link */
PN_CPP_EXTERN int credit();
+ /** Local source of the link */
PN_CPP_EXTERN terminus source();
+ /** Local target of the link */
PN_CPP_EXTERN terminus target();
+ /** Remote source of the link */
PN_CPP_EXTERN terminus remote_source();
+ /** Remote source of the link */
PN_CPP_EXTERN terminus remote_target();
+ /** Link name */
PN_CPP_EXTERN std::string name();
- PN_CPP_EXTERN pn_link_t *pn_link() const;
- PN_CPP_EXTERN link next(endpoint::State mask);
+
+ /** Next link that matches state mask. @see endpoint::state */
+ PN_CPP_EXTERN link next(endpoint::state mask);
+
+ /** Connection of the link */
PN_CPP_EXTERN class connection &connection();
+ PN_CPP_EXTERN pn_link_t *pn_link() const;
+
protected:
PN_CPP_EXTERN virtual void verify_type(pn_link_t *l);
private:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/message.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/message.hpp b/proton-c/bindings/cpp/include/proton/message.hpp
index 0667337..528088b 100644
--- a/proton-c/bindings/cpp/include/proton/message.hpp
+++ b/proton-c/bindings/cpp/include/proton/message.hpp
@@ -32,7 +32,7 @@ struct pn_data_t;
namespace proton {
-// FIXME aconway 2015-06-17: documentation of properties.
+/// An AMQP message.
class message : public proton_handle<pn_message_t>
{
public:
@@ -44,7 +44,15 @@ class message : public proton_handle<pn_message_t>
PN_CPP_EXTERN pn_message_t *pn_message() const;
+ /** Clear the message content */
+ PN_CPP_EXTERN void clear();
+
+ ///@name Message properties
+ ///@{
+
+ /// Globally unique identifier, can be an a string, an unsigned long, a uuid or a binary value.
PN_CPP_EXTERN void id(const value& id);
+ /// Globally unique identifier, can be an a string, an unsigned long, a uuid or a binary value.
PN_CPP_EXTERN value id() const;
PN_CPP_EXTERN void user(const std::string &user);
@@ -59,7 +67,9 @@ class message : public proton_handle<pn_message_t>
PN_CPP_EXTERN void reply_to(const std::string &s);
PN_CPP_EXTERN std::string reply_to() const;
+ /// Correlation identifier, can be an a string, an unsigned long, a uuid or a binary value.
PN_CPP_EXTERN void correlation_id(const value&);
+ /// Correlation identifier, can be an a string, an unsigned long, a uuid or a binary value.
PN_CPP_EXTERN value correlation_id() const;
PN_CPP_EXTERN void content_type(const std::string &s);
@@ -77,29 +87,35 @@ class message : public proton_handle<pn_message_t>
PN_CPP_EXTERN void group_id(const std::string &s);
PN_CPP_EXTERN std::string group_id() const;
- PN_CPP_EXTERN void reply_togroup_id(const std::string &s);
- PN_CPP_EXTERN std::string reply_togroup_id() const;
+ PN_CPP_EXTERN void reply_to_group_id(const std::string &s);
+ PN_CPP_EXTERN std::string reply_to_group_id() const;
+ ///@}
- /** Set the body to an AMQP value. */
+ /** Set the body to a proton::value. */
PN_CPP_EXTERN void body(const value&);
- /** Template to convert any type to a value and set as the body */
+ /** Set the body to any type T that can be converted to a proton::value */
template <class T> void body(const T& v) { body(value(v)); }
- /** Set the body to a sequence of sections containing AMQP values. */
+ /** Set the body to a sequence of values, each value is encoded as an AMQP section. */
PN_CPP_EXTERN void body(const values&);
+ /** Get the body values, there may be more than one. */
PN_CPP_EXTERN const values& body() const;
- PN_CPP_EXTERN values& body(); ///< Allows in-place modification of body sections.
+ /** Get a reference to the body, can be modified in-place. */
+ PN_CPP_EXTERN values& body();
- // FIXME aconway 2015-06-17: consistent and flexible treatment of buffers.
+ // TODO aconway 2015-06-17: consistent and flexible treatment of buffers.
// Allow convenient std::string encoding/decoding (with re-use of existing
// string capacity) but also need to allow encoding/decoding of non-string
// buffers. Introduce a buffer type with begin/end pointers?
+ /** Encode the message into string data */
PN_CPP_EXTERN void encode(std::string &data);
+ /** Retrun encoded message as a string */
PN_CPP_EXTERN std::string encode();
+ /** Decode from string data into the message. */
PN_CPP_EXTERN void decode(const std::string &data);
private:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/messaging_adapter.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/messaging_adapter.hpp b/proton-c/bindings/cpp/include/proton/messaging_adapter.hpp
index 3486b97..8744c95 100644
--- a/proton-c/bindings/cpp/include/proton/messaging_adapter.hpp
+++ b/proton-c/bindings/cpp/include/proton/messaging_adapter.hpp
@@ -29,6 +29,8 @@
#include "proton/event.h"
#include "proton/reactor.h"
+///@cond INTERNAL
+
namespace proton {
// Combine's Python's: endpoint_state_handler, incoming_message_handler, outgoing_message_handler
@@ -72,5 +74,5 @@ class messaging_adapter : public messaging_handler
};
}
-
+///@endcond INTERNAL
#endif /*!PROTON_CPP_MESSAGING_ADAPTER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/messaging_event.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/messaging_event.hpp b/proton-c/bindings/cpp/include/proton/messaging_event.hpp
index 62f0160..950c389 100644
--- a/proton-c/bindings/cpp/include/proton/messaging_event.hpp
+++ b/proton-c/bindings/cpp/include/proton/messaging_event.hpp
@@ -30,54 +30,59 @@ class handler;
class container;
class connection;
-typedef enum {
- PN_MESSAGING_PROTON = 0, // Wrapped pn_event_t
- // Covenience events for C++ messaging_handlers
- PN_MESSAGING_ABORT,
- PN_MESSAGING_ACCEPTED,
- PN_MESSAGING_COMMIT,
- PN_MESSAGING_CONNECTION_CLOSED,
- PN_MESSAGING_CONNECTION_CLOSING,
- PN_MESSAGING_CONNECTION_ERROR,
- PN_MESSAGING_CONNECTION_OPENED,
- PN_MESSAGING_CONNECTION_OPENING,
- PN_MESSAGING_DISCONNECTED,
- PN_MESSAGING_FETCH,
- PN_MESSAGING_Id_LOADED,
- PN_MESSAGING_LINK_CLOSED,
- PN_MESSAGING_LINK_CLOSING,
- PN_MESSAGING_LINK_OPENED,
- PN_MESSAGING_LINK_OPENING,
- PN_MESSAGING_LINK_ERROR,
- PN_MESSAGING_MESSAGE,
- PN_MESSAGING_QUIT,
- PN_MESSAGING_RECORD_INSERTED,
- PN_MESSAGING_RECORDS_LOADED,
- PN_MESSAGING_REJECTED,
- PN_MESSAGING_RELEASED,
- PN_MESSAGING_REQUEST,
- PN_MESSAGING_RESPONSE,
- PN_MESSAGING_SENDABLE,
- PN_MESSAGING_SESSION_CLOSED,
- PN_MESSAGING_SESSION_CLOSING,
- PN_MESSAGING_SESSION_OPENED,
- PN_MESSAGING_SESSION_OPENING,
- PN_MESSAGING_SESSION_ERROR,
- PN_MESSAGING_SETTLED,
- PN_MESSAGING_START,
- PN_MESSAGING_TIMER,
- PN_MESSAGING_TRANSACTION_ABORTED,
- PN_MESSAGING_TRANSACTION_COMMITTED,
- PN_MESSAGING_TRANSACTION_DECLARED,
- PN_MESSAGING_TRANSPORT_CLOSED
-} messaging_event_type_t;
-
+/** An event for the proton::messaging_handler */
class messaging_event : public proton_event
{
public:
+
+ // TODO aconway 2015-07-16: document meaning of each event type.
+
+ /** Event types for a messaging_handler */
+ enum event_type {
+ PROTON = 0, // Wrapped pn_event_t
+ ABORT,
+ ACCEPTED,
+ COMMIT,
+ CONNECTION_CLOSED,
+ CONNECTION_CLOSING,
+ CONNECTION_ERROR,
+ CONNECTION_OPENED,
+ CONNECTION_OPENING,
+ DISCONNECTED,
+ FETCH,
+ ID_LOADED,
+ LINK_CLOSED,
+ LINK_CLOSING,
+ LINK_OPENED,
+ LINK_OPENING,
+ LINK_ERROR,
+ MESSAGE,
+ QUIT,
+ RECORD_INSERTED,
+ RECORDS_LOADED,
+ REJECTED,
+ RELEASED,
+ REQUEST,
+ RESPONSE,
+ SENDABLE,
+ SESSION_CLOSED,
+ SESSION_CLOSING,
+ SESSION_OPENED,
+ SESSION_OPENING,
+ SESSION_ERROR,
+ SETTLED,
+ START,
+ TIMER,
+ TRANSACTION_ABORTED,
+ TRANSACTION_COMMITTED,
+ TRANSACTION_DECLARED,
+ TRANSPORT_CLOSED
+ };
+
messaging_event(pn_event_t *ce, pn_event_type_t t, class container &c);
- messaging_event(messaging_event_type_t t, proton_event &parent);
+ messaging_event(event_type t, proton_event &parent);
~messaging_event();
+
virtual PN_CPP_EXTERN void dispatch(handler &h);
virtual PN_CPP_EXTERN class connection &connection();
virtual PN_CPP_EXTERN class sender sender();
@@ -85,8 +90,10 @@ class messaging_event : public proton_event
virtual PN_CPP_EXTERN class link link();
virtual PN_CPP_EXTERN class message message();
virtual PN_CPP_EXTERN void message(class message &);
+ PN_CPP_EXTERN event_type type() const;
+
private:
- messaging_event_type_t messaging_type_;
+ event_type type_;
proton_event *parent_event_;
class message *message_;
messaging_event operator=(const messaging_event&);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/messaging_handler.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/messaging_handler.hpp b/proton-c/bindings/cpp/include/proton/messaging_handler.hpp
index 946b9b5..7de6ebd 100644
--- a/proton-c/bindings/cpp/include/proton/messaging_handler.hpp
+++ b/proton-c/bindings/cpp/include/proton/messaging_handler.hpp
@@ -31,13 +31,27 @@ namespace proton {
class event;
class messaging_adapter;
+/** messaging_handler base class. Provides a simpler set of events than
+ * proton::proton_handler and automates some common tasks. Subclass and
+ * over-ride event handling member functions.
+ * @see proton::messaging_event for meaning of events.
+ */
class messaging_handler : public proton_handler , public acking
{
public:
+ /** Create a messaging_handler
+ *@param prefetch set flow control to automatically pre-fetch this many messages
+ *@param auto_accept automatically accept received messages after on_message()
+ *@param auto_settle automatically settle on receipt of delivery for sent messages.
+ *@param peer_close_is_error treat orderly remote connection close as error.
+ */
PN_CPP_EXTERN messaging_handler(int prefetch=10, bool auto_accept=true, bool auto_settle=true,
- bool peer_close_is_error=false);
+ bool peer_close_is_error=false);
+
PN_CPP_EXTERN virtual ~messaging_handler();
+ ///@name Over-ride these member functions to handle events
+ ///@{
PN_CPP_EXTERN virtual void on_abort(event &e);
PN_CPP_EXTERN virtual void on_accepted(event &e);
PN_CPP_EXTERN virtual void on_commit(event &e);
@@ -75,8 +89,9 @@ class messaging_handler : public proton_handler , public acking
PN_CPP_EXTERN virtual void on_transaction_committed(event &e);
PN_CPP_EXTERN virtual void on_transaction_declared(event &e);
PN_CPP_EXTERN virtual void on_transport_closed(event &e);
+ ///@}
- private:
+ private:
int prefetch_;
bool auto_accept_;
bool auto_settle_;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/proton_event.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/proton_event.hpp b/proton-c/bindings/cpp/include/proton/proton_event.hpp
index c4bd5e8..4a0a012 100644
--- a/proton-c/bindings/cpp/include/proton/proton_event.hpp
+++ b/proton-c/bindings/cpp/include/proton/proton_event.hpp
@@ -31,22 +31,260 @@ class container;
class connection;
class container;
+/** Event information for a proton::proton_handler */
class proton_event : public event
{
public:
+
+ ///@name Event types
+ ///@{
+
+ /// The type of an event
+ typedef int event_type;
+
+ /**
+ * Defined as a programming convenience. No event of this type will
+ * ever be generated.
+ */
+ static const event_type EVENT_NONE;
+
+ /**
+ * A reactor has been started. Events of this type point to the reactor.
+ */
+ static const event_type REACTOR_INIT;
+
+ /**
+ * A reactor has no more events to process. Events of this type
+ * point to the reactor.
+ */
+ static const event_type REACTOR_QUIESCED;
+
+ /**
+ * A reactor has been stopped. Events of this type point to the reactor.
+ */
+ static const event_type REACTOR_FINAL;
+
+ /**
+ * A timer event has occurred.
+ */
+ static const event_type TIMER_TASK;
+
+ /**
+ * The connection has been created. This is the first event that
+ * will ever be issued for a connection. Events of this type point
+ * to the relevant connection.
+ */
+ static const event_type CONNECTION_INIT;
+
+ /**
+ * The connection has been bound to a transport. This event is
+ * issued when the transport::bind() is called.
+ */
+ static const event_type CONNECTION_BOUND;
+
+ /**
+ * The connection has been unbound from its transport. This event is
+ * issued when transport::unbind() is called.
+ */
+ static const event_type CONNECTION_UNBOUND;
+
+ /**
+ * The local connection endpoint has been closed. Events of this
+ * type point to the relevant connection.
+ */
+ static const event_type CONNECTION_LOCAL_OPEN;
+
+ /**
+ * The remote endpoint has opened the connection. Events of this
+ * type point to the relevant connection.
+ */
+ static const event_type CONNECTION_REMOTE_OPEN;
+
+ /**
+ * The local connection endpoint has been closed. Events of this
+ * type point to the relevant connection.
+ */
+ static const event_type CONNECTION_LOCAL_CLOSE;
+
+ /**
+ * The remote endpoint has closed the connection. Events of this
+ * type point to the relevant connection.
+ */
+ static const event_type CONNECTION_REMOTE_CLOSE;
+
+ /**
+ * The connection has been freed and any outstanding processing has
+ * been completed. This is the final event that will ever be issued
+ * for a connection.
+ */
+ static const event_type CONNECTION_FINAL;
+
+ /**
+ * The session has been created. This is the first event that will
+ * ever be issued for a session.
+ */
+ static const event_type SESSION_INIT;
+
+ /**
+ * The local session endpoint has been opened. Events of this type
+ * point ot the relevant session.
+ */
+ static const event_type SESSION_LOCAL_OPEN;
+
+ /**
+ * The remote endpoint has opened the session. Events of this type
+ * point to the relevant session.
+ */
+ static const event_type SESSION_REMOTE_OPEN;
+
+ /**
+ * The local session endpoint has been closed. Events of this type
+ * point ot the relevant session.
+ */
+ static const event_type SESSION_LOCAL_CLOSE;
+
+ /**
+ * The remote endpoint has closed the session. Events of this type
+ * point to the relevant session.
+ */
+ static const event_type SESSION_REMOTE_CLOSE;
+
+ /**
+ * The session has been freed and any outstanding processing has
+ * been completed. This is the final event that will ever be issued
+ * for a session.
+ */
+ static const event_type SESSION_FINAL;
+
+ /**
+ * The link has been created. This is the first event that will ever
+ * be issued for a link.
+ */
+ static const event_type LINK_INIT;
+
+ /**
+ * The local link endpoint has been opened. Events of this type
+ * point ot the relevant link.
+ */
+ static const event_type LINK_LOCAL_OPEN;
+
+ /**
+ * The remote endpoint has opened the link. Events of this type
+ * point to the relevant link.
+ */
+ static const event_type LINK_REMOTE_OPEN;
+
+ /**
+ * The local link endpoint has been closed. Events of this type
+ * point ot the relevant link.
+ */
+ static const event_type LINK_LOCAL_CLOSE;
+
+ /**
+ * The remote endpoint has closed the link. Events of this type
+ * point to the relevant link.
+ */
+ static const event_type LINK_REMOTE_CLOSE;
+
+ /**
+ * The local link endpoint has been detached. Events of this type
+ * point to the relevant link.
+ */
+ static const event_type LINK_LOCAL_DETACH;
+
+ /**
+ * The remote endpoint has detached the link. Events of this type
+ * point to the relevant link.
+ */
+ static const event_type LINK_REMOTE_DETACH;
+
+ /**
+ * The flow control state for a link has changed. Events of this
+ * type point to the relevant link.
+ */
+ static const event_type LINK_FLOW;
+
+ /**
+ * The link has been freed and any outstanding processing has been
+ * completed. This is the final event that will ever be issued for a
+ * link. Events of this type point to the relevant link.
+ */
+ static const event_type LINK_FINAL;
+
+ /**
+ * A delivery has been created or updated. Events of this type point
+ * to the relevant delivery.
+ */
+ static const event_type DELIVERY;
+
+ /**
+ * The transport has new data to read and/or write. Events of this
+ * type point to the relevant transport.
+ */
+ static const event_type TRANSPORT;
+
+ /**
+ * The transport has authenticated, if this is received by a server
+ * the associated transport has authenticated an incoming connection
+ * and transport::user() can be used to obtain the authenticated
+ * user.
+ */
+ static const event_type TRANSPORT_AUTHENTICATED;
+
+ /**
+ * Indicates that a transport error has occurred. Use
+ * transport::condition() to access the details of the error
+ * from the associated transport.
+ */
+ static const event_type TRANSPORT_ERROR;
+
+ /**
+ * Indicates that the head of the transport has been closed. This
+ * means the transport will never produce more bytes for output to
+ * the network. Events of this type point to the relevant transport.
+ */
+ static const event_type TRANSPORT_HEAD_CLOSED;
+
+ /**
+ * Indicates that the tail of the transport has been closed. This
+ * means the transport will never be able to process more bytes from
+ * the network. Events of this type point to the relevant transport.
+ */
+ static const event_type TRANSPORT_TAIL_CLOSED;
+
+ /**
+ * Indicates that the both the head and tail of the transport are
+ * closed. Events of this type point to the relevant transport.
+ */
+ static const event_type TRANSPORT_CLOSED;
+
+ static const event_type SELECTABLE_INIT;
+ static const event_type SELECTABLE_UPDATED;
+ static const event_type SELECTABLE_READABLE;
+ static const event_type SELECTABLE_WRITABLE;
+ static const event_type SELECTABLE_ERROR;
+ static const event_type SELECTABLE_EXPIRED;
+ static const event_type SELECTABLE_FINAL;
+
+ ///@}
+
virtual PN_CPP_EXTERN void dispatch(handler &h);
virtual PN_CPP_EXTERN class container &container();
virtual PN_CPP_EXTERN class connection &connection();
virtual PN_CPP_EXTERN class sender sender();
virtual PN_CPP_EXTERN class receiver receiver();
virtual PN_CPP_EXTERN class link link();
- PN_CPP_EXTERN int type();
+
+ /** Get type of event */
+ PN_CPP_EXTERN event_type type();
+
PN_CPP_EXTERN pn_event_t* pn_event();
+
protected:
PN_CPP_EXTERN proton_event(pn_event_t *ce, pn_event_type_t t, class container &c);
private:
pn_event_t *pn_event_;
- int type_;
+ event_type type_;
class container &container_;
};
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/proton_handle.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/proton_handle.hpp b/proton-c/bindings/cpp/include/proton/proton_handle.hpp
index 5799bf6..6fc9211 100644
--- a/proton-c/bindings/cpp/include/proton/proton_handle.hpp
+++ b/proton-c/bindings/cpp/include/proton/proton_handle.hpp
@@ -26,7 +26,9 @@
namespace proton {
+///@cond INTERNAL
template <class> class proton_impl_ref;
+///@endcond INTERNAL
/**
* See handle.h. Similar but for lightly wrapped Proton pn_object_t targets.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/proton_handler.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/proton_handler.hpp b/proton-c/bindings/cpp/include/proton/proton_handler.hpp
index 24384a8..2738f71 100644
--- a/proton-c/bindings/cpp/include/proton/proton_handler.hpp
+++ b/proton-c/bindings/cpp/include/proton/proton_handler.hpp
@@ -28,10 +28,15 @@ namespace proton {
class event;
class proton_event;
+/// Handler base class, subclass and over-ride event handling member functions.
+/// @see proton::proton_event for meaning of events.
class proton_handler : public handler
{
public:
PN_CPP_EXTERN proton_handler();
+
+ ///@name Over-ride these member functions to handle events
+ ///@{
PN_CPP_EXTERN virtual void on_reactor_init(event &e);
PN_CPP_EXTERN virtual void on_reactor_quiesced(event &e);
PN_CPP_EXTERN virtual void on_reactor_final(event &e);
@@ -72,8 +77,8 @@ class proton_handler : public handler
PN_CPP_EXTERN virtual void on_selectable_expired(event &e);
PN_CPP_EXTERN virtual void on_selectable_error(event &e);
PN_CPP_EXTERN virtual void on_selectable_final(event &e);
-
PN_CPP_EXTERN virtual void on_unhandled(event &e);
+ ///@}
};
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/receiver.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/receiver.hpp b/proton-c/bindings/cpp/include/proton/receiver.hpp
index be19358..4f2df0f 100644
--- a/proton-c/bindings/cpp/include/proton/receiver.hpp
+++ b/proton-c/bindings/cpp/include/proton/receiver.hpp
@@ -31,6 +31,7 @@ struct pn_connection_t;
namespace proton {
+/// A receiving link
class receiver : public link
{
public:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/sender.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/sender.hpp b/proton-c/bindings/cpp/include/proton/sender.hpp
index 1d35c42..3573a90 100644
--- a/proton-c/bindings/cpp/include/proton/sender.hpp
+++ b/proton-c/bindings/cpp/include/proton/sender.hpp
@@ -33,12 +33,14 @@ struct pn_connection_t;
namespace proton {
-
+/// A sending link
class sender : public link
{
public:
PN_CPP_EXTERN sender(pn_link_t *lnk=0);
PN_CPP_EXTERN sender(const link& c);
+
+ /// Send a message on the link.
PN_CPP_EXTERN delivery send(message &m);
protected:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/session.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/session.hpp b/proton-c/bindings/cpp/include/proton/session.hpp
index b0117c0..7f670b8 100644
--- a/proton-c/bindings/cpp/include/proton/session.hpp
+++ b/proton-c/bindings/cpp/include/proton/session.hpp
@@ -37,22 +37,37 @@ class container;
class handler;
class transport;
- class session : public endpoint, public proton_handle<pn_session_t>
+/** A session is a collection of links */
+class session : public endpoint, public proton_handle<pn_session_t>
{
public:
PN_CPP_EXTERN session(pn_session_t *s);
PN_CPP_EXTERN session();
- PN_CPP_EXTERN ~session();
- PN_CPP_EXTERN void open();
PN_CPP_EXTERN session(const session&);
+ PN_CPP_EXTERN ~session();
PN_CPP_EXTERN session& operator=(const session&);
+
+ /** Initiate local open, not complete till messaging_handler::on_session_opened()
+ * or proton_handler::on_session_remote_open()
+ */
+ PN_CPP_EXTERN void open();
+
+ /** Initiate local close, not complete till messaging_handler::on_session_closed()
+ * or proton_handler::on_session_remote_close()
+ */
PN_CPP_EXTERN void close();
- PN_CPP_EXTERN pn_session_t *pn_session();
+
+ /// Get connection
PN_CPP_EXTERN virtual class connection &connection();
- PN_CPP_EXTERN receiver create_receiver(std::string name);
- PN_CPP_EXTERN sender create_sender(std::string name);
+ /// Create a receiver link
+ PN_CPP_EXTERN receiver create_receiver(const std::string& name);
+ /// Create a sender link
+ PN_CPP_EXTERN sender create_sender(const std::string& name);
+
+ PN_CPP_EXTERN pn_session_t *pn_session();
+
private:
- friend class proton_impl_ref<session>;
+ friend class proton_impl_ref<session>;
};
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[2/3] qpid-proton git commit: PROTON-865: C++ binding API
documentation and cleanup.
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/terminus.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/terminus.hpp b/proton-c/bindings/cpp/include/proton/terminus.hpp
index 22c61d0..62fb960 100644
--- a/proton-c/bindings/cpp/include/proton/terminus.hpp
+++ b/proton-c/bindings/cpp/include/proton/terminus.hpp
@@ -31,22 +31,28 @@ namespace proton {
class link;
+/** A terminus represents one end of a link.
+ * The source terminus is where originate, the target terminus is where they go.
+ */
class terminus : public proton_handle<pn_terminus_t>
{
public:
+ /// Type of terminus
enum type_t {
TYPE_UNSPECIFIED = PN_UNSPECIFIED,
SOURCE = PN_SOURCE,
TARGET = PN_TARGET,
- COORDINATOR = PN_COORDINATOR
+ COORDINATOR = PN_COORDINATOR ///< Transaction co-ordinator
};
+ /// Expiry policy
enum expiry_policy_t {
NONDURABLE = PN_NONDURABLE,
CONFIGURATION = PN_CONFIGURATION,
DELIVERIES = PN_DELIVERIES
};
+ /// Distribution mode
enum distribution_mode_t {
MODE_UNSPECIFIED = PN_DIST_MODE_UNSPECIFIED,
COPY = PN_DIST_MODE_COPY,
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/transport.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/transport.hpp b/proton-c/bindings/cpp/include/proton/transport.hpp
index 8d0774f..6bb6f5b 100644
--- a/proton-c/bindings/cpp/include/proton/transport.hpp
+++ b/proton-c/bindings/cpp/include/proton/transport.hpp
@@ -31,11 +31,14 @@ namespace proton {
class connection;
+/** Represents a connection transport */
class transport
{
public:
PN_CPP_EXTERN transport();
PN_CPP_EXTERN ~transport();
+
+ /** Bind the transport to an AMQP connection */
PN_CPP_EXTERN void bind(connection &c);
class connection* connection() const { return connection_; }
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/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 4f02214..aa1f610 100644
--- a/proton-c/bindings/cpp/include/proton/type_traits.hpp
+++ b/proton-c/bindings/cpp/include/proton/type_traits.hpp
@@ -19,23 +19,19 @@
* under the License.
*/
-///@cond INTERNAL_DETAIL
+/**@file
+ * Internal: Type traits for mapping between AMQP and C++ types.
+ *
+ * Also provides workarounds for missing type_traits classes on older C++ compilers.
+ * @cond INTERNAL
+ */
#include "proton/types.hpp"
-#if defined(__cplusplus) && __cplusplus >= 201100
-#include <type_traits>
-#elif defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 150030729
+#ifdef USE_CPP11
#include <type_traits>
#else
-/**
- * Workaround missing std:: classes on older C++ compilers. NOTE: this is NOT a
- * full implementation of the standard c++11 types, it is the bare minimum
- * needed by this library.
- */
namespace std {
-
-
template <bool, class T=void> struct enable_if;
template <class T> struct enable_if<true, T> { typedef T type; };
@@ -123,7 +119,6 @@ template <class T> struct is_unknown_integer {
};
}
-
///@endcond
#endif // TYPE_TRAITS_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/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 f3adbf5..d5cf23c 100644
--- a/proton-c/bindings/cpp/include/proton/types.hpp
+++ b/proton-c/bindings/cpp/include/proton/types.hpp
@@ -21,7 +21,6 @@
/**@file
* Defines C++ types representing AMQP types.
- * @ingroup cpp
*/
#include "proton/export.hpp"
@@ -35,9 +34,7 @@
namespace proton {
-/** type_id identifies an AMQP type.
- *@ingroup cpp
- */
+/** type_id identifies an AMQP type. */
enum type_id {
NULl_=PN_NULL, ///< The null type, contains no data.
BOOL=PN_BOOL, ///< Boolean true or false.
@@ -66,8 +63,9 @@ enum type_id {
MAP=PN_MAP ///< A sequence of key:value pairs, may be of mixed types.
};
-///@internal
+/// Internal base class to provide comparison operators.
template <class T> struct comparable {};
+///@cond INTERNAL
template<class T> bool operator<(const comparable<T>& a, const comparable<T>& b) {
return static_cast<const T&>(a) < static_cast<const T&>(b); // operator < provided by type T
}
@@ -77,37 +75,38 @@ template<class T> bool operator>=(const comparable<T>& a, const comparable<T>& b
template<class T> bool operator==(const comparable<T>& a, const comparable<T>& b) { return a <= b && b <= a; }
template<class T> bool operator!=(const comparable<T>& a, const comparable<T>& b) { return !(a == b); }
-/// AMQP NULL type. @ingroup cpp
+PN_CPP_EXTERN pn_bytes_t pn_bytes(const std::string&);
+PN_CPP_EXTERN std::string str(const pn_bytes_t& b);
+///@endcond
+
+/// AMQP NULL type.
struct amqp_null {};
-/// AMQP boolean type. @ingroup cpp
+/// AMQP boolean type.
typedef bool amqp_bool;
-/// AMQP unsigned 8-bit type. @ingroup cpp
+/// AMQP unsigned 8-bit type.
typedef std::uint8_t amqp_ubyte;
-/// AMQP signed 8-bit integer type. @ingroup cpp
+/// AMQP signed 8-bit integer type.
typedef std::int8_t amqp_byte;
-/// AMQP unsigned 16-bit integer type. @ingroup cpp
+/// AMQP unsigned 16-bit integer type.
typedef std::uint16_t amqp_ushort;
-/// AMQP signed 16-bit integer type. @ingroup cpp
+/// AMQP signed 16-bit integer type.
typedef std::int16_t amqp_short;
-/// AMQP unsigned 32-bit integer type. @ingroup cpp
+/// AMQP unsigned 32-bit integer type.
typedef std::uint32_t amqp_uint;
-/// AMQP signed 32-bit integer type. @ingroup cpp
+/// AMQP signed 32-bit integer type.
typedef std::int32_t amqp_int;
-/// AMQP 32-bit unicode character type. @ingroup cpp
+/// AMQP 32-bit unicode character type.
typedef wchar_t amqp_char;
-/// AMQP unsigned 64-bit integer type. @ingroup cpp
+/// AMQP unsigned 64-bit integer type.
typedef std::uint64_t amqp_ulong;
-/// AMQP signed 64-bit integer type. @ingroup cpp
+/// AMQP signed 64-bit integer type.
typedef std::int64_t amqp_long;
-/// AMQP 32-bit floating-point type. @ingroup cpp
+/// AMQP 32-bit floating-point type.
typedef float amqp_float;
-/// AMQP 64-bit floating-point type. @ingroup cpp
+/// AMQP 64-bit floating-point type.
typedef double amqp_double;
-PN_CPP_EXTERN pn_bytes_t pn_bytes(const std::string&);
-PN_CPP_EXTERN std::string str(const pn_bytes_t& b);
-
-/// AMQP UTF-8 encoded string. @ingroup cpp
+/// AMQP UTF-8 encoded string.
struct amqp_string : public std::string {
amqp_string(const std::string& s=std::string()) : std::string(s) {}
amqp_string(const char* s) : std::string(s) {}
@@ -115,7 +114,7 @@ struct amqp_string : public std::string {
operator pn_bytes_t() const { return pn_bytes(*this); }
};
-/// AMQP ASCII encoded symbolic name. @ingroup cpp
+/// AMQP ASCII encoded symbolic name.
struct amqp_symbol : public std::string {
amqp_symbol(const std::string& s=std::string()) : std::string(s) {}
amqp_symbol(const char* s) : std::string(s) {}
@@ -123,7 +122,7 @@ struct amqp_symbol : public std::string {
operator pn_bytes_t() const { return pn_bytes(*this); }
};
-/// AMQP variable-length binary data. @ingroup cpp
+/// AMQP variable-length binary data.
struct amqp_binary : public std::string {
amqp_binary(const std::string& s=std::string()) : std::string(s) {}
amqp_binary(const char* s) : std::string(s) {}
@@ -134,7 +133,7 @@ struct amqp_binary : public std::string {
// TODO aconway 2015-06-11: alternative representation of variable-length data
// as pointer to existing buffer.
-// Wrapper for opaque proton types that can be treated as byte arrays.
+/// Template for opaque proton proton types that can be treated as byte arrays.
template <class P> struct opaque: public comparable<opaque<P> > {
P value;
opaque(const P& p=P()) : value(p) {}
@@ -152,17 +151,17 @@ template <class P> struct opaque: public comparable<opaque<P> > {
bool operator<(const opaque& x) const { return std::lexicographical_compare(begin(), end(), x.begin(), x.end()); }
};
-/// AMQP 16-byte UUID. @ingroup cpp
+/// AMQP 16-byte UUID.
typedef opaque<pn_uuid_t> amqp_uuid;
PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const amqp_uuid&);
-/// AMQP 32-bit decimal floating point (IEEE 854). @ingroup cpp
+/// AMQP 32-bit decimal floating point (IEEE 854).
typedef opaque<pn_decimal32_t> amqp_decimal32;
-/// AMQP 64-bit decimal floating point (IEEE 854). @ingroup cpp
+/// AMQP 64-bit decimal floating point (IEEE 854).
typedef opaque<pn_decimal64_t> amqp_decimal64;
-/// AMQP 128-bit decimal floating point (IEEE 854). @ingroup cpp
+/// AMQP 128-bit decimal floating point (IEEE 854).
typedef opaque<pn_decimal128_t> amqp_decimal128;
-/// AMQP timestamp, milliseconds since the epoch 00:00:00 (UTC), 1 January 1970. @ingroup cpp
+/// AMQP timestamp, milliseconds since the epoch 00:00:00 (UTC), 1 January 1970.
struct amqp_timestamp : public comparable<amqp_timestamp> {
pn_timestamp_t milliseconds;
amqp_timestamp(std::int64_t ms=0) : milliseconds(ms) {}
@@ -171,6 +170,7 @@ struct amqp_timestamp : public comparable<amqp_timestamp> {
bool operator<(const amqp_timestamp& x) { return milliseconds < x.milliseconds; }
};
+///@cond INTERNAL
template<class T, type_id A> struct type_pair {
typedef T cpp_type;
type_id type;
@@ -186,41 +186,45 @@ template<class T, type_id A> struct cref : public type_pair<T, A> {
cref(const ref<T,A>& ref) : value(ref.value) {}
const T& value;
};
+///@endcond INTERNAL
/** A holder for AMQP values. A holder is always encoded/decoded as its amqp_value, no need
* for the as<TYPE>() helper functions.
*
* For example to encode an array of arrays using std::vector:
*
- * typedef Holder<std::vector<amqp_string>, ARRAY> Inner;
- * typedef Holder<std::vector<Inner>, ARRAY> Outer;
+ * typedef holder<std::vector<amqp_string>, ARRAY> Inner;
+ * typedef holder<std::vector<Inner>, ARRAY> Outer;
* Outer o ...
* encoder << o;
- * @ingroup cpp
+ *
*/
-template<class T, type_id A> struct Holder : public type_pair<T, A> {
+template<class T, type_id A> struct holder : public type_pair<T, A> {
T value;
};
-/** Create a reference to value as AMQP type A for decoding. For example to decode an array of amqp_int:
+/** Create a reference to value as AMQP type A for decoding.
+ * For example to decode an array of amqp_int:
*
* std::vector<amqp_int> v;
* decoder >> as<ARRAY>(v);
- * @ingroup cpp
*/
template <type_id A, class T> ref<T, A> as(T& value) { return ref<T, A>(value); }
-/** Create a const reference to value as AMQP type A for encoding. */
+/** Create a const reference to value as AMQP type A for encoding.
+ * For example to encode an array of amqp_int:
+ *
+ * std::vector<amqp_int> v;
+ * encoder << as<ARRAY>(v);
+ */
template <type_id A, class T> cref<T, A> as(const T& value) { return cref<T, A>(value); }
-///@}
-
// TODO aconway 2015-06-16: described types.
-/** Return the name of a type. @ingroup cpp */
+/** Return the name of a type. */
PN_CPP_EXTERN std::string type_name(type_id);
-/** Print the name of a type. @ingroup cpp */
+/** Print the name of a type. */
PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, type_id);
/** Information needed to start extracting or inserting a container type.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/url.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/url.hpp b/proton-c/bindings/cpp/include/proton/url.hpp
index 1d7ca10..4da3a56 100644
--- a/proton-c/bindings/cpp/include/proton/url.hpp
+++ b/proton-c/bindings/cpp/include/proton/url.hpp
@@ -27,11 +27,15 @@ struct pn_url_t;
namespace proton {
+/// Thrown if URL parsing fails.
struct bad_url : public error { PN_CPP_EXTERN explicit bad_url(const std::string&) throw(); };
/**
- * url is a proton URL of the form <scheme>://<username>:<password>@<host>:<port>/<path>.
+ * url is a proton URL of the form `<scheme>://<username>:<password>@<host>:<port>/<path>`.
+ * scheme can be `amqp` or `amqps`. host is a DNS name or IP address (v4 or v6)
+ * port can be a number or symbolic service name like `amqp`. path is normally used as
+ * a link source or target address, on a broker it typically it corresponds to a queue or topic name.
*/
class url {
public:
@@ -48,6 +52,13 @@ class url {
*/
PN_CPP_EXTERN url(const std::string& url_str, bool defaults=true);
+ /** Parse url_str as an AMQP URL. If defaults is true, fill in defaults for missing values
+ * otherwise return an empty string for missing values.
+ * Note: converts automatically from string.
+ *@throws bad_url if URL is invalid.
+ */
+ PN_CPP_EXTERN url(const char* url_str, bool defaults=true);
+
PN_CPP_EXTERN url(const url&);
PN_CPP_EXTERN ~url();
PN_CPP_EXTERN url& operator=(const url&);
@@ -57,6 +68,11 @@ class url {
*/
PN_CPP_EXTERN void parse(const std::string&);
+ /** Parse a string as a URL
+ *@throws bad_url if URL is invalid.
+ */
+ PN_CPP_EXTERN void parse(const char*);
+
PN_CPP_EXTERN bool empty() const;
/** str returns the URL as a string string */
@@ -92,11 +108,19 @@ class url {
/** defaults fills in default values for missing parts of the URL */
PN_CPP_EXTERN void defaults();
+ friend std::ostream& operator<<(std::ostream&, const url&);
+
+ /** parse url from istream, automatically fills in defaults for missing values.
+ *
+ * Note: an invalid url is indicated by setting std::stream::fail() NOT by throwing bad_url.
+ */
+ friend std::istream& operator>>(std::istream&, url&);
+
private:
pn_url_t* url_;
};
-std::ostream& operator<<(std::ostream&, const url&);
+
}
#endif // URL_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/include/proton/wait_condition.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/wait_condition.hpp b/proton-c/bindings/cpp/include/proton/wait_condition.hpp
index f184f71..760928e 100644
--- a/proton-c/bindings/cpp/include/proton/wait_condition.hpp
+++ b/proton-c/bindings/cpp/include/proton/wait_condition.hpp
@@ -25,6 +25,9 @@
namespace proton {
+// TODO aconway 2015-07-15: c++11 should use std::function
+// c++03 could use a function template.
+
// Interface class to indicates that an expected contion has been
// achieved, i.e. for blocking_connection.wait()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/src/blocking_connection.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking_connection.cpp b/proton-c/bindings/cpp/src/blocking_connection.cpp
index 5bd790b..02cec85 100644
--- a/proton-c/bindings/cpp/src/blocking_connection.cpp
+++ b/proton-c/bindings/cpp/src/blocking_connection.cpp
@@ -22,6 +22,7 @@
#include "proton/blocking_connection.hpp"
#include "proton/blocking_sender.hpp"
#include "proton/messaging_handler.hpp"
+#include "proton/url.hpp"
#include "proton/error.hpp"
#include "msg.hpp"
#include "blocking_connection_impl.hpp"
@@ -39,7 +40,7 @@ blocking_connection::blocking_connection(const blocking_connection& c) : handle<
blocking_connection& blocking_connection::operator=(const blocking_connection& c) { return PI::assign(*this, c); }
blocking_connection::~blocking_connection() { PI::dtor(*this); }
-blocking_connection::blocking_connection(std::string &url, duration d, ssl_domain *ssld, container *c) {
+blocking_connection::blocking_connection(const proton::url &url, duration d, ssl_domain *ssld, container *c) {
blocking_connection_impl *cimpl = new blocking_connection_impl(url, d,ssld, c);
PI::ctor(*this, cimpl);
}
@@ -51,7 +52,7 @@ void blocking_connection::wait(wait_condition &cond, std::string &msg, duration
return impl_->wait(cond, msg, timeout);
}
-blocking_sender blocking_connection::create_sender(std::string &address, handler *h) {
+blocking_sender blocking_connection::create_sender(const std::string &address, handler *h) {
sender sender = impl_->container_.create_sender(impl_->connection_, address, h);
return blocking_sender(*this, sender);
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/src/blocking_connection_impl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking_connection_impl.cpp b/proton-c/bindings/cpp/src/blocking_connection_impl.cpp
index 43420d7..26d0e78 100644
--- a/proton-c/bindings/cpp/src/blocking_connection_impl.cpp
+++ b/proton-c/bindings/cpp/src/blocking_connection_impl.cpp
@@ -107,8 +107,7 @@ void blocking_connection_impl::wait(wait_condition &condition, std::string &msg,
std::string txt = "connection timed out";
if (!msg.empty())
txt += ": " + msg;
- // TODO: proper Timeout exception
- throw error(MSG(txt));
+ throw timeout_error(txt);
}
}
} catch (...) {
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/src/connection.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connection.cpp b/proton-c/bindings/cpp/src/connection.cpp
index 6c21fdd..2b335a4 100644
--- a/proton-c/bindings/cpp/src/connection.cpp
+++ b/proton-c/bindings/cpp/src/connection.cpp
@@ -61,7 +61,7 @@ std::string connection::hostname() { return impl_->hostname(); }
class container &connection::container() { return impl_->container(); }
-link connection::link_head(endpoint::State mask) {
+link connection::link_head(endpoint::state mask) {
return impl_->link_head(mask);
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/src/connection_impl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connection_impl.cpp b/proton-c/bindings/cpp/src/connection_impl.cpp
index e515d78..51da569 100644
--- a/proton-c/bindings/cpp/src/connection_impl.cpp
+++ b/proton-c/bindings/cpp/src/connection_impl.cpp
@@ -129,7 +129,7 @@ connection &connection_impl::reactor_reference(pn_connection_t *conn) {
return impl_->reactor_reference_;
}
-link connection_impl::link_head(endpoint::State mask) {
+link connection_impl::link_head(endpoint::state mask) {
return link(pn_link_head(pn_connection_, mask));
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/src/connection_impl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connection_impl.hpp b/proton-c/bindings/cpp/src/connection_impl.hpp
index 816f0d5..6450ef5 100644
--- a/proton-c/bindings/cpp/src/connection_impl.hpp
+++ b/proton-c/bindings/cpp/src/connection_impl.hpp
@@ -49,7 +49,7 @@ class connection_impl : public endpoint
PN_CPP_EXTERN pn_connection_t *pn_connection();
PN_CPP_EXTERN class container &container();
PN_CPP_EXTERN std::string hostname();
- PN_CPP_EXTERN link link_head(endpoint::State mask);
+ PN_CPP_EXTERN link link_head(endpoint::state mask);
virtual PN_CPP_EXTERN class connection &connection();
static class connection &reactor_reference(pn_connection_t *);
static connection_impl *impl(const class connection &c) { return c.impl_; }
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/src/container.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/container.cpp b/proton-c/bindings/cpp/src/container.cpp
index f135336..07cb971 100644
--- a/proton-c/bindings/cpp/src/container.cpp
+++ b/proton-c/bindings/cpp/src/container.cpp
@@ -64,7 +64,7 @@ duration container::timeout() { return impl_->timeout(); }
void container::timeout(duration timeout) { impl_->timeout(timeout); }
-sender container::create_sender(connection &connection, std::string &addr, handler *h) {
+sender container::create_sender(connection &connection, const std::string &addr, handler *h) {
return impl_->create_sender(connection, addr, h);
}
@@ -72,8 +72,8 @@ sender container::create_sender(const proton::url &url) {
return impl_->create_sender(url);
}
-receiver container::create_receiver(connection &connection, std::string &addr) {
- return impl_->create_receiver(connection, addr);
+receiver container::create_receiver(connection &connection, const std::string &addr, handler *h) {
+ return impl_->create_receiver(connection, addr, h);
}
receiver container::create_receiver(const proton::url &url) {
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/src/container_impl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/container_impl.cpp b/proton-c/bindings/cpp/src/container_impl.cpp
index fc1aafd..0858d73 100644
--- a/proton-c/bindings/cpp/src/container_impl.cpp
+++ b/proton-c/bindings/cpp/src/container_impl.cpp
@@ -230,7 +230,7 @@ void container_impl::timeout(duration timeout) {
}
-sender container_impl::create_sender(connection &connection, std::string &addr, handler *h) {
+sender container_impl::create_sender(connection &connection, const std::string &addr, handler *h) {
if (!reactor_) throw error(MSG("container not started"));
session session = default_session(connection.pn_connection(), &impl(connection)->default_session_);
sender snd = session.create_sender(container_id_ + '-' + addr);
@@ -255,19 +255,23 @@ sender container_impl::create_sender(const proton::url &url) {
return snd;
}
-receiver container_impl::create_receiver(connection &connection, std::string &addr) {
+receiver container_impl::create_receiver(connection &connection, const std::string &addr, handler *h) {
if (!reactor_) throw error(MSG("container not started"));
connection_impl *conn_impl = impl(connection);
session session = default_session(conn_impl->pn_connection_, &conn_impl->default_session_);
receiver rcv = session.create_receiver(container_id_ + '-' + addr);
- pn_terminus_set_address(pn_link_source(rcv.pn_link()), addr.c_str());
+ pn_link_t *lnk = rcv.pn_link();
+ pn_terminus_set_address(pn_link_source(lnk), addr.c_str());
+ if (h) {
+ pn_record_t *record = pn_link_attachments(lnk);
+ pn_record_set_handler(record, wrap_handler(h));
+ }
rcv.open();
return rcv;
}
receiver container_impl::create_receiver(const proton::url &url) {
if (!reactor_) throw error(MSG("container not started"));
- // TODO: const cleanup of API
connection conn = connect(url, 0);
session session = default_session(conn.pn_connection(), &impl(conn)->default_session_);
std::string path = url.path();
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/src/container_impl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/container_impl.hpp b/proton-c/bindings/cpp/src/container_impl.hpp
index 39f513d..4378f7d 100644
--- a/proton-c/bindings/cpp/src/container_impl.hpp
+++ b/proton-c/bindings/cpp/src/container_impl.hpp
@@ -46,9 +46,9 @@ class container_impl
PN_CPP_EXTERN connection connect(const url&, handler *h);
PN_CPP_EXTERN void run();
PN_CPP_EXTERN pn_reactor_t *reactor();
- PN_CPP_EXTERN sender create_sender(connection &connection, std::string &addr, handler *h);
+ PN_CPP_EXTERN sender create_sender(connection &connection, const std::string &addr, handler *h);
PN_CPP_EXTERN sender create_sender(const url&);
- PN_CPP_EXTERN receiver create_receiver(connection &connection, std::string &addr);
+ PN_CPP_EXTERN receiver create_receiver(connection &connection, const std::string &addr, handler *h);
PN_CPP_EXTERN receiver create_receiver(const url&);
PN_CPP_EXTERN class acceptor listen(const url&);
PN_CPP_EXTERN std::string container_id();
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/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 92df1f7..6ad7dfe 100644
--- a/proton-c/bindings/cpp/src/decoder.cpp
+++ b/proton-c/bindings/cpp/src/decoder.cpp
@@ -293,7 +293,6 @@ decoder& operator>>(decoder& d, amqp_double& value) {
return d;
}
-// TODO aconway 2015-06-11: decimal conversions.
decoder& operator>>(decoder& d, amqp_decimal32& value) {
extract(d.data_, value, pn_data_get_decimal32);
return d;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/src/endpoint.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/endpoint.cpp b/proton-c/bindings/cpp/src/endpoint.cpp
index 98e912a..2b7d645 100644
--- a/proton-c/bindings/cpp/src/endpoint.cpp
+++ b/proton-c/bindings/cpp/src/endpoint.cpp
@@ -22,6 +22,7 @@
#include "proton/endpoint.hpp"
#include "proton/connection.hpp"
#include "proton/transport.hpp"
+#include "proton/connection.h"
namespace proton {
@@ -29,4 +30,13 @@ endpoint::endpoint() {}
endpoint::~endpoint() {}
+const int endpoint::LOCAL_UNINIT = PN_LOCAL_UNINIT;
+const int endpoint::REMOTE_UNINIT = PN_REMOTE_UNINIT;
+const int endpoint::LOCAL_ACTIVE = PN_LOCAL_ACTIVE;
+const int endpoint::REMOTE_ACTIVE = PN_REMOTE_ACTIVE;
+const int endpoint::LOCAL_CLOSED = PN_LOCAL_CLOSED;
+const int endpoint::REMOTE_CLOSED = PN_REMOTE_CLOSED;
+const int endpoint::LOCAL_MASK = PN_LOCAL_MASK;
+const int endpoint::REMOTE_MASK = PN_REMOTE_MASK;
+
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/src/error.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/error.cpp b/proton-c/bindings/cpp/src/error.cpp
index 18aaa7c..fb409ef 100644
--- a/proton-c/bindings/cpp/src/error.cpp
+++ b/proton-c/bindings/cpp/src/error.cpp
@@ -25,6 +25,8 @@ static const std::string prefix("proton: ");
error::error(const std::string& msg) throw() : std::runtime_error(prefix+msg) {}
+timeout_error::timeout_error(const std::string& msg) throw() : error(msg) {}
+
message_reject::message_reject(const std::string& msg) throw() : error(msg) {}
message_release::message_release(const std::string& msg) throw() : error(msg) {}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/src/link.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/link.cpp b/proton-c/bindings/cpp/src/link.cpp
index 2470510..2cef0a2 100644
--- a/proton-c/bindings/cpp/src/link.cpp
+++ b/proton-c/bindings/cpp/src/link.cpp
@@ -105,7 +105,7 @@ class connection &link::connection() {
return connection_impl::reactor_reference(c);
}
-link link::next(endpoint::State mask) {
+link link::next(endpoint::state mask) {
return link(pn_link_next(impl_, (pn_state_t) mask));
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/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 62dca4d..616f23d 100644
--- a/proton-c/bindings/cpp/src/message.cpp
+++ b/proton-c/bindings/cpp/src/message.cpp
@@ -44,13 +44,16 @@ message::message(const message& m) : proton_handle<pn_message_t>(), body_(0) {
PI::copy(*this, m);
}
-// FIXME aconway 2015-06-17: message should be a value type, needs to own pn_message_t
-// and do appropriate _copy and _free operations.
+// TODO aconway 2015-06-17: message should be a value not a handle
+// Needs to own pn_message_t and do appropriate _copy and _free operations.
+
message& message::operator=(const message& m) {
return PI::assign(*this, m);
}
message::~message() { PI::dtor(*this); }
+void message::clear() { pn_message_clear(impl_); }
+
namespace {
void confirm(pn_message_t * const& p) {
if (p) return;
@@ -189,12 +192,12 @@ std::string message::group_id() const {
return s ? std::string(s) : std::string();
}
-void message::reply_togroup_id(const std::string &s) {
+void message::reply_to_group_id(const std::string &s) {
confirm(impl_);
check(pn_message_set_reply_to_group_id(impl_, s.c_str()));
}
-std::string message::reply_togroup_id() const {
+std::string message::reply_to_group_id() const {
confirm(impl_);
const char* s = pn_message_get_reply_to_group_id(impl_);
return s ? std::string(s) : std::string();
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/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 433b254..0bb574f 100644
--- a/proton-c/bindings/cpp/src/messaging_adapter.cpp
+++ b/proton-c/bindings/cpp/src/messaging_adapter.cpp
@@ -43,7 +43,7 @@ messaging_adapter::~messaging_adapter(){}
void messaging_adapter::on_reactor_init(event &e) {
proton_event *pe = dynamic_cast<proton_event*>(&e);
if (pe) {
- messaging_event mevent(PN_MESSAGING_START, *pe);
+ messaging_event mevent(messaging_event::START, *pe);
delegate_.on_start(mevent);
}
}
@@ -55,7 +55,7 @@ void messaging_adapter::on_link_flow(event &e) {
pn_link_t *lnk = pn_event_link(pne);
if (lnk && pn_link_is_sender(lnk) && pn_link_credit(lnk) > 0) {
// create on_message extended event
- messaging_event mevent(PN_MESSAGING_SENDABLE, *pe);
+ messaging_event mevent(messaging_event::SENDABLE, *pe);
delegate_.on_sendable(mevent);;
}
}
@@ -86,7 +86,7 @@ void messaging_adapter::on_delivery(event &e) {
if (pn_link_is_receiver(lnk)) {
if (!pn_delivery_partial(dlv) && pn_delivery_readable(dlv)) {
// generate on_message
- messaging_event mevent(PN_MESSAGING_MESSAGE, *pe);
+ messaging_event mevent(messaging_event::MESSAGE, *pe);
message m(receive_message(lnk, dlv));
mevent.message(m);
if (pn_link_state(lnk) & PN_LOCAL_CLOSED) {
@@ -114,7 +114,7 @@ void messaging_adapter::on_delivery(event &e) {
}
}
else if (pn_delivery_updated(dlv) && pn_delivery_settled(dlv)) {
- messaging_event mevent(PN_MESSAGING_SETTLED, *pe);
+ messaging_event mevent(messaging_event::SETTLED, *pe);
delegate_.on_settled(mevent);
}
} else {
@@ -122,20 +122,20 @@ void messaging_adapter::on_delivery(event &e) {
if (pn_delivery_updated(dlv)) {
std::uint64_t rstate = pn_delivery_remote_state(dlv);
if (rstate == PN_ACCEPTED) {
- messaging_event mevent(PN_MESSAGING_ACCEPTED, *pe);
+ messaging_event mevent(messaging_event::ACCEPTED, *pe);
delegate_.on_accepted(mevent);
}
else if (rstate == PN_REJECTED) {
- messaging_event mevent(PN_MESSAGING_REJECTED, *pe);
+ messaging_event mevent(messaging_event::REJECTED, *pe);
delegate_.on_rejected(mevent);
}
else if (rstate == PN_RELEASED || rstate == PN_MODIFIED) {
- messaging_event mevent(PN_MESSAGING_RELEASED, *pe);
+ messaging_event mevent(messaging_event::RELEASED, *pe);
delegate_.on_released(mevent);
}
if (pn_delivery_settled(dlv)) {
- messaging_event mevent(PN_MESSAGING_SETTLED, *pe);
+ messaging_event mevent(messaging_event::SETTLED, *pe);
delegate_.on_settled(mevent);
}
if (auto_settle_)
@@ -172,15 +172,15 @@ void messaging_adapter::on_link_remote_close(event &e) {
pn_link_t *lnk = pn_event_link(cevent);
pn_state_t state = pn_link_state(lnk);
if (pn_condition_is_set(pn_link_remote_condition(lnk))) {
- messaging_event mevent(PN_MESSAGING_LINK_ERROR, *pe);
+ messaging_event mevent(messaging_event::LINK_ERROR, *pe);
on_link_error(mevent);
}
else if (is_local_closed(state)) {
- messaging_event mevent(PN_MESSAGING_LINK_CLOSED, *pe);
+ messaging_event mevent(messaging_event::LINK_CLOSED, *pe);
on_link_closed(mevent);
}
else {
- messaging_event mevent(PN_MESSAGING_LINK_CLOSING, *pe);
+ messaging_event mevent(messaging_event::LINK_CLOSING, *pe);
on_link_closing(mevent);
}
pn_link_close(lnk);
@@ -194,15 +194,15 @@ void messaging_adapter::on_session_remote_close(event &e) {
pn_session_t *session = pn_event_session(cevent);
pn_state_t state = pn_session_state(session);
if (pn_condition_is_set(pn_session_remote_condition(session))) {
- messaging_event mevent(PN_MESSAGING_SESSION_ERROR, *pe);
+ messaging_event mevent(messaging_event::SESSION_ERROR, *pe);
on_session_error(mevent);
}
else if (is_local_closed(state)) {
- messaging_event mevent(PN_MESSAGING_SESSION_CLOSED, *pe);
+ messaging_event mevent(messaging_event::SESSION_CLOSED, *pe);
on_session_closed(mevent);
}
else {
- messaging_event mevent(PN_MESSAGING_SESSION_CLOSING, *pe);
+ messaging_event mevent(messaging_event::SESSION_CLOSING, *pe);
on_session_closing(mevent);
}
pn_session_close(session);
@@ -216,15 +216,15 @@ void messaging_adapter::on_connection_remote_close(event &e) {
pn_connection_t *connection = pn_event_connection(cevent);
pn_state_t state = pn_connection_state(connection);
if (pn_condition_is_set(pn_connection_remote_condition(connection))) {
- messaging_event mevent(PN_MESSAGING_CONNECTION_ERROR, *pe);
+ messaging_event mevent(messaging_event::CONNECTION_ERROR, *pe);
on_connection_error(mevent);
}
else if (is_local_closed(state)) {
- messaging_event mevent(PN_MESSAGING_CONNECTION_CLOSED, *pe);
+ messaging_event mevent(messaging_event::CONNECTION_CLOSED, *pe);
on_connection_closed(mevent);
}
else {
- messaging_event mevent(PN_MESSAGING_CONNECTION_CLOSING, *pe);
+ messaging_event mevent(messaging_event::CONNECTION_CLOSING, *pe);
on_connection_closing(mevent);
}
pn_connection_close(connection);
@@ -236,7 +236,7 @@ void messaging_adapter::on_connection_local_open(event &e) {
if (pe) {
pn_connection_t *connection = pn_event_connection(pe->pn_event());
if (is_remote_open(pn_connection_state(connection))) {
- messaging_event mevent(PN_MESSAGING_CONNECTION_OPENED, *pe);
+ messaging_event mevent(messaging_event::CONNECTION_OPENED, *pe);
on_connection_opened(mevent);
}
}
@@ -247,11 +247,11 @@ void messaging_adapter::on_connection_remote_open(event &e) {
if (pe) {
pn_connection_t *connection = pn_event_connection(pe->pn_event());
if (is_local_open(pn_connection_state(connection))) {
- messaging_event mevent(PN_MESSAGING_CONNECTION_OPENED, *pe);
+ messaging_event mevent(messaging_event::CONNECTION_OPENED, *pe);
on_connection_opened(mevent);
}
else if (is_local_unititialised(pn_connection_state(connection))) {
- messaging_event mevent(PN_MESSAGING_CONNECTION_OPENING, *pe);
+ messaging_event mevent(messaging_event::CONNECTION_OPENING, *pe);
on_connection_opening(mevent);
pn_connection_open(connection);
}
@@ -263,7 +263,7 @@ void messaging_adapter::on_session_local_open(event &e) {
if (pe) {
pn_session_t *session = pn_event_session(pe->pn_event());
if (is_remote_open(pn_session_state(session))) {
- messaging_event mevent(PN_MESSAGING_SESSION_OPENED, *pe);
+ messaging_event mevent(messaging_event::SESSION_OPENED, *pe);
on_session_opened(mevent);
}
}
@@ -274,11 +274,11 @@ void messaging_adapter::on_session_remote_open(event &e) {
if (pe) {
pn_session_t *session = pn_event_session(pe->pn_event());
if (is_local_open(pn_session_state(session))) {
- messaging_event mevent(PN_MESSAGING_SESSION_OPENED, *pe);
+ messaging_event mevent(messaging_event::SESSION_OPENED, *pe);
on_session_opened(mevent);
}
else if (is_local_unititialised(pn_session_state(session))) {
- messaging_event mevent(PN_MESSAGING_SESSION_OPENING, *pe);
+ messaging_event mevent(messaging_event::SESSION_OPENING, *pe);
on_session_opening(mevent);
pn_session_open(session);
}
@@ -290,7 +290,7 @@ void messaging_adapter::on_link_local_open(event &e) {
if (pe) {
pn_link_t *link = pn_event_link(pe->pn_event());
if (is_remote_open(pn_link_state(link))) {
- messaging_event mevent(PN_MESSAGING_LINK_OPENED, *pe);
+ messaging_event mevent(messaging_event::LINK_OPENED, *pe);
on_link_opened(mevent);
}
}
@@ -301,11 +301,11 @@ void messaging_adapter::on_link_remote_open(event &e) {
if (pe) {
pn_link_t *link = pn_event_link(pe->pn_event());
if (is_local_open(pn_link_state(link))) {
- messaging_event mevent(PN_MESSAGING_LINK_OPENED, *pe);
+ messaging_event mevent(messaging_event::LINK_OPENED, *pe);
on_link_opened(mevent);
}
else if (is_local_unititialised(pn_link_state(link))) {
- messaging_event mevent(PN_MESSAGING_LINK_OPENING, *pe);
+ messaging_event mevent(messaging_event::LINK_OPENING, *pe);
on_link_opening(mevent);
pn_link_open(link);
}
@@ -317,7 +317,7 @@ void messaging_adapter::on_transport_tail_closed(event &e) {
if (pe) {
pn_connection_t *conn = pn_event_connection(pe->pn_event());
if (conn && is_local_open(pn_connection_state(conn))) {
- messaging_event mevent(PN_MESSAGING_DISCONNECTED, *pe);
+ messaging_event mevent(messaging_event::DISCONNECTED, *pe);
delegate_.on_disconnected(mevent);
}
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/src/messaging_event.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_event.cpp b/proton-c/bindings/cpp/src/messaging_event.cpp
index b5da375..d79974d 100644
--- a/proton-c/bindings/cpp/src/messaging_event.cpp
+++ b/proton-c/bindings/cpp/src/messaging_event.cpp
@@ -34,12 +34,13 @@
namespace proton {
messaging_event::messaging_event(pn_event_t *ce, pn_event_type_t t, class container &c) :
- proton_event(ce, t, c), messaging_type_(PN_MESSAGING_PROTON), parent_event_(0), message_(0)
+ proton_event(ce, t, c), type_(messaging_event::PROTON), parent_event_(0), message_(0)
{}
-messaging_event::messaging_event(messaging_event_type_t t, proton_event &p) :
- proton_event(NULL, PN_EVENT_NONE, p.container()), messaging_type_(t), parent_event_(&p), message_(0) {
- if (messaging_type_ == PN_MESSAGING_PROTON)
+messaging_event::messaging_event(event_type t, proton_event &p) :
+ proton_event(NULL, PN_EVENT_NONE, p.container()), type_(t), parent_event_(&p), message_(0)
+{
+ if (type_ == messaging_event::PROTON)
throw error(MSG("invalid messaging event type"));
}
@@ -47,8 +48,10 @@ messaging_event::~messaging_event() {
delete message_;
}
+messaging_event::event_type messaging_event::type() const { return type_; }
+
connection &messaging_event::connection() {
- if (messaging_type_ == PN_MESSAGING_PROTON)
+ if (type_ == messaging_event::PROTON)
return proton_event::connection();
if (parent_event_)
return parent_event_->connection();
@@ -56,7 +59,7 @@ connection &messaging_event::connection() {
}
sender messaging_event::sender() {
- if (messaging_type_ == PN_MESSAGING_PROTON)
+ if (type_ == messaging_event::PROTON)
return proton_event::sender();
if (parent_event_)
return parent_event_->sender();
@@ -64,7 +67,7 @@ sender messaging_event::sender() {
}
receiver messaging_event::receiver() {
- if (messaging_type_ == PN_MESSAGING_PROTON)
+ if (type_ == messaging_event::PROTON)
return proton_event::receiver();
if (parent_event_)
return parent_event_->receiver();
@@ -72,7 +75,7 @@ receiver messaging_event::receiver() {
}
link messaging_event::link() {
- if (messaging_type_ == PN_MESSAGING_PROTON)
+ if (type_ == messaging_event::PROTON)
return proton_event::link();
if (parent_event_)
return parent_event_->link();
@@ -89,50 +92,50 @@ message messaging_event::message() {
}
void messaging_event::message(class message &m) {
- if (messaging_type_ != PN_MESSAGING_MESSAGE || !parent_event_)
+ if (type_ != messaging_event::MESSAGE || !parent_event_)
throw error(MSG("event type does not provide message"));
event_context(parent_event_->pn_event(), m.pn_message());
}
void messaging_event::dispatch(handler &h) {
- if (messaging_type_ == PN_MESSAGING_PROTON) {
+ if (type_ == messaging_event::PROTON) {
proton_event::dispatch(h);
return;
}
messaging_handler *handler = dynamic_cast<messaging_handler*>(&h);
if (handler) {
- switch(messaging_type_) {
-
- case PN_MESSAGING_START: handler->on_start(*this); break;
- case PN_MESSAGING_SENDABLE: handler->on_sendable(*this); break;
- case PN_MESSAGING_MESSAGE: handler->on_message(*this); break;
- case PN_MESSAGING_ACCEPTED: handler->on_accepted(*this); break;
- case PN_MESSAGING_REJECTED: handler->on_rejected(*this); break;
- case PN_MESSAGING_RELEASED: handler->on_released(*this); break;
- case PN_MESSAGING_SETTLED: handler->on_settled(*this); break;
-
- case PN_MESSAGING_CONNECTION_CLOSING: handler->on_connection_closing(*this); break;
- case PN_MESSAGING_CONNECTION_CLOSED: handler->on_connection_closed(*this); break;
- case PN_MESSAGING_CONNECTION_ERROR: handler->on_connection_error(*this); break;
- case PN_MESSAGING_CONNECTION_OPENING: handler->on_connection_opening(*this); break;
- case PN_MESSAGING_CONNECTION_OPENED: handler->on_connection_opened(*this); break;
-
- case PN_MESSAGING_LINK_CLOSED: handler->on_link_closed(*this); break;
- case PN_MESSAGING_LINK_CLOSING: handler->on_link_closing(*this); break;
- case PN_MESSAGING_LINK_ERROR: handler->on_link_error(*this); break;
- case PN_MESSAGING_LINK_OPENING: handler->on_link_opening(*this); break;
- case PN_MESSAGING_LINK_OPENED: handler->on_link_opened(*this); break;
-
- case PN_MESSAGING_SESSION_CLOSED: handler->on_session_closed(*this); break;
- case PN_MESSAGING_SESSION_CLOSING: handler->on_session_closing(*this); break;
- case PN_MESSAGING_SESSION_ERROR: handler->on_session_error(*this); break;
- case PN_MESSAGING_SESSION_OPENING: handler->on_session_opening(*this); break;
- case PN_MESSAGING_SESSION_OPENED: handler->on_session_opened(*this); break;
-
- case PN_MESSAGING_TRANSPORT_CLOSED: handler->on_transport_closed(*this); break;
+ switch(type_) {
+
+ case messaging_event::START: handler->on_start(*this); break;
+ case messaging_event::SENDABLE: handler->on_sendable(*this); break;
+ case messaging_event::MESSAGE: handler->on_message(*this); break;
+ case messaging_event::ACCEPTED: handler->on_accepted(*this); break;
+ case messaging_event::REJECTED: handler->on_rejected(*this); break;
+ case messaging_event::RELEASED: handler->on_released(*this); break;
+ case messaging_event::SETTLED: handler->on_settled(*this); break;
+
+ case messaging_event::CONNECTION_CLOSING: handler->on_connection_closing(*this); break;
+ case messaging_event::CONNECTION_CLOSED: handler->on_connection_closed(*this); break;
+ case messaging_event::CONNECTION_ERROR: handler->on_connection_error(*this); break;
+ case messaging_event::CONNECTION_OPENING: handler->on_connection_opening(*this); break;
+ case messaging_event::CONNECTION_OPENED: handler->on_connection_opened(*this); break;
+
+ case messaging_event::LINK_CLOSED: handler->on_link_closed(*this); break;
+ case messaging_event::LINK_CLOSING: handler->on_link_closing(*this); break;
+ case messaging_event::LINK_ERROR: handler->on_link_error(*this); break;
+ case messaging_event::LINK_OPENING: handler->on_link_opening(*this); break;
+ case messaging_event::LINK_OPENED: handler->on_link_opened(*this); break;
+
+ case messaging_event::SESSION_CLOSED: handler->on_session_closed(*this); break;
+ case messaging_event::SESSION_CLOSING: handler->on_session_closing(*this); break;
+ case messaging_event::SESSION_ERROR: handler->on_session_error(*this); break;
+ case messaging_event::SESSION_OPENING: handler->on_session_opening(*this); break;
+ case messaging_event::SESSION_OPENED: handler->on_session_opened(*this); break;
+
+ case messaging_event::TRANSPORT_CLOSED: handler->on_transport_closed(*this); break;
default:
- throw error(MSG("Unkown messaging event type " << messaging_type_));
+ throw error(MSG("Unkown messaging event type " << type_));
break;
}
} else {
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/src/proton_event.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_event.cpp b/proton-c/bindings/cpp/src/proton_event.cpp
index 2d2f7d5..e3e39ab 100644
--- a/proton-c/bindings/cpp/src/proton_event.cpp
+++ b/proton-c/bindings/cpp/src/proton_event.cpp
@@ -35,9 +35,9 @@
namespace proton {
proton_event::proton_event(pn_event_t *ce, pn_event_type_t t, class container &c) :
- pn_event_(ce),
- type_((int) t),
- container_(c)
+ pn_event_(ce),
+ type_((int) t),
+ container_(c)
{}
int proton_event::type() { return type_; }
@@ -87,54 +87,54 @@ void proton_event::dispatch(handler &h) {
if (handler) {
switch(type_) {
- case PN_REACTOR_INIT: handler->on_reactor_init(*this); break;
- case PN_REACTOR_QUIESCED: handler->on_reactor_quiesced(*this); break;
- case PN_REACTOR_FINAL: handler->on_reactor_final(*this); break;
-
- case PN_TIMER_TASK: handler->on_timer_task(*this); break;
-
- case PN_CONNECTION_INIT: handler->on_connection_init(*this); break;
- case PN_CONNECTION_BOUND: handler->on_connection_bound(*this); break;
- case PN_CONNECTION_UNBOUND: handler->on_connection_unbound(*this); break;
- case PN_CONNECTION_LOCAL_OPEN: handler->on_connection_local_open(*this); break;
- case PN_CONNECTION_LOCAL_CLOSE: handler->on_connection_local_close(*this); break;
- case PN_CONNECTION_REMOTE_OPEN: handler->on_connection_remote_open(*this); break;
- case PN_CONNECTION_REMOTE_CLOSE: handler->on_connection_remote_close(*this); break;
- case PN_CONNECTION_FINAL: handler->on_connection_final(*this); break;
-
- case PN_SESSION_INIT: handler->on_session_init(*this); break;
- case PN_SESSION_LOCAL_OPEN: handler->on_session_local_open(*this); break;
- case PN_SESSION_LOCAL_CLOSE: handler->on_session_local_close(*this); break;
- case PN_SESSION_REMOTE_OPEN: handler->on_session_remote_open(*this); break;
- case PN_SESSION_REMOTE_CLOSE: handler->on_session_remote_close(*this); break;
- case PN_SESSION_FINAL: handler->on_session_final(*this); break;
-
- case PN_LINK_INIT: handler->on_link_init(*this); break;
- case PN_LINK_LOCAL_OPEN: handler->on_link_local_open(*this); break;
- case PN_LINK_LOCAL_CLOSE: handler->on_link_local_close(*this); break;
- case PN_LINK_LOCAL_DETACH: handler->on_link_local_detach(*this); break;
- case PN_LINK_REMOTE_OPEN: handler->on_link_remote_open(*this); break;
- case PN_LINK_REMOTE_CLOSE: handler->on_link_remote_close(*this); break;
- case PN_LINK_REMOTE_DETACH: handler->on_link_remote_detach(*this); break;
- case PN_LINK_FLOW: handler->on_link_flow(*this); break;
- case PN_LINK_FINAL: handler->on_link_final(*this); break;
-
- case PN_DELIVERY: handler->on_delivery(*this); break;
-
- case PN_TRANSPORT: handler->on_transport(*this); break;
- case PN_TRANSPORT_ERROR: handler->on_transport_error(*this); break;
- case PN_TRANSPORT_HEAD_CLOSED: handler->on_transport_head_closed(*this); break;
- case PN_TRANSPORT_TAIL_CLOSED: handler->on_transport_tail_closed(*this); break;
- case PN_TRANSPORT_CLOSED: handler->on_transport_closed(*this); break;
-
- case PN_SELECTABLE_INIT: handler->on_selectable_init(*this); break;
- case PN_SELECTABLE_UPDATED: handler->on_selectable_updated(*this); break;
- case PN_SELECTABLE_READABLE: handler->on_selectable_readable(*this); break;
- case PN_SELECTABLE_WRITABLE: handler->on_selectable_writable(*this); break;
- case PN_SELECTABLE_EXPIRED: handler->on_selectable_expired(*this); break;
- case PN_SELECTABLE_ERROR: handler->on_selectable_error(*this); break;
- case PN_SELECTABLE_FINAL: handler->on_selectable_final(*this); break;
- default:
+ case PN_REACTOR_INIT: handler->on_reactor_init(*this); break;
+ case PN_REACTOR_QUIESCED: handler->on_reactor_quiesced(*this); break;
+ case PN_REACTOR_FINAL: handler->on_reactor_final(*this); break;
+
+ case PN_TIMER_TASK: handler->on_timer_task(*this); break;
+
+ case PN_CONNECTION_INIT: handler->on_connection_init(*this); break;
+ case PN_CONNECTION_BOUND: handler->on_connection_bound(*this); break;
+ case PN_CONNECTION_UNBOUND: handler->on_connection_unbound(*this); break;
+ case PN_CONNECTION_LOCAL_OPEN: handler->on_connection_local_open(*this); break;
+ case PN_CONNECTION_LOCAL_CLOSE: handler->on_connection_local_close(*this); break;
+ case PN_CONNECTION_REMOTE_OPEN: handler->on_connection_remote_open(*this); break;
+ case PN_CONNECTION_REMOTE_CLOSE: handler->on_connection_remote_close(*this); break;
+ case PN_CONNECTION_FINAL: handler->on_connection_final(*this); break;
+
+ case PN_SESSION_INIT: handler->on_session_init(*this); break;
+ case PN_SESSION_LOCAL_OPEN: handler->on_session_local_open(*this); break;
+ case PN_SESSION_LOCAL_CLOSE: handler->on_session_local_close(*this); break;
+ case PN_SESSION_REMOTE_OPEN: handler->on_session_remote_open(*this); break;
+ case PN_SESSION_REMOTE_CLOSE: handler->on_session_remote_close(*this); break;
+ case PN_SESSION_FINAL: handler->on_session_final(*this); break;
+
+ case PN_LINK_INIT: handler->on_link_init(*this); break;
+ case PN_LINK_LOCAL_OPEN: handler->on_link_local_open(*this); break;
+ case PN_LINK_LOCAL_CLOSE: handler->on_link_local_close(*this); break;
+ case PN_LINK_LOCAL_DETACH: handler->on_link_local_detach(*this); break;
+ case PN_LINK_REMOTE_OPEN: handler->on_link_remote_open(*this); break;
+ case PN_LINK_REMOTE_CLOSE: handler->on_link_remote_close(*this); break;
+ case PN_LINK_REMOTE_DETACH: handler->on_link_remote_detach(*this); break;
+ case PN_LINK_FLOW: handler->on_link_flow(*this); break;
+ case PN_LINK_FINAL: handler->on_link_final(*this); break;
+
+ case PN_DELIVERY: handler->on_delivery(*this); break;
+
+ case PN_TRANSPORT: handler->on_transport(*this); break;
+ case PN_TRANSPORT_ERROR: handler->on_transport_error(*this); break;
+ case PN_TRANSPORT_HEAD_CLOSED: handler->on_transport_head_closed(*this); break;
+ case PN_TRANSPORT_TAIL_CLOSED: handler->on_transport_tail_closed(*this); break;
+ case PN_TRANSPORT_CLOSED: handler->on_transport_closed(*this); break;
+
+ case PN_SELECTABLE_INIT: handler->on_selectable_init(*this); break;
+ case PN_SELECTABLE_UPDATED: handler->on_selectable_updated(*this); break;
+ case PN_SELECTABLE_READABLE: handler->on_selectable_readable(*this); break;
+ case PN_SELECTABLE_WRITABLE: handler->on_selectable_writable(*this); break;
+ case PN_SELECTABLE_EXPIRED: handler->on_selectable_expired(*this); break;
+ case PN_SELECTABLE_ERROR: handler->on_selectable_error(*this); break;
+ case PN_SELECTABLE_FINAL: handler->on_selectable_final(*this); break;
+ default:
throw error(MSG("Invalid Proton event type " << type_));
break;
}
@@ -148,4 +148,46 @@ void proton_event::dispatch(handler &h) {
}
}
+const proton_event::event_type EVENT_NONE=PN_EVENT_NONE;
+const proton_event::event_type REACTOR_INIT=PN_REACTOR_INIT;
+const proton_event::event_type REACTOR_QUIESCED=PN_REACTOR_QUIESCED;
+const proton_event::event_type REACTOR_FINAL=PN_REACTOR_FINAL;
+const proton_event::event_type TIMER_TASK=PN_TIMER_TASK;
+const proton_event::event_type CONNECTION_INIT=PN_CONNECTION_INIT;
+const proton_event::event_type CONNECTION_BOUND=PN_CONNECTION_BOUND;
+const proton_event::event_type CONNECTION_UNBOUND=PN_CONNECTION_UNBOUND;
+const proton_event::event_type CONNECTION_LOCAL_OPEN=PN_CONNECTION_LOCAL_OPEN;
+const proton_event::event_type CONNECTION_REMOTE_OPEN=PN_CONNECTION_REMOTE_OPEN;
+const proton_event::event_type CONNECTION_LOCAL_CLOSE=PN_CONNECTION_LOCAL_CLOSE;
+const proton_event::event_type CONNECTION_REMOTE_CLOSE=PN_CONNECTION_REMOTE_CLOSE;
+const proton_event::event_type CONNECTION_FINAL=PN_CONNECTION_FINAL;
+const proton_event::event_type SESSION_INIT=PN_SESSION_INIT;
+const proton_event::event_type SESSION_LOCAL_OPEN=PN_SESSION_LOCAL_OPEN;
+const proton_event::event_type SESSION_REMOTE_OPEN=PN_SESSION_REMOTE_OPEN;
+const proton_event::event_type SESSION_LOCAL_CLOSE=PN_SESSION_LOCAL_CLOSE;
+const proton_event::event_type SESSION_REMOTE_CLOSE=PN_SESSION_REMOTE_CLOSE;
+const proton_event::event_type SESSION_FINAL=PN_SESSION_FINAL;
+const proton_event::event_type LINK_INIT=PN_LINK_INIT;
+const proton_event::event_type LINK_LOCAL_OPEN=PN_LINK_LOCAL_OPEN;
+const proton_event::event_type LINK_REMOTE_OPEN=PN_LINK_REMOTE_OPEN;
+const proton_event::event_type LINK_LOCAL_CLOSE=PN_LINK_LOCAL_CLOSE;
+const proton_event::event_type LINK_REMOTE_CLOSE=PN_LINK_REMOTE_CLOSE;
+const proton_event::event_type LINK_LOCAL_DETACH=PN_LINK_LOCAL_DETACH;
+const proton_event::event_type LINK_REMOTE_DETACH=PN_LINK_REMOTE_DETACH;
+const proton_event::event_type LINK_FLOW=PN_LINK_FLOW;
+const proton_event::event_type LINK_FINAL=PN_LINK_FINAL;
+const proton_event::event_type DELIVERY=PN_DELIVERY;
+const proton_event::event_type TRANSPORT=PN_TRANSPORT;
+const proton_event::event_type TRANSPORT_AUTHENTICATED=PN_TRANSPORT_AUTHENTICATED;
+const proton_event::event_type TRANSPORT_ERROR=PN_TRANSPORT_ERROR;
+const proton_event::event_type TRANSPORT_HEAD_CLOSED=PN_TRANSPORT_HEAD_CLOSED;
+const proton_event::event_type TRANSPORT_TAIL_CLOSED=PN_TRANSPORT_TAIL_CLOSED;
+const proton_event::event_type TRANSPORT_CLOSED=PN_TRANSPORT_CLOSED;
+const proton_event::event_type SELECTABLE_INIT=PN_SELECTABLE_INIT;
+const proton_event::event_type SELECTABLE_UPDATED=PN_SELECTABLE_UPDATED;
+const proton_event::event_type SELECTABLE_READABLE=PN_SELECTABLE_READABLE;
+const proton_event::event_type SELECTABLE_WRITABLE=PN_SELECTABLE_WRITABLE;
+const proton_event::event_type SELECTABLE_ERROR=PN_SELECTABLE_ERROR;
+const proton_event::event_type SELECTABLE_EXPIRED=PN_SELECTABLE_EXPIRED;
+const proton_event::event_type SELECTABLE_FINAL=PN_SELECTABLE_FINAL;
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/src/session.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/session.cpp b/proton-c/bindings/cpp/src/session.cpp
index 283b085..5742f13 100644
--- a/proton-c/bindings/cpp/src/session.cpp
+++ b/proton-c/bindings/cpp/src/session.cpp
@@ -60,12 +60,12 @@ connection &session::connection() {
return connection_impl::reactor_reference(c);
}
-receiver session::create_receiver(std::string name) {
+receiver session::create_receiver(const std::string& name) {
pn_link_t *link = pn_receiver(impl_, name.c_str());
return receiver(link);
}
-sender session::create_sender(std::string name) {
+sender session::create_sender(const std::string& name) {
pn_link_t *link = pn_sender(impl_, name.c_str());
return sender(link);
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/bindings/cpp/src/url.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/url.cpp b/proton-c/bindings/cpp/src/url.cpp
index d5ab411..4b8d956 100644
--- a/proton-c/bindings/cpp/src/url.cpp
+++ b/proton-c/bindings/cpp/src/url.cpp
@@ -22,6 +22,8 @@
#include "proton/error.hpp"
#include "proton/url.hpp"
#include "proton/url.h"
+#include <ostream>
+#include <istream>
namespace proton {
@@ -52,6 +54,8 @@ url::url() : url_(pn_url()) {}
url::url(const std::string &s, bool d) : url_(parse_throw(s)) { if (d) defaults(); }
+url::url(const char *s, bool d) : url_(parse_throw(s)) { if (d) defaults(); }
+
url::url(const url& u) : url_(parse_allow_empty(u.str())) {}
url::~url() { pn_url_free(url_); }
@@ -60,6 +64,8 @@ url& url::operator=(const url& u) { replace(url_, parse_allow_empty(u.str())); r
void url::parse(const std::string& s) { replace(url_, parse_throw(s)); }
+void url::parse(const char *s) { replace(url_, parse_throw(s)); }
+
std::string url::str() const { return char_str(pn_url_str(url_)); }
std::string url::scheme() const { return char_str(pn_url_get_scheme(url_)); }
@@ -90,4 +96,19 @@ const std::string url::AMQPS("amqps");
std::ostream& operator<<(std::ostream& o, const url& u) { return o << u.str(); }
+std::istream& operator>>(std::istream& i, url& u) {
+ std::string s;
+ i >> s;
+ if (!i.fail() && !i.bad()) {
+ pn_url_t* p = pn_url_parse(s.c_str());
+ if (p) {
+ replace(u.url_, p);
+ u.defaults();
+ } else {
+ i.clear(std::ios::failbit);
+ }
+ }
+ return i;
+}
+
} // namespace proton
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/035b6957/proton-c/include/proton/message.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/message.h b/proton-c/include/proton/message.h
index 837b95e..42e45f5 100644
--- a/proton-c/include/proton/message.h
+++ b/proton-c/include/proton/message.h
@@ -389,7 +389,7 @@ PN_EXTERN const char * pn_message_get_subject (pn_message_t *msg);
PN_EXTERN int pn_message_set_subject (pn_message_t *msg, const char *subject);
/**
- * Get the reply_to for a message.
+o * Get the reply_to for a message.
*
* This operation will return NULL if no reply_to has been set or if
* the reply_to has been set to NULL. The pointer returned by this
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org