You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2016/10/20 12:26:37 UTC
[09/10] qpid-proton git commit: PROTON-1319: C++ SunStudo: Move
internal header files of cpp bindings
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c3aa3a5/proton-c/bindings/cpp/src/proton_bits.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_bits.hpp b/proton-c/bindings/cpp/src/proton_bits.hpp
deleted file mode 100644
index 97d4bee..0000000
--- a/proton-c/bindings/cpp/src/proton_bits.hpp
+++ /dev/null
@@ -1,149 +0,0 @@
-#ifndef PROTON_BITS_HPP
-#define PROTON_BITS_HPP
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-#include <proton/link.h>
-#include <proton/session.h>
-
-#include <string>
-#include <iosfwd>
-
-/**@file
- *
- * Assorted internal proton utilities.
- */
-
-struct pn_error_t;
-
-struct pn_data_t;
-struct pn_transport_t;
-struct pn_sasl_t;
-struct pn_ssl_t;
-struct pn_connection_t;
-struct pn_session_t;
-struct pn_link_t;
-struct pn_delivery_t;
-struct pn_condition_t;
-struct pn_acceptor_t;
-struct pn_terminus_t;
-struct pn_reactor_t;
-struct pn_record_t;
-
-namespace proton {
-
-namespace internal { class data; }
-class transport;
-class sasl;
-class ssl;
-class connection;
-class session;
-class link;
-class sender;
-class receiver;
-class transfer;
-class tracker;
-class delivery;
-class error_condition;
-class acceptor;
-class terminus;
-class source;
-class target;
-class reactor;
-
-std::string error_str(long code);
-
-/** Print the error string from pn_error_t, or from code if pn_error_t has no error. */
-std::string error_str(pn_error_t*, long code=0);
-
-/** Make a void* inspectable via operator <<. */
-struct inspectable { void* value; inspectable(void* o) : value(o) {} };
-
-/** Stream a proton object via pn_inspect. */
-std::ostream& operator<<(std::ostream& o, const inspectable& object);
-
-void set_error_condition(const error_condition&, pn_condition_t*);
-
-/// Convert a const char* to std::string, convert NULL to the empty string.
-inline std::string str(const char* s) { return s ? s : std::string(); }
-
-namespace internal {
-
-// These traits relate the wrapped and wrapper classes for the templated factories below
-template <class T> struct wrapped {};
-template <> struct wrapped<internal::data> { typedef pn_data_t type; };
-template <> struct wrapped<transport> { typedef pn_transport_t type; };
-template <> struct wrapped<sasl> { typedef pn_sasl_t type; };
-template <> struct wrapped<ssl> { typedef pn_ssl_t type; };
-template <> struct wrapped<connection> { typedef pn_connection_t type; };
-template <> struct wrapped<session> { typedef pn_session_t type; };
-template <> struct wrapped<link> { typedef pn_link_t type; };
-template <> struct wrapped<sender> { typedef pn_link_t type; };
-template <> struct wrapped<receiver> { typedef pn_link_t type; };
-template <> struct wrapped<transfer> { typedef pn_delivery_t type; };
-template <> struct wrapped<tracker> { typedef pn_delivery_t type; };
-template <> struct wrapped<delivery> { typedef pn_delivery_t type; };
-template <> struct wrapped<error_condition> { typedef pn_condition_t type; };
-template <> struct wrapped<acceptor> { typedef pn_acceptor_t type; }; // TODO aconway 2016-05-13: reactor only
-template <> struct wrapped<terminus> { typedef pn_terminus_t type; };
-template <> struct wrapped<source> { typedef pn_terminus_t type; };
-template <> struct wrapped<target> { typedef pn_terminus_t type; };
-template <> struct wrapped<reactor> { typedef pn_reactor_t type; };
-
-template <class T> struct wrapper {};
-template <> struct wrapper<pn_data_t> { typedef internal::data type; };
-template <> struct wrapper<pn_transport_t> { typedef transport type; };
-template <> struct wrapper<pn_sasl_t> { typedef sasl type; };
-template <> struct wrapper<pn_ssl_t> { typedef ssl type; };
-template <> struct wrapper<pn_connection_t> { typedef connection type; };
-template <> struct wrapper<pn_session_t> { typedef session type; };
-template <> struct wrapper<pn_link_t> { typedef link type; };
-template <> struct wrapper<pn_delivery_t> { typedef transfer type; };
-template <> struct wrapper<pn_condition_t> { typedef error_condition type; };
-template <> struct wrapper<pn_acceptor_t> { typedef acceptor type; };
-template <> struct wrapper<pn_terminus_t> { typedef terminus type; };
-template <> struct wrapper<pn_reactor_t> { typedef reactor type; };
-
-// Factory for wrapper types
-template <class T>
-class factory {
-public:
- static T wrap(typename wrapped<T>::type* t) { return t; }
- static typename wrapped<T>::type* unwrap(T t) { return t.pn_object(); }
-};
-
-// Get attachments for various proton-c types
-template <class T>
-inline pn_record_t* get_attachments(T*);
-
-template <> inline pn_record_t* get_attachments(pn_session_t* s) { return pn_session_attachments(s); }
-template <> inline pn_record_t* get_attachments(pn_link_t* l) { return pn_link_attachments(l); }
-}
-
-template <class T>
-typename internal::wrapper<T>::type make_wrapper(T* t) { return internal::factory<typename internal::wrapper<T>::type>::wrap(t); }
-
-template <class U>
-U make_wrapper(typename internal::wrapped<U>::type* t) { return internal::factory<U>::wrap(t); }
-
-template <class T>
-typename internal::wrapped<T>::type* unwrap(T t) {return internal::factory<T>::unwrap(t); }
-
-}
-
-#endif // PROTON_BITS_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c3aa3a5/proton-c/bindings/cpp/src/proton_event.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_event.hpp b/proton-c/bindings/cpp/src/proton_event.hpp
deleted file mode 100644
index 9b33701..0000000
--- a/proton-c/bindings/cpp/src/proton_event.hpp
+++ /dev/null
@@ -1,293 +0,0 @@
-#ifndef PROTON_CPP_PROTONEVENT_H
-#define PROTON_CPP_PROTONEVENT_H
-
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-#include "proton/error.hpp"
-
-#include <proton/event.h>
-
-namespace proton {
-
-class proton_handler;
-class container;
-
-/** Event information for a proton::proton_handler */
-class proton_event
-{
- public:
- /// The type of an event
- enum event_type {
- ///@name Event types
- ///@{
-
- /**
- * Defined as a programming convenience. No event of this type will
- * ever be generated.
- */
- EVENT_NONE=PN_EVENT_NONE,
-
- /**
- * A reactor has been started. Events of this type point to the reactor.
- */
- REACTOR_INIT=PN_REACTOR_INIT,
-
- /**
- * A reactor has no more events to process. Events of this type
- * point to the reactor.
- */
- REACTOR_QUIESCED=PN_REACTOR_QUIESCED,
-
- /**
- * A reactor has been stopped. Events of this type point to the reactor.
- */
- REACTOR_FINAL=PN_REACTOR_FINAL,
-
- /**
- * A timer event has occurred.
- */
- TIMER_TASK=PN_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.
- */
- CONNECTION_INIT=PN_CONNECTION_INIT,
-
- /**
- * The connection has been bound to a transport. This event is
- * issued when the transport::bind() is called.
- */
- CONNECTION_BOUND=PN_CONNECTION_BOUND,
-
- /**
- * The connection has been unbound from its transport. This event is
- * issued when transport::unbind() is called.
- */
- CONNECTION_UNBOUND=PN_CONNECTION_UNBOUND,
-
- /**
- * The local connection endpoint has been closed. Events of this
- * type point to the relevant connection.
- */
- CONNECTION_LOCAL_OPEN=PN_CONNECTION_LOCAL_OPEN,
-
- /**
- * The remote endpoint has opened the connection. Events of this
- * type point to the relevant connection.
- */
- CONNECTION_REMOTE_OPEN=PN_CONNECTION_REMOTE_OPEN,
-
- /**
- * The local connection endpoint has been closed. Events of this
- * type point to the relevant connection.
- */
- CONNECTION_LOCAL_CLOSE=PN_CONNECTION_LOCAL_CLOSE,
-
- /**
- * The remote endpoint has closed the connection. Events of this
- * type point to the relevant connection.
- */
- CONNECTION_REMOTE_CLOSE=PN_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.
- */
- CONNECTION_FINAL=PN_CONNECTION_FINAL,
-
- /**
- * The session has been created. This is the first event that will
- * ever be issued for a session.
- */
- SESSION_INIT=PN_SESSION_INIT,
-
- /**
- * The local session endpoint has been opened. Events of this type
- * point to the relevant session.
- */
- SESSION_LOCAL_OPEN=PN_SESSION_LOCAL_OPEN,
-
- /**
- * The remote endpoint has opened the session. Events of this type
- * point to the relevant session.
- */
- SESSION_REMOTE_OPEN=PN_SESSION_REMOTE_OPEN,
-
- /**
- * The local session endpoint has been closed. Events of this type
- * point ot the relevant session.
- */
- SESSION_LOCAL_CLOSE=PN_SESSION_LOCAL_CLOSE,
-
- /**
- * The remote endpoint has closed the session. Events of this type
- * point to the relevant session.
- */
- SESSION_REMOTE_CLOSE=PN_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.
- */
- SESSION_FINAL=PN_SESSION_FINAL,
-
- /**
- * The link has been created. This is the first event that will ever
- * be issued for a link.
- */
- LINK_INIT=PN_LINK_INIT,
-
- /**
- * The local link endpoint has been opened. Events of this type
- * point ot the relevant link.
- */
- LINK_LOCAL_OPEN=PN_LINK_LOCAL_OPEN,
-
- /**
- * The remote endpoint has opened the link. Events of this type
- * point to the relevant link.
- */
- LINK_REMOTE_OPEN=PN_LINK_REMOTE_OPEN,
-
- /**
- * The local link endpoint has been closed. Events of this type
- * point ot the relevant link.
- */
- LINK_LOCAL_CLOSE=PN_LINK_LOCAL_CLOSE,
-
- /**
- * The remote endpoint has closed the link. Events of this type
- * point to the relevant link.
- */
- LINK_REMOTE_CLOSE=PN_LINK_REMOTE_CLOSE,
-
- /**
- * The local link endpoint has been detached. Events of this type
- * point to the relevant link.
- */
- LINK_LOCAL_DETACH=PN_LINK_LOCAL_DETACH,
-
- /**
- * The remote endpoint has detached the link. Events of this type
- * point to the relevant link.
- */
- LINK_REMOTE_DETACH=PN_LINK_REMOTE_DETACH,
-
- /**
- * The flow control state for a link has changed. Events of this
- * type point to the relevant link.
- */
- LINK_FLOW=PN_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.
- */
- LINK_FINAL=PN_LINK_FINAL,
-
- /**
- * A delivery has been created or updated. Events of this type point
- * to the relevant delivery.
- */
- DELIVERY=PN_DELIVERY,
-
- /**
- * The transport has new data to read and/or write. Events of this
- * type point to the relevant transport.
- */
- TRANSPORT=PN_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.
- */
- TRANSPORT_AUTHENTICATED=PN_TRANSPORT_AUTHENTICATED,
-
- /**
- * Indicates that a transport error has occurred. Use
- * transport::condition() to access the details of the error
- * from the associated transport.
- */
- TRANSPORT_ERROR=PN_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.
- */
- TRANSPORT_HEAD_CLOSED=PN_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.
- */
- TRANSPORT_TAIL_CLOSED=PN_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.
- */
- TRANSPORT_CLOSED=PN_TRANSPORT_CLOSED,
-
- SELECTABLE_INIT=PN_SELECTABLE_INIT,
- SELECTABLE_UPDATED=PN_SELECTABLE_UPDATED,
- SELECTABLE_READABLE=PN_SELECTABLE_READABLE,
- SELECTABLE_WRITABLE=PN_SELECTABLE_WRITABLE,
- SELECTABLE_ERROR=PN_SELECTABLE_ERROR,
- SELECTABLE_EXPIRED=PN_SELECTABLE_EXPIRED,
- SELECTABLE_FINAL=PN_SELECTABLE_FINAL
- };
- ///@}
-
- proton_event(pn_event_t *ce, class container* cont) :
- pn_event_(ce),
- container_(cont)
- {}
-
- pn_event_t* pn_event() const { return pn_event_; }
- class container& container() const {
- if (!container_)
- throw proton::error("event does not have a container");
- return *container_;
- }
-
- /// Get type of event
- event_type type() const { return event_type(pn_event_type(pn_event_)); }
-
- void dispatch(proton_handler& h);
-
- private:
- pn_event_t *pn_event_;
- class container* container_;
-};
-
-}
-
-#endif /*!PROTON_CPP_PROTONEVENT_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c3aa3a5/proton-c/bindings/cpp/src/proton_handler.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_handler.hpp b/proton-c/bindings/cpp/src/proton_handler.hpp
deleted file mode 100644
index 9941396..0000000
--- a/proton-c/bindings/cpp/src/proton_handler.hpp
+++ /dev/null
@@ -1,92 +0,0 @@
-#ifndef PROTON_CPP_PROTONHANDLER_H
-#define PROTON_CPP_PROTONHANDLER_H
-
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-#include "proton/internal/object.hpp"
-
-#include <vector>
-
-struct pn_handler_t;
-
-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:
- proton_handler();
- virtual ~proton_handler();
-
- ///@name Over-ride these member functions to handle events
- ///@{
- virtual void on_reactor_init(proton_event &e);
- virtual void on_reactor_quiesced(proton_event &e);
- virtual void on_reactor_final(proton_event &e);
- virtual void on_timer_task(proton_event &e);
- virtual void on_connection_init(proton_event &e);
- virtual void on_connection_bound(proton_event &e);
- virtual void on_connection_unbound(proton_event &e);
- virtual void on_connection_local_open(proton_event &e);
- virtual void on_connection_local_close(proton_event &e);
- virtual void on_connection_remote_open(proton_event &e);
- virtual void on_connection_remote_close(proton_event &e);
- virtual void on_connection_final(proton_event &e);
- virtual void on_session_init(proton_event &e);
- virtual void on_session_local_open(proton_event &e);
- virtual void on_session_local_close(proton_event &e);
- virtual void on_session_remote_open(proton_event &e);
- virtual void on_session_remote_close(proton_event &e);
- virtual void on_session_final(proton_event &e);
- virtual void on_link_init(proton_event &e);
- virtual void on_link_local_open(proton_event &e);
- virtual void on_link_local_close(proton_event &e);
- virtual void on_link_local_detach(proton_event &e);
- virtual void on_link_remote_open(proton_event &e);
- virtual void on_link_remote_close(proton_event &e);
- virtual void on_link_remote_detach(proton_event &e);
- virtual void on_link_flow(proton_event &e);
- virtual void on_link_final(proton_event &e);
- virtual void on_delivery(proton_event &e);
- virtual void on_transport(proton_event &e);
- virtual void on_transport_error(proton_event &e);
- virtual void on_transport_head_closed(proton_event &e);
- virtual void on_transport_tail_closed(proton_event &e);
- virtual void on_transport_closed(proton_event &e);
- virtual void on_selectable_init(proton_event &e);
- virtual void on_selectable_updated(proton_event &e);
- virtual void on_selectable_readable(proton_event &e);
- virtual void on_selectable_writable(proton_event &e);
- virtual void on_selectable_expired(proton_event &e);
- virtual void on_selectable_error(proton_event &e);
- virtual void on_selectable_final(proton_event &e);
- virtual void on_unhandled(proton_event &e);
- ///@}
-};
-
-}
-
-#endif /*!PROTON_CPP_PROTONHANDLER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c3aa3a5/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
deleted file mode 100644
index c7ab915..0000000
--- a/proton-c/bindings/cpp/src/reactor.hpp
+++ /dev/null
@@ -1,106 +0,0 @@
-#ifndef REACTOR_HPP
-#define REACTOR_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.
- */
-
-/// @cond INTERNAL
-/// XXX remove
-
-#include "proton/internal/object.hpp"
-#include "proton/duration.hpp"
-#include "proton/timestamp.hpp"
-
-struct pn_reactor_t;
-struct pn_handler_t;
-struct pn_io_t;
-
-namespace proton {
-
-class connection;
-class container;
-class acceptor;
-class url;
-class messaging_handler;
-class task;
-
-class reactor : public internal::object<pn_reactor_t> {
- public:
- reactor(pn_reactor_t* r = 0) : internal::object<pn_reactor_t>(r) {}
-
- /** Create a new reactor. */
- static reactor create();
-
- /** Open a connection to url and create a receiver with source=url.path() */
- acceptor listen(const proton::url &);
-
- /** Run the event loop, return when all connections and acceptors are closed. */
- void run();
-
- /** Start the reactor, you must call process() to process events */
- void start();
-
- /** Process events, return true if there are more events to process. */
- bool process();
-
- /** Stop the reactor, causes run() to return and process() to return false. */
- void stop();
-
- /// Identifier for the container
- std::string id() const;
-
- /// Get timeout, process() will return if there is no activity within the timeout.
- duration timeout();
-
- /// Set timeout, process() will return if there is no activity within the timeout.
- void timeout(duration timeout);
-
- timestamp mark();
- timestamp now();
-
- task schedule(int, pn_handler_t*);
-
- class connection connection(pn_handler_t*) const;
-
- class connection connection_to_host(const std::string &host, const std::string &port, pn_handler_t*) const;
-
- pn_handler_t* pn_handler() const;
-
- void pn_handler(pn_handler_t* );
-
- pn_handler_t* pn_global_handler() const;
-
- void pn_global_handler(pn_handler_t* );
-
- pn_io_t* pn_io() const;
-
- void wakeup();
- bool quiesced();
- void yield();
-
- friend class container_impl;
- friend class container_context;
- friend class internal::factory<reactor>;
-};
-
-}
-
-/// @endcond
-
-#endif // REACTOR_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c3aa3a5/proton-c/bindings/cpp/src/scalar_test.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/scalar_test.hpp b/proton-c/bindings/cpp/src/scalar_test.hpp
deleted file mode 100644
index b075c98..0000000
--- a/proton-c/bindings/cpp/src/scalar_test.hpp
+++ /dev/null
@@ -1,209 +0,0 @@
-#ifndef SCALAR_TEST_HPP
-#define SCALAR_TEST_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.
- */
-
-// Template tests used by both scalar_test.cpp and value_test.hpp to test conversion
-// of scalar values via a proton::scalar or a proton::value.
-
-#include "test_bits.hpp"
-
-#include "proton/types.hpp"
-#include "proton/error.hpp"
-
-#include <sstream>
-
-
-namespace test {
-
-using namespace proton;
-
-// Inserting and extracting simple C++ values using same-type get<T> and coerce<T>
-template <class V, class T> void simple_type_test(T x, type_id tid, const std::string& s, T y) {
- V vx(x); // Construct from C++ value
- ASSERT_EQUAL(tid, vx.type());
- ASSERT(!vx.empty());
- ASSERT_EQUAL(x, get<T>(vx));
- ASSERT_EQUAL(x, coerce<T>(vx));
-
- V vxa = x; // Assign from C++ value
- ASSERT_EQUAL(tid, vxa.type());
- ASSERT(!vx.empty());
- ASSERT_EQUAL(vx, vxa);
- ASSERT_EQUAL(x, get<T>(vxa));
- ASSERT_EQUAL(x, coerce<T>(vxa));
-
- V v2; // Default construct
- ASSERT(v2.type() == NULL_TYPE);
- ASSERT(v2.empty());
- v2 = x; // Assign from C++ value
- ASSERT_EQUAL(tid, v2.type());
- ASSERT_EQUAL(vx, v2);
- ASSERT_EQUAL(x, get<T>(v2));
- ASSERT_EQUAL(x, coerce<T>(v2));
-
- V v3(vx); // Copy construct
- ASSERT_EQUAL(tid, v3.type());
- ASSERT_EQUAL(vx, v3);
- ASSERT_EQUAL(x, get<T>(v3));
- ASSERT_EQUAL(x, coerce<T>(v3));
-
- V v4 = vx; // Copy assign
- ASSERT_EQUAL(tid, v4.type());
- ASSERT_EQUAL(x, get<T>(v4));
- ASSERT_EQUAL(x, coerce<T>(v4));
-
- ASSERT_EQUAL(s, to_string(vx)); // Stringify
- V vy(y);
- ASSERT(vx != vy); // Compare
- ASSERT(vx < vy);
- ASSERT(vy > vx);
-}
-
-// Test native C/C++ integer types via their mapped integer type ([u]int_x_t)
-template <class V, class T> void simple_integral_test() {
- typedef typename internal::integer_type<sizeof(T), internal::is_signed<T>::value>::type int_type;
- simple_type_test<V>(T(3), internal::type_id_of<int_type>::value, "3", T(4));
-}
-
-// Test invalid gets, valid same-type get<T> is tested by simple_type_test
-// Templated to test both scalar and value.
-template<class V> void bad_get_test() {
- try { get<bool>(V(int8_t(1))); FAIL("byte as bool"); } catch (conversion_error) {}
- try { get<uint8_t>(V(true)); FAIL("bool as uint8_t"); } catch (conversion_error) {}
- try { get<uint8_t>(V(int8_t(1))); FAIL("int8 as uint8"); } catch (conversion_error) {}
- try { get<int16_t>(V(uint16_t(1))); FAIL("uint16 as int16"); } catch (conversion_error) {}
- try { get<int16_t>(V(int32_t(1))); FAIL("int32 as int16"); } catch (conversion_error) {}
- try { get<symbol>(V(std::string())); FAIL("string as symbol"); } catch (conversion_error) {}
- try { get<std::string>(V(binary())); FAIL("binary as string"); } catch (conversion_error) {}
- try { get<binary>(V(symbol())); FAIL("symbol as binary"); } catch (conversion_error) {}
- try { get<binary>(V(timestamp())); FAIL("timestamp as binary"); } catch (conversion_error) {}
- try { get<int>(V(timestamp())); FAIL("timestamp as int"); } catch (conversion_error) {}
- try { get<timestamp>(V(0)); FAIL("int as timestamp"); } catch (conversion_error) {}
- try { get<timestamp>(V(std::string())); FAIL("string as timestamp"); } catch (conversion_error) {}
-}
-
-// Test some valid coercions and some bad ones with mixed types.
-// Templated to test both scalar and value.
-template<class V> void coerce_test() {
- // Valid C++ conversions should work with coerce.
- ASSERT_EQUAL(false, coerce<bool>(V(0)));
- ASSERT_EQUAL(true, coerce<bool>(V(-1)));
- ASSERT_EQUAL(true, coerce<bool>(V(int64_t(0xFFFF0000))));
-
- ASSERT_EQUAL(1, coerce<uint8_t>(V(uint64_t(1)))); // In range.
- ASSERT_EQUAL(1, coerce<uint8_t>(V(uint32_t(0xFF01)))); // int truncate.
- ASSERT_EQUAL(0xFFFF, coerce<uint16_t>(V(int8_t(-1)))); // Sign extend.
- ASSERT_EQUAL(-1, coerce<int32_t>(V(uint64_t(0xFFFFFFFFul)))); // 2s complement
-
- ASSERT_EQUALISH(1.2f, coerce<float>(V(double(1.2))), 0.001f);
- ASSERT_EQUALISH(3.4, coerce<double>(V(float(3.4))), 0.001);
- ASSERT_EQUALISH(23.0, coerce<double>(V(uint64_t(23))), 0.001); // int to double.
- ASSERT_EQUAL(-1945, coerce<int>(V(float(-1945.123)))); // round to int.
-
- // String-like conversions.
- ASSERT_EQUAL(std::string("foo"), coerce<std::string>(V(symbol("foo"))));
- ASSERT_EQUAL(std::string("foo"), coerce<std::string>(V(binary("foo"))));
-
- // Bad coercions, types are not `is_convertible`
- V s("foo");
- try { coerce<bool>(s); FAIL("string as bool"); } catch (conversion_error) {}
- try { coerce<int>(s); FAIL("string as int"); } catch (conversion_error) {}
- try { coerce<double>(s); FAIL("string as double"); } catch (conversion_error) {}
-
- try { coerce<std::string>(V(0)); FAIL("int as string"); } catch (conversion_error) {}
- try { coerce<symbol>(V(true)); FAIL("bool as symbol"); } catch (conversion_error) {}
- try { coerce<binary>(V(0.0)); FAIL("double as binary"); } catch (conversion_error) {}
- try { coerce<symbol>(V(binary())); FAIL("binary as symbol"); } catch (conversion_error) {}
- try { coerce<binary>(V(symbol())); FAIL("symbol as binary"); } catch (conversion_error) {}
- try { coerce<binary>(s); } catch (conversion_error) {}
- try { coerce<symbol>(s); } catch (conversion_error) {}
-}
-
-template <class V> void null_test() {
- V v;
- ASSERT(v.empty());
- ASSERT_EQUAL(NULL_TYPE, v.type());
- get<null>(v);
- null n;
- get(v, n);
- V v2(n);
- ASSERT(v.empty());
- ASSERT_EQUAL(NULL_TYPE, v.type());
- v = "foo";
- ASSERT_EQUAL(STRING, v.type());
- try { get<null>(v); FAIL("Expected conversion_error"); } catch (conversion_error) {}
- v = null();
- get<null>(v);
-}
-
-// Nasty hack for uninterpreted decimal<> types.
-template <class T> T make(const char c) { T x; std::fill(x.begin(), x.end(), c); return x; }
-
-template <class V> void scalar_test_group(int& failed) {
- // Direct AMQP-mapped types.
- RUN_TEST(failed, simple_type_test<V>(false, BOOLEAN, "false", true));
- RUN_TEST(failed, simple_type_test<V>(uint8_t(42), UBYTE, "42", uint8_t(50)));
- RUN_TEST(failed, simple_type_test<V>(int8_t(-42), BYTE, "-42", int8_t(-40)));
- RUN_TEST(failed, simple_type_test<V>(uint16_t(4242), USHORT, "4242", uint16_t(5252)));
- RUN_TEST(failed, simple_type_test<V>(int16_t(-4242), SHORT, "-4242", int16_t(3)));
- RUN_TEST(failed, simple_type_test<V>(uint32_t(4242), UINT, "4242", uint32_t(5252)));
- RUN_TEST(failed, simple_type_test<V>(int32_t(-4242), INT, "-4242", int32_t(3)));
- RUN_TEST(failed, simple_type_test<V>(uint64_t(4242), ULONG, "4242", uint64_t(5252)));
- RUN_TEST(failed, simple_type_test<V>(int64_t(-4242), LONG, "-4242", int64_t(3)));
- RUN_TEST(failed, simple_type_test<V>(wchar_t('X'), CHAR, "88", wchar_t('Y')));
- RUN_TEST(failed, simple_type_test<V>(float(1.234), FLOAT, "1.234", float(2.345)));
- RUN_TEST(failed, simple_type_test<V>(double(11.2233), DOUBLE, "11.2233", double(12)));
- RUN_TEST(failed, simple_type_test<V>(timestamp(1234), TIMESTAMP, "1234", timestamp(12345)));
- RUN_TEST(failed, simple_type_test<V>(make<decimal32>(1), DECIMAL32, "decimal32(0x01010101)", make<decimal32>(2)));
- RUN_TEST(failed, simple_type_test<V>(make<decimal64>(3), DECIMAL64, "decimal64(0x0303030303030303)", make<decimal64>(4)));
- RUN_TEST(failed, simple_type_test<V>(make<decimal128>(5), DECIMAL128, "decimal128(0x05050505050505050505050505050505)", make<decimal128>(6)));
- RUN_TEST(failed, simple_type_test<V>(
- uuid::copy("\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff"),
- UUID, "00112233-4455-6677-8899-aabbccddeeff",
- uuid::copy("\xff\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff")));
- RUN_TEST(failed, simple_type_test<V>(std::string("xxx"), STRING, "xxx", std::string("yyy")));
- RUN_TEST(failed, simple_type_test<V>(symbol("aaa"), SYMBOL, "aaa", symbol("aaaa")));
- RUN_TEST(failed, simple_type_test<V>(binary("\010aaa"), BINARY, "b\"\\x08aaa\"", binary("aaaa")));
-
- // Test native C++ integral types.
- RUN_TEST(failed, (simple_integral_test<V, char>()));
- RUN_TEST(failed, (simple_integral_test<V, signed char>()));
- RUN_TEST(failed, (simple_integral_test<V, unsigned char>()));
- RUN_TEST(failed, (simple_integral_test<V, short>()));
- RUN_TEST(failed, (simple_integral_test<V, int>()));
- RUN_TEST(failed, (simple_integral_test<V, long>()));
- RUN_TEST(failed, (simple_integral_test<V, unsigned short>()));
- RUN_TEST(failed, (simple_integral_test<V, unsigned int>()));
- RUN_TEST(failed, (simple_integral_test<V, unsigned long>()));
-#if PN_CPP_HAS_LONG_LONG
- RUN_TEST(failed, (simple_integral_test<V, long long>()));
- RUN_TEST(failed, (simple_integral_test<V, unsigned long long>()));
-#endif
-
-
- RUN_TEST(failed, (coerce_test<V>()));
- RUN_TEST(failed, (null_test<V>()));
- RUN_TEST(failed, (bad_get_test<V>()));
-}
-
-}
-
-#endif // SCALAR_TEST_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c3aa3a5/proton-c/bindings/cpp/src/test_bits.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/test_bits.hpp b/proton-c/bindings/cpp/src/test_bits.hpp
deleted file mode 100644
index 0cfbe1f..0000000
--- a/proton-c/bindings/cpp/src/test_bits.hpp
+++ /dev/null
@@ -1,136 +0,0 @@
-#ifndef TEST_BITS_HPP
-#define TEST_BITS_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 "msg.hpp"
-#include "proton/types.hpp"
-
-#include <stdexcept>
-#include <iostream>
-#include <iterator>
-#include <sstream>
-#include <math.h>
-
-namespace test {
-
-struct fail : public std::logic_error {
- fail(const std::string& what) : logic_error(what) {}
-};
-
-template <class T, class U>
-void assert_equal(const T& want, const U& got, const std::string& what) {
- if (!(want == got))
- throw fail(MSG(what << " " << want << " != " << got));
-}
-
-template <class T>
-inline void assert_equalish(T want, T got, T delta, const std::string& what)
-{
- if (!(fabs(want-got) <= delta))
- throw fail(MSG(what << " " << want << " !=~ " << got));
-}
-
-#define FAIL_MSG(WHAT) (MSG(__FILE__ << ":" << __LINE__ << ": " << WHAT).str())
-#define FAIL(WHAT) throw test::fail(FAIL_MSG(WHAT))
-#define ASSERT(TEST) do { if (!(TEST)) FAIL("failed ASSERT(" #TEST ")"); } while(false)
-#define ASSERT_EQUAL(WANT, GOT) \
- test::assert_equal((WANT), (GOT), FAIL_MSG("failed ASSERT_EQUAL(" #WANT ", " #GOT ")"))
-#define ASSERT_EQUALISH(WANT, GOT, DELTA) \
- test::assert_equalish((WANT), (GOT), (DELTA), FAIL_MSG("failed ASSERT_EQUALISH(" #WANT ", " #GOT ")"))
-
-#define RUN_TEST(BAD_COUNT, TEST) \
- do { \
- try { \
- TEST; \
- break; \
- } catch(const test::fail& e) { \
- std::cout << "FAIL " << #TEST << std::endl << e.what() << std::endl; \
- } catch(const std::exception& e) { \
- std::cout << "ERROR " << #TEST << std::endl << __FILE__ << ":" << __LINE__ << ": " << e.what() << std::endl; \
- } \
- ++BAD_COUNT; \
- } while(0)
-
-template<class T> std::string str(const T& x) {
- std::ostringstream s; s << std::boolalpha << x; return s.str();
-}
-
-// A way to easily create literal collections that can be compared to std:: collections
-// and to print std collections
-// e.g.
-// std::vector<string> v = ...;
-// ASSERT_EQUAL(many<string>() + "a" + "b" + "c", v);
-template <class T> struct many : public std::vector<T> {
- many() {}
- template<class S> explicit many(const S& s) : std::vector<T>(s.begin(), s.end()) {}
- many& operator+=(const T& t) { this->push_back(t); return *this; }
- many& operator<<(const T& t) { return *this += t; }
- many operator+(const T& t) { many<T> l(*this); return l += t; }
-};
-
-template <class T, class S> bool operator==(const many<T>& m, const S& s) {
- return m.size() == s.size() && S(m.begin(), m.end()) == s;
-}
-
-template <class T, class S> bool operator==(const S& s, const many<T>& m) {
- return m.size() == s.size() && S(m.begin(), m.end()) == s;
-}
-
-template <class T> std::ostream& operator<<(std::ostream& o, const many<T>& m) {
- std::ostream_iterator<T> oi(o, " ");
- std::copy(m.begin(), m.end(), oi);
- return o;
-}
-
-}
-
-namespace std {
-template <class T> std::ostream& operator<<(std::ostream& o, const std::vector<T>& s) {
- return o << test::many<T>(s);
-}
-
-template <class T> std::ostream& operator<<(std::ostream& o, const std::deque<T>& s) {
- return o << test::many<T>(s);
-}
-
-template <class T> std::ostream& operator<<(std::ostream& o, const std::list<T>& s) {
- return o << test::many<T>(s);
-}
-
-template <class K, class T> std::ostream& operator<<(std::ostream& o, const std::map<K, T>& x) {
- return o << test::many<std::pair<K, T> >(x);
-}
-
-template <class U, class V> std::ostream& operator<<(std::ostream& o, const std::pair<U, V>& p) {
- return o << "( " << p.first << " , " << p.second << " )";
-}
-
-#if PN_CPP_HAS_CPP11
-template <class K, class T> std::ostream& operator<<(std::ostream& o, const std::unordered_map<K, T>& x) {
- return o << test::many<std::pair<const K, T> >(x);
-}
-
-template <class T> std::ostream& operator<<(std::ostream& o, const std::forward_list<T>& s) {
- return o << test::many<T>(s);
-}
-#endif
-}
-
-#endif // TEST_BITS_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c3aa3a5/proton-c/bindings/cpp/src/test_dummy_container.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/test_dummy_container.hpp b/proton-c/bindings/cpp/src/test_dummy_container.hpp
deleted file mode 100644
index 4af432a..0000000
--- a/proton-c/bindings/cpp/src/test_dummy_container.hpp
+++ /dev/null
@@ -1,83 +0,0 @@
-#ifndef TEST_DUMMY_CONTAINER_HPP
-#define TEST_DUMMY_CONTAINER_HPP
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include "proton/container.hpp"
-#include "proton/event_loop.hpp"
-#include "proton/thread_safe.hpp"
-
-namespace test {
-
-using namespace proton;
-
-
-class dummy_container : public standard_container {
- public:
- dummy_container(const std::string cid="") :
- id_(cid), fail("not implemented for dummy_container") {}
-
- // Pull in base class functions here so that name search finds all the overloads
- using standard_container::stop;
- using standard_container::connect;
- using standard_container::listen;
- using standard_container::open_receiver;
- using standard_container::open_sender;
-
- returned<connection> connect(const std::string&, const connection_options&) { throw fail; }
- listener listen(const std::string& , listen_handler& ) { throw fail; }
- void stop_listening(const std::string&) { throw fail; }
- void run() { throw fail; }
- void auto_stop(bool) { throw fail; }
- void stop(const proton::error_condition& ) { throw fail; }
- returned<sender> open_sender(const std::string &, const proton::sender_options &, const connection_options&) { throw fail; }
- returned<receiver> open_receiver( const std::string &, const proton::receiver_options &, const connection_options &) { throw fail; }
- std::string id() const { return id_; }
- void client_connection_options(const connection_options &o) { ccopts_ = o; }
- connection_options client_connection_options() const { return ccopts_; }
- void server_connection_options(const connection_options &o) { scopts_ = o; }
- connection_options server_connection_options() const { return scopts_; }
- void sender_options(const class sender_options &o) { sopts_ = o; }
- class sender_options sender_options() const { return sopts_; }
- void receiver_options(const class receiver_options &o) { ropts_ = o; }
- class receiver_options receiver_options() const { return ropts_; }
-#if PN_CPP_HAS_STD_FUNCTION
- void schedule(duration, std::function<void()>) { throw fail; }
-#endif
- void schedule(duration, void_function0&) { throw fail; }
-
- private:
- std::string id_;
- connection_options ccopts_, scopts_;
- class sender_options sopts_;
- class receiver_options ropts_;
- std::runtime_error fail;
-};
-
-class dummy_event_loop : public event_loop {
-#if PN_CPP_HAS_CPP11
- bool inject(std::function<void()> f) PN_CPP_OVERRIDE { f(); return true; }
-#endif
- bool inject(proton::void_function0& h) PN_CPP_OVERRIDE { h(); return true; }
-};
-
-}
-
-#endif // TEST_DUMMY_CONTAINER_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c3aa3a5/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
deleted file mode 100644
index 484dfc4..0000000
--- a/proton-c/bindings/cpp/src/types_internal.hpp
+++ /dev/null
@@ -1,74 +0,0 @@
-#ifndef TYPES_INTERNAL_HPP
-#define TYPES_INTERNAL_HPP
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include "proton/internal/type_traits.hpp"
-#include "proton/error.hpp"
-#include "proton/binary.hpp"
-#include <sstream>
-
-///@file
-/// Inline helpers for encode/decode/type conversion/ostream operators.
-
-namespace proton {
-
-/// Byte copy between two objects, only enabled if their sizes are equal.
-template <class T, class U>
-typename internal::enable_if<sizeof(T) == sizeof(U)>::type byte_copy(T &to, const U &from) {
- const char *p = reinterpret_cast<const char*>(&from);
- std::copy(p, p + sizeof(T), reinterpret_cast<char*>(&to));
-}
-
-inline conversion_error
-make_conversion_error(type_id want, type_id got, const std::string& msg=std::string()) {
- std::ostringstream s;
- s << "unexpected type, want: " << want << " got: " << got;
- if (!msg.empty()) s << ": " << msg;
- return conversion_error(s.str());
-}
-
-/// Convert std::string to pn_bytes_t
-inline pn_bytes_t pn_bytes(const std::string& s) {
- pn_bytes_t b = { s.size(), s.empty() ? 0 : const_cast<char*>(&s[0]) };
- return b;
-}
-
-inline pn_bytes_t pn_bytes(const binary& s) {
- pn_bytes_t b = { s.size(), s.empty() ? 0 : reinterpret_cast<const char*>(&s[0]) };
- return b;
-}
-
-inline std::string str(const pn_bytes_t& b) { return std::string(b.start, b.size); }
-inline binary bin(const pn_bytes_t& b) { return binary(b.start, b.start+b.size); }
-
-// Save all stream format state, restore in destructor.
-struct ios_guard {
- std::ios &guarded;
- std::ios old;
- ios_guard(std::ios& x) : guarded(x), old(0) { old.copyfmt(guarded); }
- ~ios_guard() { guarded.copyfmt(old); }
-};
-
-// Convert a char (signed or unsigned) into an unsigned 1 byte integer that will ostream
-// as a numeric byte value, not a character and will not get sign-extended.
-inline unsigned int printable_byte(uint8_t byte) { return byte; }
-
-}
-#endif // TYPES_INTERNAL_HPP
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org