Repository: qpid-proton Updated Branches: refs/heads/master 552f43911 -> 2dc4afe08
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/symbol.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/symbol.hpp b/proton-c/bindings/cpp/include/proton/symbol.hpp index 7a5764a..026154f 100644 --- a/proton-c/bindings/cpp/include/proton/symbol.hpp +++ b/proton-c/bindings/cpp/include/proton/symbol.hpp @@ -1,6 +1,8 @@ -#ifndef SYMBOL_HPP -#define SYMBOL_HPP +#ifndef PROTON_SYMBOL_HPP +#define PROTON_SYMBOL_HPP + /* + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -17,23 +19,26 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. + * */ namespace proton { -/// symbol is a std::string that represents the AMQP symbol type. -/// A symbol can only contain 7-bit ASCII characters. +/// A std::string that represents the AMQP symbol type. /// +/// A symbol can only contain 7-bit ASCII characters. class symbol : public std::string { public: - /// Construct from a std::string + /// Construct from a std::string. symbol(const std::string& s=std::string()) : std::string(s) {} - /// Construct from a C-string + + /// Construct from a C string. symbol(const char* s) : std::string(s) {} - /// Construct from any sequence of char + + /// Construct from any sequence of char. template<class Iter> symbol(Iter start, Iter finish) : std::string(start, finish) {} }; -} +} // proton -#endif // SYMBOL_HPP +#endif // PROTON_SYMBOL_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/target.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/target.hpp b/proton-c/bindings/cpp/include/proton/target.hpp index 0415038..096d805 100644 --- a/proton-c/bindings/cpp/include/proton/target.hpp +++ b/proton-c/bindings/cpp/include/proton/target.hpp @@ -1,5 +1,5 @@ -#ifndef PROTON_CPP_TARGET_H -#define PROTON_CPP_TARGET_H +#ifndef PROTON_TARGET_HPP +#define PROTON_TARGET_HPP /* * @@ -23,7 +23,7 @@ */ #include "proton/export.hpp" -#include "proton/object.hpp" +#include "proton/internal/object.hpp" #include "proton/value.hpp" #include "proton/terminus.hpp" @@ -34,31 +34,32 @@ namespace proton { class sender; class receiver; -/// /// The target is the destination node of a sent or received message. /// -/// @see proton::sender proton::receiver proton::target +/// @see proton::sender, proton::receiver, proton::target class target : public terminus { public: + /// Create an empty target. target() : terminus() {} using terminus::durability_mode; using terminus::expiry_policy; + /// The address of the target. PN_CPP_EXTERN std::string address() const; - /// @cond INTERNAL private: target(pn_terminus_t* t); target(const sender&); target(const receiver&); + + /// @cond INTERNAL friend class internal::factory<target>; friend class sender; friend class receiver; /// @endcond - }; -} +} // proton -#endif // PROTON_CPP_TARGET_H +#endif // PROTON_TARGET_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/target_options.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/target_options.hpp b/proton-c/bindings/cpp/include/proton/target_options.hpp index bafc363..739f38d 100644 --- a/proton-c/bindings/cpp/include/proton/target_options.hpp +++ b/proton-c/bindings/cpp/include/proton/target_options.hpp @@ -1,5 +1,5 @@ -#ifndef PROTON_CPP_TARGET_OPTIONS_H -#define PROTON_CPP_TARGET_OPTIONS_H +#ifndef PROTON_TARGET_OPTIONS_HPP +#define PROTON_TARGET_OPTIONS_HPP /* * @@ -24,7 +24,7 @@ #include "proton/config.hpp" #include "proton/export.hpp" -#include "proton/pn_unique_ptr.hpp" +#include "proton/internal/pn_unique_ptr.hpp" #include "proton/types.hpp" #include "proton/delivery_mode.hpp" #include "proton/target.hpp" @@ -40,13 +40,12 @@ class target; /// Options for creating a target node for a sender or receiver. /// -/// Options can be "chained" (@see proton::connection_options). +/// Options can be "chained" (see proton::connection_options). /// /// Normal value semantics: copy or assign creates a separate copy of /// the options. class target_options { public: - /// Create an empty set of options. PN_CPP_EXTERN target_options(); @@ -74,20 +73,19 @@ class target_options { /// Control when the clock for expiration begins. PN_CPP_EXTERN target_options& expiry_policy(enum target::expiry_policy); - - /// @cond INTERNAL private: void apply(target&) const; class impl; internal::pn_unique_ptr<impl> impl_; - friend class target; - friend class sender_options; - friend class receiver_options; + /// @cond INTERNAL + friend class target; + friend class sender_options; + friend class receiver_options; /// @endcond }; -} +} // proton -#endif // PROTON_CPP_TARGET_OPTIONS_H +#endif // PROTON_TARGET_OPTIONS_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/task.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/task.hpp b/proton-c/bindings/cpp/include/proton/task.hpp index b833a48..cd3ac84 100644 --- a/proton-c/bindings/cpp/include/proton/task.hpp +++ b/proton-c/bindings/cpp/include/proton/task.hpp @@ -1,5 +1,5 @@ -#ifndef PROTON_CPP_TASK_H -#define PROTON_CPP_TASK_H +#ifndef PROTON_TASK_HPP +#define PROTON_TASK_HPP /* * @@ -23,16 +23,16 @@ */ /// @cond INTERNAL -/// XXX needs more discussion +/// XXX Needs more discussion #include "proton/export.hpp" -#include "proton/object.hpp" +#include "proton/internal/object.hpp" #include "proton/reactor.h" namespace proton { -/// A task for timer events. +/// **Experimental** - A task for timer events. class task : public internal::object<pn_task_t> { public: task(pn_task_t* t) : internal::object<pn_task_t>(t) {} @@ -41,8 +41,8 @@ class task : public internal::object<pn_task_t> { PN_CPP_EXTERN void cancel(); }; -} +} // proton /// @endcond -#endif // PROTON_CPP_TASK_H +#endif // PROTON_TASK_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/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 cdcb7d3..403df0a 100644 --- a/proton-c/bindings/cpp/include/proton/terminus.hpp +++ b/proton-c/bindings/cpp/include/proton/terminus.hpp @@ -1,5 +1,5 @@ -#ifndef PROTON_CPP_TERMINUS_H -#define PROTON_CPP_TERMINUS_H +#ifndef PROTON_TERMINUS_HPP +#define PROTON_TERMINUS_HPP /* * @@ -23,7 +23,7 @@ */ #include "proton/export.hpp" -#include "proton/object.hpp" +#include "proton/internal/object.hpp" #include "proton/value.hpp" #include "proton/link.h" @@ -45,20 +45,31 @@ class terminus { public: terminus() : object_(0), parent_(0) {} + /// The persistence mode of the source or target. enum durability_mode { - NONDURABLE = PN_NONDURABLE, - CONFIGURATION = PN_CONFIGURATION, - UNSETTLED_STATE = PN_DELIVERIES + /// No persistence. + NONDURABLE = PN_NONDURABLE, + /// Only configuration is persisted. + CONFIGURATION = PN_CONFIGURATION, + /// Configuration and unsettled state are persisted. + UNSETTLED_STATE = PN_DELIVERIES }; + /// When expiration of the source or target begins. enum expiry_policy { - LINK_CLOSE = PN_EXPIRE_WITH_LINK, - SESSION_CLOSE = PN_EXPIRE_WITH_SESSION, - CONNECTION_CLOSE = PN_EXPIRE_WITH_CONNECTION, - NEVER = PN_EXPIRE_NEVER + /// When the link is closed. + LINK_CLOSE = PN_EXPIRE_WITH_LINK, + /// When the containing session is closed. + SESSION_CLOSE = PN_EXPIRE_WITH_SESSION, + /// When the containing connection is closed. + CONNECTION_CLOSE = PN_EXPIRE_WITH_CONNECTION, + /// The terminus never expires. + NEVER = PN_EXPIRE_NEVER }; - /// Control when the clock for expiration begins. + // XXX This should have address? + + /// Get the policy for when expiration begins. PN_CPP_EXTERN enum expiry_policy expiry_policy() const; /// The period after which the source is discarded on expiry. The @@ -75,19 +86,19 @@ class terminus { /// terminus. See also lifetime_policy. PN_CPP_EXTERN value node_properties() const; - /// @cond INTERNAL protected: pn_terminus_t *pn_object() { return object_; } private: pn_terminus_t* object_; pn_link_t* parent_; + /// @cond INTERNAL friend class internal::factory<terminus>; friend class source; friend class target; /// @endcond }; -} +} // proton -#endif // PROTON_CPP_TERMINUS_H +#endif // PROTON_TERMINUS_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/thread_safe.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/thread_safe.hpp b/proton-c/bindings/cpp/include/proton/thread_safe.hpp index b721f76..4ba06de 100644 --- a/proton-c/bindings/cpp/include/proton/thread_safe.hpp +++ b/proton-c/bindings/cpp/include/proton/thread_safe.hpp @@ -2,6 +2,7 @@ #define PROTON_THREAD_SAFE_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 @@ -15,22 +16,24 @@ * 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 - pp * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. + * */ -#include <proton/config.hpp> -#include <proton/connection.hpp> -#include <proton/event_loop.hpp> -#include <proton/object.hpp> -#include <proton/type_traits.hpp> +#include "proton/config.hpp" +#include "proton/connection.hpp" +#include "proton/event_loop.hpp" +#include "proton/internal/object.hpp" +#include "proton/internal/type_traits.hpp" #include <functional> // FIXME aconway 2016-05-03: doc namespace proton { + class connection; class session; class link; @@ -49,21 +52,22 @@ template<> struct endpoint_traits<receiver> {}; template <class T> class returned; // FIXME aconway 2016-05-09: doc -/// Events for each proton::connection are processed sequentially in an -/// event-loop. proton::handler functions for a single connection are never -/// called concurrently. inject() lets you add user-defined function calls to -/// be processed in the event loop sequence. +/// **Experimental** - A thread-safe object wrapper. +/// +/// Events for each proton::connection are processed sequentially in +/// an event_loop. proton::handler functions for a single connection +/// are never called concurrently. inject() lets you add user-defined +/// function calls to be processed in the event loop sequence. /// -/// thread_safe is useful with multi-threaded programs, where different -/// connection's event-loops can run concurrently. Proton objects associated -/// with a connection (proton::connection, proton:sender etc.) are not thread -/// safe, so they can only be used in the context of the connections thread_safe. -/// inject() allows any thread (application threads or thread_safe threads for +/// thread_safe is useful with multi-threaded programs, where +/// different connection's event loops can run concurrently. Proton +/// objects associated with a connection (proton::connection, +/// proton::sender, etc.) are not thread safe, so they can only be +/// used in the context of the connection's thread_safe. inject() +/// allows any thread (application threads or thread_safe threads for /// different connections) to communicate safely. -/// template <class T> -class thread_safe : private internal::pn_ptr_base, private internal::endpoint_traits<T> -{ +class thread_safe : private internal::pn_ptr_base, private internal::endpoint_traits<T> { typedef typename T::pn_type pn_type; struct inject_decref : public inject_handler { @@ -73,7 +77,9 @@ class thread_safe : private internal::pn_ptr_base, private internal::endpoint_tr }; public: + /// @cond INTERNAL static void operator delete(void*) {} + /// @endcond ~thread_safe() { if (ptr()) { @@ -89,14 +95,20 @@ class thread_safe : private internal::pn_ptr_base, private internal::endpoint_tr } } + /// Get the event loop for this object. class event_loop* event_loop() { return event_loop::get(ptr()); } + /// @cond INTERNAL + /// XXX Not sure what the status of these is + // FIXME aconway 2016-05-04: doc T unsafe() { return T(ptr()); } // Caller must delete static thread_safe* create(const T& obj) { return new (obj.pn_object()) thread_safe(); } + /// @endcond + private: static void* operator new(size_t, pn_type* p) { return p; } static void operator delete(void*, pn_type*) {} @@ -107,7 +119,9 @@ class thread_safe : private internal::pn_ptr_base, private internal::endpoint_tr thread_safe(const thread_safe&); thread_safe& operator=(const thread_safe&); + /// @cond INTERNAL friend class returned<T>; + /// @endcond }; // FIXME aconway 2016-05-04: doc. @@ -148,13 +162,16 @@ class returned : private internal::endpoint_traits<T> mutable thread_safe<T>* ptr_; }; +// XXX Review this text +/// Make a thread-safe wrapper for `obj`. template <class T> returned<T> make_thread_safe(const T& obj) { return returned<T>(thread_safe<T>::create(obj)); } +// XXX Review this text +/// Get a thread-unsafe pointer for `p`. template <class T> T make_thread_unsafe(T* p) { return p->unsafe(); } - #if PN_CPP_HAS_CPP11 template <class T> std::shared_ptr<thread_safe<T> > make_shared_thread_safe(const T& obj) { return std::shared_ptr<thread_safe<T> >(thread_safe<T>::create(obj)); @@ -167,7 +184,6 @@ template <class T> T make_thread_unsafe(const std::shared_ptr<T>& p) { return p- template <class T> T make_thread_unsafe(const std::unique_ptr<T>& p) { return p->unsafe(); } #endif - -} +} // proton #endif // PROTON_THREAD_SAFE_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/timestamp.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/timestamp.hpp b/proton-c/bindings/cpp/include/proton/timestamp.hpp index 7736e00..01c317d 100644 --- a/proton-c/bindings/cpp/include/proton/timestamp.hpp +++ b/proton-c/bindings/cpp/include/proton/timestamp.hpp @@ -1,5 +1,6 @@ -#ifndef TIMESTAMP_HPP -#define TIMESTAMP_HPP +#ifndef PROTON_TIMESTAMP_HPP +#define PROTON_TIMESTAMP_HPP + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -22,32 +23,44 @@ #include "proton/duration.hpp" namespace proton { -/// 64 bit timestamp in milliseconds since the epoch 00:00:00 (UTC), 1 January 1970. + +/// A 64-bit timestamp in milliseconds since the Unix epoch. +/// +/// The dawn of the Unix epoch was 00:00:00 (UTC), 1 January 1970. class timestamp : private internal::comparable<timestamp> { public: - typedef int64_t numeric_type; ///< Numeric type holding milliseconds value - PN_CPP_EXTERN static timestamp now(); ///< Current wall-clock time + /// A numeric type holding a milliseconds value. + typedef int64_t numeric_type; + + /// The current wall-clock time. + PN_CPP_EXTERN static timestamp now(); - explicit timestamp(numeric_type ms = 0) : ms_(ms) {} ///< Construct from milliseconds - timestamp& operator=(numeric_type ms) { ms_ = ms; return *this; } ///< Assign from milliseconds - numeric_type milliseconds() const { return ms_; } ///< Get milliseconds + /// Construct from milliseconds. + explicit timestamp(numeric_type ms = 0) : ms_(ms) {} + + /// Assign from milliseconds. + timestamp& operator=(numeric_type ms) { ms_ = ms; return *this; } + + /// Get milliseconds. + numeric_type milliseconds() const { return ms_; } private: numeric_type ms_; }; -///@name Comparison and arithmetic operators -///@{ +/// @name Comparison and arithmetic operators +/// @{ inline bool operator==(timestamp x, timestamp y) { return x.milliseconds() == y.milliseconds(); } inline bool operator<(timestamp x, timestamp y) { return x.milliseconds() < y.milliseconds(); } inline timestamp operator+(timestamp ts, duration d) { return timestamp(ts.milliseconds() + d.milliseconds()); } inline duration operator-(timestamp t0, timestamp t1) { return duration(t0.milliseconds() - t1.milliseconds()); } inline timestamp operator+(duration d, timestamp ts) { return ts + d; } -///@} +/// @} /// Printable format. PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, timestamp); -} -#endif // TIMESTAMP_HPP +} // proton + +#endif // PROTON_TIMESTAMP_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/tracker.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/tracker.hpp b/proton-c/bindings/cpp/include/proton/tracker.hpp index e35d1f8..e6f7c5d 100644 --- a/proton-c/bindings/cpp/include/proton/tracker.hpp +++ b/proton-c/bindings/cpp/include/proton/tracker.hpp @@ -1,5 +1,5 @@ -#ifndef PROTON_CPP_TRACKER_H -#define PROTON_CPP_TRACKER_H +#ifndef PROTON_TRACKER_HPP +#define PROTON_TRACKER_HPP /* * @@ -29,23 +29,28 @@ struct pn_delivery_t; namespace proton { -/// A message transfer. Every delivery exists within the context of a -/// proton::link. A delivery attempt can fail. As a result, a -/// particular message may correspond to multiple deliveries. +/// A tracker for a sent message. Every tracker exists within the +/// context of a sender. +/// +/// A delivery attempt can fail. As a result, a particular message may +/// correspond to multiple trackers. class tracker : public transfer { /// @cond INTERNAL tracker(pn_delivery_t* d); /// @endcond public: + /// Create an empty tracker. tracker() {} - // Return the sender for this tracker + /// Get the sender for this tracker. PN_CPP_EXTERN class sender sender() const; + // @cond INTERNAL friend class internal::factory<tracker>; + // @endcond }; -} +} // proton -#endif // PROTON_CPP_TRACKER_H +#endif // PROTON_TRACKER_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/transfer.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/transfer.hpp b/proton-c/bindings/cpp/include/proton/transfer.hpp index f37984d..fcbe3c6 100644 --- a/proton-c/bindings/cpp/include/proton/transfer.hpp +++ b/proton-c/bindings/cpp/include/proton/transfer.hpp @@ -1,5 +1,5 @@ -#ifndef PROTON_CPP_TRANSFER_H -#define PROTON_CPP_TRANSFER_H +#ifndef PROTON_TRANSFER_HPP +#define PROTON_TRANSFER_HPP /* * @@ -23,31 +23,30 @@ */ #include "proton/export.hpp" -#include "proton/object.hpp" +#include "proton/internal/object.hpp" #include "proton/delivery.h" #include "proton/disposition.h" namespace proton { -/// A message transfer. Every delivery exists within the context of a -/// proton::link. A delivery attempt can fail. As a result, a -/// particular message may correspond to multiple deliveries. +/// The base class for delivery and tracker. class transfer : public internal::object<pn_delivery_t> { /// @cond INTERNAL transfer(pn_delivery_t* d) : internal::object<pn_delivery_t>(d) {} /// @endcond public: + /// Create an empty transfer. transfer() : internal::object<pn_delivery_t>(0) {} - /// Return the session for this transfer + /// Return the session for this transfer. PN_CPP_EXTERN class session session() const; - /// Return the connection for this transfer + /// Return the connection for this transfer. PN_CPP_EXTERN class connection connection() const; - /// Return the container for this transfer + /// Return the container for this transfer. PN_CPP_EXTERN class container &container() const; /// Settle the delivery; informs the remote end. @@ -56,7 +55,6 @@ class transfer : public internal::object<pn_delivery_t> { /// Return true if the transfer has been settled. PN_CPP_EXTERN bool settled() const; - /// @cond INTERNAL protected: /// Delivery state values. enum state { @@ -77,10 +75,11 @@ class transfer : public internal::object<pn_delivery_t> { /// Get the remote state for a delivery. enum state state() const; + /// @cond INTERNAL friend class internal::factory<transfer>; /// @endcond }; -} +} // proton -#endif // PROTON_CPP_TRANSFER_H +#endif // PROTON_TRANSFER_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/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 84b6832..fb704ba 100644 --- a/proton-c/bindings/cpp/include/proton/transport.hpp +++ b/proton-c/bindings/cpp/include/proton/transport.hpp @@ -1,5 +1,5 @@ -#ifndef PROTON_CPP_TRANSPORT_H -#define PROTON_CPP_TRANSPORT_H +#ifndef PROTON_TRANSPORT_HPP +#define PROTON_TRANSPORT_HPP /* * @@ -22,7 +22,7 @@ * */ -#include "proton/object.hpp" +#include "proton/internal/object.hpp" #include "proton/types.hpp" #include "proton/export.hpp" @@ -38,12 +38,14 @@ namespace io { class connection_engine; } +/// A network channel supporting an AMQP connection. class transport : public internal::object<pn_transport_t> { /// @cond INTERNAL transport(pn_transport_t* t) : internal::object<pn_transport_t>(t) {} /// @endcond public: + /// Create an empty transport. transport() : internal::object<pn_transport_t>(0) {} /// Get the connection associated with this transport. @@ -63,6 +65,6 @@ class transport : public internal::object<pn_transport_t> { /// @endcond }; -} +} // proton -#endif // PROTON_CPP_TRANSPORT_H +#endif // PROTON_TRANSPORT_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/type_id.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/type_id.hpp b/proton-c/bindings/cpp/include/proton/type_id.hpp index d454bc3..711100f 100644 --- a/proton-c/bindings/cpp/include/proton/type_id.hpp +++ b/proton-c/bindings/cpp/include/proton/type_id.hpp @@ -2,6 +2,7 @@ #define PROTON_TYPE_ID_HPP /* + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -18,14 +19,17 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. + * */ -///@file +/// @file /// /// Type-identifiers for AMQP types. -#include <proton/export.hpp> -#include <proton/codec.h> +#include "proton/export.hpp" + +#include "proton/codec.h" + #include <string> namespace proton { @@ -34,29 +38,29 @@ namespace proton { enum type_id { NULL_TYPE = PN_NULL, ///< The null type, contains no data. BOOLEAN = PN_BOOL, ///< Boolean true or false. - UBYTE = PN_UBYTE, ///< Unsigned 8 bit integer. - BYTE = PN_BYTE, ///< Signed 8 bit integer. - USHORT = PN_USHORT, ///< Unsigned 16 bit integer. - SHORT = PN_SHORT, ///< Signed 16 bit integer. - UINT = PN_UINT, ///< Unsigned 32 bit integer. - INT = PN_INT, ///< Signed 32 bit integer. - CHAR = PN_CHAR, ///< 32 bit unicode character. - ULONG = PN_ULONG, ///< Unsigned 64 bit integer. - LONG = PN_LONG, ///< Signed 64 bit integer. - TIMESTAMP = PN_TIMESTAMP, ///< Signed 64 bit milliseconds since the epoch. - FLOAT = PN_FLOAT, ///< 32 bit binary floating point. - DOUBLE = PN_DOUBLE, ///< 64 bit binary floating point. - DECIMAL32 = PN_DECIMAL32, ///< 32 bit decimal floating point. - DECIMAL64 = PN_DECIMAL64, ///< 64 bit decimal floating point. - DECIMAL128 = PN_DECIMAL128, ///< 128 bit decimal floating point. - UUID = PN_UUID, ///< 16 byte UUID. - BINARY = PN_BINARY, ///< Variable length sequence of bytes. - STRING = PN_STRING, ///< Variable length utf8-encoded string. - SYMBOL = PN_SYMBOL, ///< Variable length encoded string. + UBYTE = PN_UBYTE, ///< Unsigned 8-bit integer. + BYTE = PN_BYTE, ///< Signed 8-bit integer. + USHORT = PN_USHORT, ///< Unsigned 16-bit integer. + SHORT = PN_SHORT, ///< Signed 16-bit integer. + UINT = PN_UINT, ///< Unsigned 32-bit integer. + INT = PN_INT, ///< Signed 32-bit integer. + CHAR = PN_CHAR, ///< 32-bit unicode character. + ULONG = PN_ULONG, ///< Unsigned 64-bit integer. + LONG = PN_LONG, ///< Signed 64-bit integer. + TIMESTAMP = PN_TIMESTAMP, ///< Signed 64-bit milliseconds since the epoch. + FLOAT = PN_FLOAT, ///< 32-bit binary floating point. + DOUBLE = PN_DOUBLE, ///< 64-bit binary floating point. + DECIMAL32 = PN_DECIMAL32, ///< 32-bit decimal floating point. + DECIMAL64 = PN_DECIMAL64, ///< 64-bit decimal floating point. + DECIMAL128 = PN_DECIMAL128, ///< 128-bit decimal floating point. + UUID = PN_UUID, ///< 16-byte UUID. + BINARY = PN_BINARY, ///< Variable-length sequence of bytes. + STRING = PN_STRING, ///< Variable-length utf8-encoded string. + SYMBOL = PN_SYMBOL, ///< Variable-length encoded string. DESCRIBED = PN_DESCRIBED, ///< A descriptor and a value. ARRAY = PN_ARRAY, ///< A sequence of values of the same type. - LIST = PN_LIST, ///< A sequence of values, may be of mixed types. - MAP = PN_MAP ///< A sequence of key:value pairs, may be of mixed types. + LIST = PN_LIST, ///< A sequence of values of mixed types. + MAP = PN_MAP ///< A sequence of key-value pairs. }; /// Get the name of the AMQP type. @@ -65,11 +69,12 @@ PN_CPP_EXTERN std::string type_name(type_id); /// Print the type name. PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, type_id); -/// Throw a conversion_error if want != got with a message including the names of the types. +/// Throw a conversion_error if want != got with a message including +/// the names of the types. PN_CPP_EXTERN void assert_type_equal(type_id want, type_id got); -///@name Test propreties of a type_id. -///@{ +/// @name Test the properties of a type_id. +/// @{ inline bool type_id_is_signed_int(type_id t) { return t == BYTE || t == SHORT || t == INT || t == LONG; } inline bool type_id_is_unsigned_int(type_id t) { return t == UBYTE || t == USHORT || t == UINT || t == ULONG; } inline bool type_id_is_integral(type_id t) { return t == BOOLEAN || t == CHAR || t == TIMESTAMP || type_id_is_unsigned_int(t) || type_id_is_signed_int(t); } @@ -80,8 +85,8 @@ inline bool type_id_is_string_like(type_id t) { return t == BINARY || t == STRIN inline bool type_id_is_container(type_id t) { return t == LIST || t == MAP || t == ARRAY || t == DESCRIBED; } inline bool type_id_is_scalar(type_id t) { return type_id_is_integral(t) || type_id_is_floating_point(t) || type_id_is_decimal(t) || type_id_is_string_like(t) || t == TIMESTAMP || t == UUID; } inline bool type_id_is_null(type_id t) { return t == NULL_TYPE; } -///} +/// } } // proton -#endif /*!PROTON_TYPE_ID_HPP*/ +#endif // PROTON_TYPE_ID_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/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 deleted file mode 100644 index db4d685..0000000 --- a/proton-c/bindings/cpp/include/proton/type_traits.hpp +++ /dev/null @@ -1,153 +0,0 @@ -#ifndef PROTON_TYPE_TRAITS_HPP -#define PROTON_TYPE_TRAITS_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: Type traits for mapping between AMQP and C++ types. -/// -/// Also provides workarounds for missing type_traits classes on older -/// C++ compilers. - -#include <proton/config.hpp> -#include <proton/types_fwd.hpp> -#include <proton/type_id.hpp> - -///@cond INTERNAL -namespace proton { -namespace internal { - -class decoder; -class encoder; - -template <bool, class T=void> struct enable_if {}; -template <class T> struct enable_if<true, T> { typedef T type; }; - -struct true_type { static const bool value = true; }; -struct false_type { static const bool value = false; }; - -template <class T> struct is_integral : public false_type {}; -template <class T> struct is_signed : public false_type {}; - -template <> struct is_integral<char> : public true_type {}; -template <> struct is_signed<char> : public false_type {}; - -template <> struct is_integral<unsigned char> : public true_type {}; -template <> struct is_integral<unsigned short> : public true_type {}; -template <> struct is_integral<unsigned int> : public true_type {}; -template <> struct is_integral<unsigned long> : public true_type {}; - -template <> struct is_integral<signed char> : public true_type {}; -template <> struct is_integral<signed short> : public true_type {}; -template <> struct is_integral<signed int> : public true_type {}; -template <> struct is_integral<signed long> : public true_type {}; - -template <> struct is_signed<unsigned short> : public false_type {}; -template <> struct is_signed<unsigned int> : public false_type {}; -template <> struct is_signed<unsigned long> : public false_type {}; - -template <> struct is_signed<signed char> : public true_type {}; -template <> struct is_signed<signed short> : public true_type {}; -template <> struct is_signed<signed int> : public true_type {}; -template <> struct is_signed<signed long> : public true_type {}; - -#if PN_CPP_HAS_LONG_LONG -template <> struct is_integral<unsigned long long> : public true_type {}; -template <> struct is_integral<signed long long> : public true_type {}; -template <> struct is_signed<unsigned long long> : public false_type {}; -template <> struct is_signed<signed long long> : public true_type {}; -#endif - -template <class T, class U> struct is_same { static const bool value=false; }; -template <class T> struct is_same<T,T> { static const bool value=true; }; - -template< class T > struct remove_const { typedef T type; }; -template< class T > struct remove_const<const T> { typedef T type; }; - -template <type_id ID, class T> struct type_id_constant { - typedef T type; - static const type_id value = ID; -}; - -///@name Metafunction returning AMQP type for scalar C++ types. -///@{ -template <class T> struct type_id_of; -template<> struct type_id_of<bool> : public type_id_constant<BOOLEAN, bool> {}; -template<> struct type_id_of<uint8_t> : public type_id_constant<UBYTE, uint8_t> {}; -template<> struct type_id_of<int8_t> : public type_id_constant<BYTE, int8_t> {}; -template<> struct type_id_of<uint16_t> : public type_id_constant<USHORT, uint16_t> {}; -template<> struct type_id_of<int16_t> : public type_id_constant<SHORT, int16_t> {}; -template<> struct type_id_of<uint32_t> : public type_id_constant<UINT, uint32_t> {}; -template<> struct type_id_of<int32_t> : public type_id_constant<INT, int32_t> {}; -template<> struct type_id_of<uint64_t> : public type_id_constant<ULONG, uint64_t> {}; -template<> struct type_id_of<int64_t> : public type_id_constant<LONG, int64_t> {}; -template<> struct type_id_of<wchar_t> : public type_id_constant<CHAR, wchar_t> {}; -template<> struct type_id_of<float> : public type_id_constant<FLOAT, float> {}; -template<> struct type_id_of<double> : public type_id_constant<DOUBLE, double> {}; -template<> struct type_id_of<timestamp> : public type_id_constant<TIMESTAMP, timestamp> {}; -template<> struct type_id_of<decimal32> : public type_id_constant<DECIMAL32, decimal32> {}; -template<> struct type_id_of<decimal64> : public type_id_constant<DECIMAL64, decimal64> {}; -template<> struct type_id_of<decimal128> : public type_id_constant<DECIMAL128, decimal128> {}; -template<> struct type_id_of<uuid> : public type_id_constant<UUID, uuid> {}; -template<> struct type_id_of<std::string> : public type_id_constant<STRING, std::string> {}; -template<> struct type_id_of<symbol> : public type_id_constant<SYMBOL, symbol> {}; -template<> struct type_id_of<binary> : public type_id_constant<BINARY, binary> {}; -///@} - -/// Metafunction to test if a class has a type_id. -template <class T, class Enable=void> struct has_type_id : public false_type {}; -template <class T> struct has_type_id<T, typename type_id_of<T>::type> : public true_type {}; - -// Map arbitrary integral types to known AMQP integral types. -template<size_t SIZE, bool IS_SIGNED> struct integer_type; -template<> struct integer_type<1, true> { typedef int8_t type; }; -template<> struct integer_type<2, true> { typedef int16_t type; }; -template<> struct integer_type<4, true> { typedef int32_t type; }; -template<> struct integer_type<8, true> { typedef int64_t type; }; -template<> struct integer_type<1, false> { typedef uint8_t type; }; -template<> struct integer_type<2, false> { typedef uint16_t type; }; -template<> struct integer_type<4, false> { typedef uint32_t type; }; -template<> struct integer_type<8, false> { typedef uint64_t type; }; - -// True if T is an integer type that does not have an explicit type_id. -template <class T> struct is_unknown_integer { - static const bool value = !has_type_id<T>::value && is_integral<T>::value; -}; - -// Helper base for SFINAE test templates. -struct sfinae { - typedef char yes; - typedef double no; - struct wildcard { wildcard(...); }; -}; - -template <class From, class To> struct is_convertible : public sfinae { - static yes test(const To&); - static no test(...); - static const From& from; - static bool const value = sizeof(test(from)) == sizeof(yes); -}; - -} // internal -} // proton -//@endcond - -#endif // PROTON_TYPE_TRAITS_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/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 66f0f93..08a4d05 100644 --- a/proton-c/bindings/cpp/include/proton/types.hpp +++ b/proton-c/bindings/cpp/include/proton/types.hpp @@ -1,6 +1,8 @@ #ifndef PROTON_TYPES_HPP #define PROTON_TYPES_HPP + /* + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -17,115 +19,37 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. + * */ -///@file +/// @file /// -/// Include the definitions of all proton types used to represent AMQP types. - -/**@page types AMQP and C++ types - -@details - -An AMQP message body can hold binary data using any encoding you like. AMQP also -defines its own encoding and types. The AMQP encoding is often used in message -bodies because it is supported by AMQP libraries on many languages and -platforms. You also need to use the AMQP types to set and examine message -properties. - -## Scalar types - -Each type is identified by a proton::type_id. - -C++ type | AMQP type_id | Description ---------------------|----------------------|----------------------- -bool | proton::BOOLEAN | Boolean true/false -uint8_t | proton::UBYTE | 8 bit unsigned byte -int8_t | proton::BYTE | 8 bit signed byte -uint16_t | proton::USHORT | 16 bit unsigned integer -int16_t | proton::SHORT | 16 bit signed integer -uint32_t | proton::UINT | 32 bit unsigned integer -int32_t | proton::INT | 32 bit signed integer -uint64_t | proton::ULONG | 64 bit unsigned integer -int64_t | proton::LONG | 64 bit signed integer -wchar_t | proton::CHAR | 32 bit unicode code point -float | proton::FLOAT | 32 bit binary floating point -double | proton::DOUBLE | 64 bit binary floating point -proton::timestamp | proton::TIMESTAMP | 64 bit signed milliseconds since 00:00:00 (UTC), 1 January 1970. -proton::decimal32 | proton::DECIMAL32 | 32 bit decimal floating point -proton::decimal64 | proton::DECIMAL64 | 64 bit decimal floating point -proton::decimal128 | proton::DECIMAL128 | 128 bit decimal floating point -proton::uuid | proton::UUID | 128 bit universally-unique identifier -std::string | proton::STRING | UTF-8 encoded unicode string -proton::symbol | proton::SYMBOL | 7-bit ASCII encoded string -proton::binary | proton::BINARY | Variable-length binary data - -proton::scalar is a holder that can hold a scalar value of any type. - -## Compound types - -C++ type | AMQP type_id | Description ---------------------|----------------------|----------------------- -see below | proton::ARRAY | Sequence of values of the same type -see below | proton::LIST | Sequence of values of mixed types -see below | proton::MAP | Map of key/value pairs - -proton::value is a holder that can hold any AMQP value, scalar or compound - -proton::ARRAY converts to/from C++ sequences: std::vector, std::deque, std::list and -std::forward_list. - -proton::LIST converts to/from sequences of proton::value or proton::scalar, -which can hold mixed types of data. - -proton::MAP converts to/from std::map, std::unordered_map and sequences of -std::pair. - -When decoding the encoded map types must be convertible to element type of the -C++ sequence or the key/value types of the C++ map. Use proton::value as the -element or key/value type to decode any ARRAY/LIST/MAP. - -For example you can decode any AMQP MAP into: - - std::map<proton::value, proton::value> - -You can decode any AMQP LIST or ARRAY into - - std::vector<proton::value> - -## Include files - -You can simply include proton/types.hpp to include all the type definitions and -conversions. Alternatively, you can selectively include only what you need: - - - proton/types_fwd.hpp: forward declarations for all types. - - proton/list.hpp, proton/vector.hpp etc.: conversions for std::list, std::vector etc. - - include individual .hpp files as per the table above. -*/ +/// Include the definitions of all proton types used to represent AMQP +/// types. // TODO aconway 2016-03-15: described types, described arrays. -#include <proton/annotation_key.hpp> -#include <proton/binary.hpp> -#include <proton/config.hpp> -#include <proton/decimal.hpp> -#include <proton/deque.hpp> -#include <proton/duration.hpp> -#include <proton/list.hpp> -#include <proton/map.hpp> -#include <proton/message_id.hpp> -#include <proton/scalar.hpp> -#include <proton/symbol.hpp> -#include <proton/timestamp.hpp> -#include <proton/types_fwd.hpp> -#include <proton/uuid.hpp> -#include <proton/value.hpp> -#include <proton/vector.hpp> +#include "proton/annotation_key.hpp" +#include "proton/binary.hpp" +#include "proton/codec/deque.hpp" +#include "proton/codec/list.hpp" +#include "proton/codec/map.hpp" +#include "proton/codec/vector.hpp" +#include "proton/config.hpp" +#include "proton/decimal.hpp" +#include "proton/duration.hpp" +#include "proton/message_id.hpp" +#include "proton/scalar.hpp" +#include "proton/symbol.hpp" +#include "proton/timestamp.hpp" +#include "proton/types_fwd.hpp" +#include "proton/uuid.hpp" +#include "proton/value.hpp" +#include "proton/config.hpp" -#include <proton/config.hpp> #if PN_CPP_HAS_CPP11 -#include <proton/forward_list.hpp> -#include <proton/unordered_map.hpp> +#include "proton/forward_list.hpp" +#include "proton/unordered_map.hpp" #endif #endif // PROTON_TYPES_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/types_fwd.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/types_fwd.hpp b/proton-c/bindings/cpp/include/proton/types_fwd.hpp index 8ece3de..f850049 100644 --- a/proton-c/bindings/cpp/include/proton/types_fwd.hpp +++ b/proton-c/bindings/cpp/include/proton/types_fwd.hpp @@ -1,6 +1,8 @@ #ifndef PROTON_TYPES_FWD_HPP #define PROTON_TYPES_FWD_HPP + /* + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -17,20 +19,20 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. + * */ - -///@file +/// @file /// -/// Forward declarations for all the C++ types used by proton to represent AMQP types. +/// Forward declarations for all the C++ types used by Proton to +/// represent AMQP types. -#include <proton/config.hpp> +#include "proton/config.hpp" -#include <proton/type_compat.h> +#include "proton/type_compat.h" #include <string> -/// The proton namespace namespace proton { class binary; @@ -51,6 +53,7 @@ struct null { null(std::nullptr_t) {} #endif }; -} + +} // proton #endif // PROTON_TYPES_FWD_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/unordered_map.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/unordered_map.hpp b/proton-c/bindings/cpp/include/proton/unordered_map.hpp deleted file mode 100644 index 43a84d1..0000000 --- a/proton-c/bindings/cpp/include/proton/unordered_map.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef PROTON_UNORDERED_MAP_HPP -#define PROTON_UNORDERED_MAP_HPP -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include <unordered_map> -#include <proton/encoder.hpp> -#include <proton/decoder.hpp> - -namespace proton { -namespace codec { - -/// Encode std::unordered_map<K, T> as amqp::UNORDERED_MAP. -template <class K, class T, class C, class A> -encoder& operator<<(encoder& e, const std::unordered_map<K, T, C, A>& m) { return e << encoder::map(m); } - -/// Decode to std::unordered_map<K, T> from amqp::UNORDERED_MAP. -template <class K, class T, class C, class A> -decoder& operator>>(decoder& d, std::unordered_map<K, T, C, A>& m) { return d >> decoder::associative(m); } - -} // internal -} // proton - -#endif // PROTON_UNORDERED_MAP_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/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 b08dc88..bb21b68 100644 --- a/proton-c/bindings/cpp/include/proton/url.hpp +++ b/proton-c/bindings/cpp/include/proton/url.hpp @@ -1,7 +1,8 @@ -#ifndef URL_HPP -#define URL_HPP +#ifndef PROTON_URL_HPP +#define PROTON_URL_HPP /* + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -18,10 +19,11 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. + * */ -#include <proton/types_fwd.hpp> -#include <proton/error.hpp> +#include "proton/types_fwd.hpp" +#include "proton/error.hpp" #include <iosfwd> @@ -29,15 +31,16 @@ struct pn_url_t; namespace proton { -/// Raised if URL parsing fails. +/// An error encountered during URL parsing. struct PN_CPP_CLASS_EXTERN url_error : public error { /// @cond INTERNAL - PN_CPP_EXTERN explicit url_error(const std::string&); ///< Construct with message + /// Construct a URL error with a message. + PN_CPP_EXTERN explicit url_error(const std::string&); /// @endcond }; -/// A proton URL. +/// A Proton URL. /// /// Proton URLs take the form /// `<scheme>://<username>:<password>@<host>:<port>/<path>`. @@ -54,35 +57,53 @@ class url { static const std::string AMQP; ///< "amqp" prefix static const std::string AMQPS; ///< "amqps" prefix - /// 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. + // XXX No constructor for an empty URL? + // XXX What is the default 'defaults' behavior? + + /// Parse `url_str` as an AMQP URL. /// /// @note Converts automatically from string. - /// /// @throw url_error if URL is invalid. PN_CPP_EXTERN url(const std::string& url_str); + + /// @cond INTERNAL + /// XXX I want to understand why this is important to keep. + /// + /// **Experimental** - 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. + /// @throw url_error if URL is invalid. PN_CPP_EXTERN url(const std::string& url_str, bool defaults); + /// @endcond /// Copy a URL. PN_CPP_EXTERN url(const url&); + PN_CPP_EXTERN ~url(); + /// Copy a URL. PN_CPP_EXTERN url& operator=(const url&); /// True if the URL is empty. PN_CPP_EXTERN bool empty() const; - /// returns the URL as a string + /// Returns the URL as a string PN_CPP_EXTERN operator std::string() const; /// @name URL fields /// /// @{ + /// `amqp` or `amqps`. PN_CPP_EXTERN std::string scheme() const; + /// The user name for authentication. PN_CPP_EXTERN std::string user() const; + // XXX Passwords in URLs are dumb. + /// The password. PN_CPP_EXTERN std::string password() const; + /// The host name or IP address. PN_CPP_EXTERN std::string host() const; /// `port` can be a number or a symbolic name such as "amqp". PN_CPP_EXTERN std::string port() const; @@ -91,6 +112,8 @@ class url { /// host_port returns just the `host:port` part of the URL PN_CPP_EXTERN std::string host_port() const; + // XXX is this not confusing (or incorrect)? The path starts with + // the first / after //. /// `path` is everything after the final "/". PN_CPP_EXTERN std::string path() const; @@ -99,18 +122,21 @@ class url { private: pn_url_t* url_; - friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const url&); + /// @cond INTERNAL + + friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const url&); + // XXX Why is it important to have this? /// Parse `url` from istream. This automatically fills in /// defaults for missing values. /// /// @note An invalid url is indicated by setting /// std::stream::fail(), NOT by throwing url_error. - friend PN_CPP_EXTERN std::istream& operator>>(std::istream&, url&); + friend PN_CPP_EXTERN std::istream& operator>>(std::istream&, url&); /// @endcond }; -} +} // proton -#endif // URL_HPP +#endif // PROTON_URL_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/uuid.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/uuid.hpp b/proton-c/bindings/cpp/include/proton/uuid.hpp index 73970f1..b69f914 100644 --- a/proton-c/bindings/cpp/include/proton/uuid.hpp +++ b/proton-c/bindings/cpp/include/proton/uuid.hpp @@ -1,6 +1,8 @@ -#ifndef UUID_HPP -#define UUID_HPP +#ifndef PROTON_UUID_HPP +#define PROTON_UUID_HPP + /* + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -17,10 +19,11 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. + * */ -#include <proton/byte_array.hpp> -#include <proton/export.hpp> +#include "proton/byte_array.hpp" +#include "proton/export.hpp" #include <string> #include <iosfwd> @@ -30,24 +33,30 @@ namespace proton { /// A 16-byte universally unique identifier. class uuid : public byte_array<16> { public: - /// Return a uuid copied from bytes, bytes must point to at least 16 bytes. - /// If bytes==0 the UUID is zero initialized. + /// Make a copy. PN_CPP_EXTERN static uuid copy(); + + /// Return a uuid copied from bytes. Bytes must point to at least + /// 16 bytes. If `bytes == 0` the UUID is zero-initialized. PN_CPP_EXTERN static uuid copy(const char* bytes); - /// Return a simple randomly-generated UUID. Used by the proton library to - /// generate default UUIDs. For specific security, performance or - /// uniqueness requirements you may want to use a better UUID generator or + /// Return a simple randomly-generated UUID. This is used by the + /// Proton library to generate default UUIDs. + /// + /// For specific security, performance, or uniqueness + /// requirements, you may want to use a better UUID generator or /// some other form of identifier entirely. PN_CPP_EXTERN static uuid random(); - /// UUID standard string format: 8-4-4-4-12 (36 chars, 32 alphanumeric and 4 hypens) + /// UUID standard string format: 8-4-4-4-12 (36 chars, 32 + /// alphanumeric chars and 4 hypens). PN_CPP_EXTERN std::string str() const; }; -/// UUID standard format: 8-4-4-4-12 (36 chars, 32 alphanumeric and 4 hypens) +/// UUID standard format: 8-4-4-4-12 (36 chars, 32 alphanumeric chars +/// and 4 hypens). PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const uuid&); -} +} // proton -#endif // UUID_HPP +#endif // PROTON_UUID_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/value.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/value.hpp b/proton-c/bindings/cpp/include/proton/value.hpp index 7b347f7..3741972 100644 --- a/proton-c/bindings/cpp/include/proton/value.hpp +++ b/proton-c/bindings/cpp/include/proton/value.hpp @@ -2,6 +2,7 @@ #define PROTON_VALUE_HPP /* + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -18,16 +19,18 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. + * */ -#include <proton/encoder.hpp> -#include <proton/decoder.hpp> -#include <proton/type_traits.hpp> -#include <proton/types_fwd.hpp> +#include "proton/codec/encoder.hpp" +#include "proton/codec/decoder.hpp" +#include "proton/internal/type_traits.hpp" +#include "proton/types_fwd.hpp" #include <iosfwd> namespace proton { + class message; namespace internal { @@ -35,10 +38,10 @@ namespace internal { class value_base; PN_CPP_EXTERN std::ostream& operator<<(std::ostream& o, const value_base& x); -///@internal - separate value data from implicit conversion constructors to avoid recursions. +/// Separate value data from implicit conversion constructors to avoid +/// recursions. class value_base { public: - /// Get the type ID for the current value. PN_CPP_EXTERN type_id type() const; @@ -49,16 +52,19 @@ class value_base { codec::data& data() const; mutable class codec::data data_; + /// @cond INTERNAL friend class proton::message; friend class codec::encoder; friend class codec::decoder; friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const value_base&); + /// @endcond }; -} - +} // internal -/// A holder for any AMQP value, simple or complex, see @ref types. +/// A holder for any AMQP value, simple or complex. +/// +/// @see @ref types_page class value : public internal::value_base, private internal::comparable<value> { private: // Enabler for encodable types excluding proton::value. @@ -70,20 +76,20 @@ class value : public internal::value_base, private internal::comparable<value> { /// Create a null value PN_CPP_EXTERN value(); - ///@name Copy a value - ///@{ + /// @name Copy a value + /// @{ PN_CPP_EXTERN value(const value&); PN_CPP_EXTERN value& operator=(const value&); #if PN_CPP_HAS_RVALUE_REFERENCES PN_CPP_EXTERN value(value&&); PN_CPP_EXTERN value& operator=(value&&); #endif - ///@} + /// @} - /// Construct from any allowed type T, see @ref types. + /// Construct from any allowed type T. template <class T> value(const T& x, typename assignable<T>::type* = 0) { *this = x; } - /// Assign from any allowed type T, see @ref types. + /// Assign from any allowed type T. template <class T> typename assignable<T, value&>::type operator=(const T& x) { codec::encoder e(*this); e << x; @@ -93,47 +99,52 @@ class value : public internal::value_base, private internal::comparable<value> { /// Reset the value to null PN_CPP_EXTERN void clear(); - ///@cond INTERNAL (deprecated) + /// @cond INTERNAL (deprecated) template<class T> void get(T &t) const; template<class T> T get() const; PN_CPP_EXTERN int64_t as_int() const; PN_CPP_EXTERN uint64_t as_uint() const; PN_CPP_EXTERN double as_double() const; PN_CPP_EXTERN std::string as_string() const; - ///@endcond + /// @endcond /// swap values friend PN_CPP_EXTERN void swap(value&, value&); - ///@name Comparison operators - ///@{ + + /// @name Comparison operators + /// @{ friend PN_CPP_EXTERN bool operator==(const value& x, const value& y); friend PN_CPP_EXTERN bool operator<(const value& x, const value& y); - ///@} + /// @} - ///@cond INTERNAL + /// @cond INTERNAL PN_CPP_EXTERN explicit value(const codec::data&); - ///@endcond + /// @endcond }; -///@copydoc scalar::get -///@related proton::value +/// @copydoc scalar::get +/// @related proton::value template<class T> T get(const value& v) { T x; get(v, x); return x; } -/// Like get(const value&) but assigns the value to a reference instead of returning it. -/// May be more efficient for complex values (arrays, maps etc.) -///@related proton::value +/// Like get(const value&) but assigns the value to a reference +/// instead of returning it. May be more efficient for complex values +/// (arrays, maps, etc.) +/// +/// @related proton::value template<class T> void get(const value& v, T& x) { codec::decoder d(v, true); d >> x; } -///@copydoc scalar::coerce -///@related proton::value +/// @copydoc scalar::coerce +/// @related proton::value template<class T> T coerce(const value& v) { T x; coerce(v, x); return x; } -/// Like coerce(const value&) but assigns the value to a reference instead of returning it. -/// May be more efficient for complex values (arrays, maps etc.) -///@related proton::value +/// Like coerce(const value&) but assigns the value to a reference +/// instead of returning it. May be more efficient for complex values +/// (arrays, maps, etc.) +/// +/// @related proton::value template<class T> void coerce(const value& v, T& x) { codec::decoder d(v, false); d >> x; } -///@cond INTERNAL +/// @cond INTERNAL template<> inline void get<null>(const value& v, null&) { assert_type_equal(NULL_TYPE, v.type()); } template<class T> void value::get(T &x) const { x = proton::get<T>(*this); } template<class T> T value::get() const { return proton::get<T>(*this); } @@ -141,7 +152,7 @@ inline int64_t value::as_int() const { return proton::coerce<int64_t>(*this); } inline uint64_t value::as_uint() const { return proton::coerce<uint64_t>(*this); } inline double value::as_double() const { return proton::coerce<double>(*this); } inline std::string value::as_string() const { return proton::coerce<std::string>(*this); } -///@endcond +/// @endcond } // proton http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/vector.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/vector.hpp b/proton-c/bindings/cpp/include/proton/vector.hpp deleted file mode 100644 index 1e04b0d..0000000 --- a/proton-c/bindings/cpp/include/proton/vector.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef PROTON_VECTOR_HPP -#define PROTON_VECTOR_HPP -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include <vector> -#include <utility> - -#include <proton/encoder.hpp> -#include <proton/decoder.hpp> - -namespace proton { -namespace codec { - -/// Encode std::vector<T> as amqp::ARRAY (same type elements) -template <class T, class A> encoder& operator<<(encoder& e, const std::vector<T, A>& x) { - return e << encoder::array(x, internal::type_id_of<T>::value); -} - -/// Encode std::vector<value> encode as amqp::LIST (mixed type elements) -template <class A> encoder& operator<<(encoder& e, const std::vector<value, A>& x) { return e << encoder::list(x); } - -/// Encode std::vector<scalar> as amqp::LIST (mixed type elements) -template <class A> encoder& operator<<(encoder& e, const std::vector<scalar, A>& x) { return e << encoder::list(x); } - -/// Encode std::deque<std::pair<k,t> > as amqp::MAP, preserves order of entries. -template <class A, class K, class T> -encoder& operator<<(encoder& e, const std::vector<std::pair<K,T>, A>& x) { return e << encoder::map(x); } - -/// Decode to std::vector<T> from an amqp::LIST or amqp::ARRAY. -template <class T, class A> decoder& operator>>(decoder& d, std::vector<T, A>& x) { return d >> decoder::sequence(x); } - -/// Decode to std::vector<std::pair<K, T> from an amqp::MAP. -template <class A, class K, class T> decoder& operator>>(decoder& d, std::vector<std::pair<K, T> , A>& x) { return d >> decoder::pair_sequence(x); } - -} // internal -} // proton - -#endif // PROTON_VECTOR_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/src/acceptor.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/acceptor.hpp b/proton-c/bindings/cpp/src/acceptor.hpp index 51d1094..82f2f5c 100644 --- a/proton-c/bindings/cpp/src/acceptor.hpp +++ b/proton-c/bindings/cpp/src/acceptor.hpp @@ -1,5 +1,5 @@ -#ifndef PROTON_CPP_ACCEPTOR_H -#define PROTON_CPP_ACCEPTOR_H +#ifndef PROTON_ACCEPTOR_HPP +#define PROTON_ACCEPTOR_HPP /* * @@ -22,9 +22,10 @@ * */ -#include <proton/reactor.h> -#include <proton/export.hpp> -#include <proton/object.hpp> +#include "proton/export.hpp" +#include "proton/internal/object.hpp" + +#include "proton/reactor.h" struct pn_acceptor_t; @@ -52,10 +53,10 @@ class acceptor : public internal::object<pn_acceptor_t> { PN_CPP_EXTERN class connection_options &connection_options(); /// @cond INTERNAL - friend class internal::factory<acceptor>; + friend class internal::factory<acceptor>; /// @endcond }; -} +} // proton -#endif // PROTON_CPP_ACCEPTOR_H +#endif // PROTON_ACCEPTOR_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/src/data.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/data.cpp b/proton-c/bindings/cpp/src/data.cpp index 26583af..3f5aa5e 100644 --- a/proton-c/bindings/cpp/src/data.cpp +++ b/proton-c/bindings/cpp/src/data.cpp @@ -20,9 +20,9 @@ #include "proton_bits.hpp" #include <proton/binary.hpp> +#include <proton/codec/encoder.hpp> #include <proton/data.hpp> #include <proton/decimal.hpp> -#include <proton/encoder.hpp> #include <proton/message_id.hpp> #include <proton/symbol.hpp> #include <proton/timestamp.hpp> http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/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 7bfbeb3..d6ba4e5 100644 --- a/proton-c/bindings/cpp/src/decoder.cpp +++ b/proton-c/bindings/cpp/src/decoder.cpp @@ -19,9 +19,9 @@ #include <proton/annotation_key.hpp> #include <proton/binary.hpp> +#include <proton/codec/encoder.hpp> #include <proton/data.hpp> #include <proton/decimal.hpp> -#include <proton/encoder.hpp> #include <proton/message_id.hpp> #include <proton/scalar.hpp> #include <proton/symbol.hpp> http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/src/encoder.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/encoder.cpp b/proton-c/bindings/cpp/src/encoder.cpp index 4067cf8..3abd2ca 100644 --- a/proton-c/bindings/cpp/src/encoder.cpp +++ b/proton-c/bindings/cpp/src/encoder.cpp @@ -23,11 +23,11 @@ #include <proton/annotation_key.hpp> #include <proton/binary.hpp> +#include <proton/codec/encoder.hpp> #include <proton/data.hpp> #include <proton/decimal.hpp> -#include <proton/encoder.hpp> #include <proton/message_id.hpp> -#include <proton/scalar_base.hpp> +#include <proton/internal/scalar_base.hpp> #include <proton/symbol.hpp> #include <proton/timestamp.hpp> #include <proton/value.hpp> http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/src/interop_test.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/interop_test.cpp b/proton-c/bindings/cpp/src/interop_test.cpp index bcadcfe..22581f0 100644 --- a/proton-c/bindings/cpp/src/interop_test.cpp +++ b/proton-c/bindings/cpp/src/interop_test.cpp @@ -17,8 +17,8 @@ * under the License. */ -#include "proton/decoder.hpp" -#include "proton/encoder.hpp" +#include "proton/codec/decoder.hpp" +#include "proton/codec/encoder.hpp" #include "proton/error.hpp" #include "proton/value.hpp" #include "test_bits.hpp" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/src/object.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/object.cpp b/proton-c/bindings/cpp/src/object.cpp index a891b20..f881c63 100644 --- a/proton-c/bindings/cpp/src/object.cpp +++ b/proton-c/bindings/cpp/src/object.cpp @@ -17,7 +17,7 @@ * under the License. */ -#include "proton/object.hpp" +#include "proton/internal/object.hpp" #include <proton/object.h> namespace proton { http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/src/reactor.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/reactor.hpp b/proton-c/bindings/cpp/src/reactor.hpp index 74bacff..ec5f120 100644 --- a/proton-c/bindings/cpp/src/reactor.hpp +++ b/proton-c/bindings/cpp/src/reactor.hpp @@ -23,7 +23,7 @@ /// @cond INTERNAL /// XXX remove -#include "proton/object.hpp" +#include "proton/internal/object.hpp" #include "proton/duration.hpp" #include "proton/timestamp.hpp" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/src/scalar_base.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/scalar_base.cpp b/proton-c/bindings/cpp/src/scalar_base.cpp index c7f97e8..20694db 100644 --- a/proton-c/bindings/cpp/src/scalar_base.cpp +++ b/proton-c/bindings/cpp/src/scalar_base.cpp @@ -22,10 +22,10 @@ #include "proton/binary.hpp" #include "proton/decimal.hpp" -#include "proton/scalar_base.hpp" +#include "proton/internal/scalar_base.hpp" +#include "proton/internal/type_traits.hpp" #include "proton/symbol.hpp" #include "proton/timestamp.hpp" -#include "proton/type_traits.hpp" #include "proton/uuid.hpp" #include <ostream> http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/src/scalar_test.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/scalar_test.cpp b/proton-c/bindings/cpp/src/scalar_test.cpp index f306ba8..ba22757 100644 --- a/proton-c/bindings/cpp/src/scalar_test.cpp +++ b/proton-c/bindings/cpp/src/scalar_test.cpp @@ -21,7 +21,7 @@ #include "proton/binary.hpp" #include "proton/error.hpp" -#include "proton/type_traits.hpp" +#include "proton/internal/type_traits.hpp" #include <proton/scalar.hpp> #include <proton/value.hpp> http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/src/types_internal.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/types_internal.hpp b/proton-c/bindings/cpp/src/types_internal.hpp index 0391d9b..c9ee7c6 100644 --- a/proton-c/bindings/cpp/src/types_internal.hpp +++ b/proton-c/bindings/cpp/src/types_internal.hpp @@ -19,7 +19,7 @@ * under the License. */ -#include <proton/type_traits.hpp> +#include <proton/internal/type_traits.hpp> #include <proton/error.hpp> #include <proton/binary.hpp> #include <sstream> http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/tests/tools/apps/cpp/reactor_send.cpp ---------------------------------------------------------------------- diff --git a/tests/tools/apps/cpp/reactor_send.cpp b/tests/tools/apps/cpp/reactor_send.cpp index eae4d46..05e6417 100644 --- a/tests/tools/apps/cpp/reactor_send.cpp +++ b/tests/tools/apps/cpp/reactor_send.cpp @@ -24,7 +24,7 @@ #include "proton/binary.hpp" #include "proton/connection.hpp" #include "proton/default_container.hpp" -#include "proton/decoder.hpp" +#include "proton/codec/decoder.hpp" #include "proton/delivery.hpp" #include "proton/handler.hpp" #include "proton/tracker.hpp" --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
