mirror of
https://github.com/zeromq/cppzmq.git
synced 2024-12-12 10:33:52 +01:00
Problem: whitespace style too restrictive.
For header only library like cppzmq, whitespace style inherited from libzmq is too restrictive. Solution: relaxing whitespace before parens from always to in control statements only, increased max column width from 80 to 85 and removing requirement of whitespace after template keyword.
This commit is contained in:
parent
590cf711e5
commit
ff3c221516
@ -26,14 +26,14 @@ AllowShortBlocksOnASingleLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortFunctionsOnASingleLine: InlineOnly
|
||||
AlwaysBreakTemplateDeclarations: false
|
||||
ColumnLimit: 80
|
||||
ColumnLimit: 85
|
||||
MaxEmptyLinesToKeep: 2
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
ContinuationIndentWidth: 2
|
||||
PointerAlignment: Right
|
||||
ReflowComments: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeParens: Always
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesInAngles: false
|
||||
SpacesInParentheses: false
|
||||
@ -44,7 +44,7 @@ SortIncludes: false
|
||||
|
||||
FixNamespaceComments: false
|
||||
BreakBeforeBinaryOperators: NonAssignment
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceAfterTemplateKeyword: false
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignOperands: true
|
||||
BreakConstructorInitializers: AfterColon
|
||||
|
@ -106,16 +106,14 @@ TEST (active_poller, add_handler_twice_throws)
|
||||
zmq::active_poller_t::handler_t handler;
|
||||
active_poller.add(socket, ZMQ_POLLIN, handler);
|
||||
/// \todo the actual error code should be checked
|
||||
ASSERT_THROW (active_poller.add (socket, ZMQ_POLLIN, handler),
|
||||
zmq::error_t);
|
||||
ASSERT_THROW(active_poller.add(socket, ZMQ_POLLIN, handler), zmq::error_t);
|
||||
}
|
||||
|
||||
TEST(active_poller, wait_with_no_handlers_throws)
|
||||
{
|
||||
zmq::active_poller_t active_poller;
|
||||
/// \todo the actual error code should be checked
|
||||
ASSERT_THROW (active_poller.wait (std::chrono::milliseconds{10}),
|
||||
zmq::error_t);
|
||||
ASSERT_THROW(active_poller.wait(std::chrono::milliseconds{10}), zmq::error_t);
|
||||
}
|
||||
|
||||
TEST(active_poller, remove_unregistered_throws)
|
||||
@ -163,8 +161,7 @@ TEST (active_poller, poll_basic)
|
||||
|
||||
zmq::active_poller_t active_poller;
|
||||
bool message_received = false;
|
||||
zmq::active_poller_t::handler_t handler =
|
||||
[&message_received](short events) {
|
||||
zmq::active_poller_t::handler_t handler = [&message_received](short events) {
|
||||
ASSERT_TRUE(0 != (events & ZMQ_POLLIN));
|
||||
message_received = true;
|
||||
};
|
||||
@ -206,8 +203,7 @@ TEST (active_poller, client_server)
|
||||
|
||||
// Re-add server socket with pollout flag
|
||||
ASSERT_NO_THROW(active_poller.remove(s.server));
|
||||
ASSERT_NO_THROW (
|
||||
active_poller.add (s.server, ZMQ_POLLIN | ZMQ_POLLOUT, handler));
|
||||
ASSERT_NO_THROW(active_poller.add(s.server, ZMQ_POLLIN | ZMQ_POLLOUT, handler));
|
||||
ASSERT_EQ(1, active_poller.wait(std::chrono::milliseconds{-1}));
|
||||
ASSERT_EQ(events, ZMQ_POLLOUT);
|
||||
}
|
||||
@ -218,8 +214,7 @@ TEST (active_poller, add_invalid_socket_throws)
|
||||
zmq::active_poller_t active_poller;
|
||||
zmq::socket_t a{context, zmq::socket_type::router};
|
||||
zmq::socket_t b{std::move(a)};
|
||||
ASSERT_THROW (
|
||||
active_poller.add (a, ZMQ_POLLIN, zmq::active_poller_t::handler_t{}),
|
||||
ASSERT_THROW(active_poller.add(a, ZMQ_POLLIN, zmq::active_poller_t::handler_t{}),
|
||||
zmq::error_t);
|
||||
}
|
||||
|
||||
@ -228,8 +223,8 @@ TEST (active_poller, remove_invalid_socket_throws)
|
||||
zmq::context_t context;
|
||||
zmq::socket_t socket{context, zmq::socket_type::router};
|
||||
zmq::active_poller_t active_poller;
|
||||
ASSERT_NO_THROW (active_poller.add (socket, ZMQ_POLLIN,
|
||||
zmq::active_poller_t::handler_t{}));
|
||||
ASSERT_NO_THROW(
|
||||
active_poller.add(socket, ZMQ_POLLIN, zmq::active_poller_t::handler_t{}));
|
||||
ASSERT_EQ(1u, active_poller.size());
|
||||
std::vector<zmq::socket_t> sockets;
|
||||
sockets.emplace_back(std::move(socket));
|
||||
@ -363,8 +358,7 @@ TEST (active_poller, received_on_move_constructed_active_poller)
|
||||
int count = 0;
|
||||
// Setup active_poller a
|
||||
zmq::active_poller_t a;
|
||||
ASSERT_NO_THROW (
|
||||
a.add (s.server, ZMQ_POLLIN, [&count](short) { ++count; }));
|
||||
ASSERT_NO_THROW(a.add(s.server, ZMQ_POLLIN, [&count](short) { ++count; }));
|
||||
// client sends message
|
||||
ASSERT_NO_THROW(s.client.send("Hi"));
|
||||
// wait for message and verify it is received
|
||||
@ -393,8 +387,8 @@ TEST (active_poller, remove_from_handler)
|
||||
zmq::active_poller_t active_poller;
|
||||
int count = 0;
|
||||
for (auto i = 0; i < ITER_NO; ++i) {
|
||||
ASSERT_NO_THROW (active_poller.add (
|
||||
setup_list[i].server, ZMQ_POLLIN, [&, i](short events) {
|
||||
ASSERT_NO_THROW(
|
||||
active_poller.add(setup_list[i].server, ZMQ_POLLIN, [&, i](short events) {
|
||||
ASSERT_EQ(events, ZMQ_POLLIN);
|
||||
active_poller.remove(setup_list[ITER_NO - i - 1].server);
|
||||
ASSERT_EQ(ITER_NO - i - 1, active_poller.size());
|
||||
|
@ -245,8 +245,7 @@ TEST (poller, wait_on_move_constructed_poller)
|
||||
zmq::poller_t<> b{std::move(a)};
|
||||
std::vector<zmq_poller_event_t> events(1);
|
||||
/// \todo the actual error code should be checked
|
||||
ASSERT_THROW (a.wait_all (events, std::chrono::milliseconds{10}),
|
||||
zmq::error_t);
|
||||
ASSERT_THROW(a.wait_all(events, std::chrono::milliseconds{10}), zmq::error_t);
|
||||
ASSERT_EQ(1, b.wait_all(events, std::chrono::milliseconds{-1}));
|
||||
}
|
||||
|
||||
@ -260,8 +259,7 @@ TEST (poller, wait_on_move_assigned_poller)
|
||||
b = {std::move(a)};
|
||||
/// \todo the actual error code should be checked
|
||||
std::vector<zmq_poller_event_t> events(1);
|
||||
ASSERT_THROW (a.wait_all (events, std::chrono::milliseconds{10}),
|
||||
zmq::error_t);
|
||||
ASSERT_THROW(a.wait_all(events, std::chrono::milliseconds{10}), zmq::error_t);
|
||||
ASSERT_EQ(1, b.wait_all(events, std::chrono::milliseconds{-1}));
|
||||
}
|
||||
|
||||
@ -277,8 +275,7 @@ TEST (poller, remove_from_handler)
|
||||
// Setup poller
|
||||
zmq::poller_t<> poller;
|
||||
for (auto i = 0; i < ITER_NO; ++i) {
|
||||
ASSERT_NO_THROW (
|
||||
poller.add (setup_list[i].server, ZMQ_POLLIN, nullptr));
|
||||
ASSERT_NO_THROW(poller.add(setup_list[i].server, ZMQ_POLLIN, nullptr));
|
||||
}
|
||||
// Clients send messages
|
||||
for (auto &s : setup_list) {
|
||||
@ -293,8 +290,7 @@ TEST (poller, remove_from_handler)
|
||||
|
||||
// Fire all handlers in one wait
|
||||
std::vector<zmq_poller_event_t> events(ITER_NO);
|
||||
ASSERT_EQ (ITER_NO,
|
||||
poller.wait_all (events, std::chrono::milliseconds{-1}));
|
||||
ASSERT_EQ(ITER_NO, poller.wait_all(events, std::chrono::milliseconds{-1}));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -11,6 +11,7 @@ class loopback_ip4_binder
|
||||
public:
|
||||
loopback_ip4_binder(zmq::socket_t &socket) { bind(socket); }
|
||||
std::string endpoint() { return endpoint_; }
|
||||
|
||||
private:
|
||||
// Helper function used in constructor
|
||||
// as Gtest allows ASSERT_* only in void returning functions
|
||||
@ -20,8 +21,8 @@ private:
|
||||
ASSERT_NO_THROW(socket.bind("tcp://127.0.0.1:*"));
|
||||
std::array<char, 100> endpoint{};
|
||||
size_t endpoint_size = endpoint.size();
|
||||
ASSERT_NO_THROW(socket.getsockopt(ZMQ_LAST_ENDPOINT, endpoint.data(),
|
||||
&endpoint_size));
|
||||
ASSERT_NO_THROW(
|
||||
socket.getsockopt(ZMQ_LAST_ENDPOINT, endpoint.data(), &endpoint_size));
|
||||
ASSERT_TRUE(endpoint_size < endpoint.size());
|
||||
endpoint_ = std::string{endpoint.data()};
|
||||
}
|
||||
@ -30,10 +31,7 @@ private:
|
||||
|
||||
struct common_server_client_setup
|
||||
{
|
||||
common_server_client_setup ()
|
||||
{
|
||||
init ();
|
||||
}
|
||||
common_server_client_setup() { init(); }
|
||||
|
||||
void init()
|
||||
{
|
||||
|
105
zmq.hpp
105
zmq.hpp
@ -79,8 +79,7 @@
|
||||
#endif
|
||||
|
||||
// Detect whether the compiler supports C++11 rvalue references.
|
||||
#if (defined(__GNUC__) \
|
||||
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2)) \
|
||||
#if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2)) \
|
||||
&& defined(__GXX_EXPERIMENTAL_CXX0X__))
|
||||
#define ZMQ_HAS_RVALUE_REFS
|
||||
#define ZMQ_DELETED_FUNCTION = delete
|
||||
@ -152,8 +151,7 @@ class error_t : public std::exception
|
||||
int errnum;
|
||||
};
|
||||
|
||||
inline int
|
||||
poll (zmq_pollitem_t const *items_, size_t nitems_, long timeout_ = -1)
|
||||
inline int poll(zmq_pollitem_t const *items_, size_t nitems_, long timeout_ = -1)
|
||||
{
|
||||
int rc = zmq_poll(const_cast<zmq_pollitem_t *>(items_),
|
||||
static_cast<int>(nitems_), timeout_);
|
||||
@ -163,9 +161,8 @@ poll (zmq_pollitem_t const *items_, size_t nitems_, long timeout_ = -1)
|
||||
}
|
||||
|
||||
#ifdef ZMQ_CPP11
|
||||
inline int poll (zmq_pollitem_t const *items,
|
||||
size_t nitems,
|
||||
std::chrono::milliseconds timeout)
|
||||
inline int
|
||||
poll(zmq_pollitem_t const *items, size_t nitems, std::chrono::milliseconds timeout)
|
||||
{
|
||||
return poll(items, nitems, static_cast<long>(timeout.count()));
|
||||
}
|
||||
@ -173,8 +170,7 @@ inline int poll (zmq_pollitem_t const *items,
|
||||
inline int poll(std::vector<zmq_pollitem_t> const &items,
|
||||
std::chrono::milliseconds timeout)
|
||||
{
|
||||
return poll (items.data (), items.size (),
|
||||
static_cast<long> (timeout.count ()));
|
||||
return poll(items.data(), items.size(), static_cast<long>(timeout.count()));
|
||||
}
|
||||
|
||||
inline int poll(std::vector<zmq_pollitem_t> const &items, long timeout_ = -1)
|
||||
@ -259,10 +255,7 @@ class message_t
|
||||
memcpy(data(), data_, size_);
|
||||
}
|
||||
|
||||
inline message_t (void *data_,
|
||||
size_t size_,
|
||||
free_fn *ffn_,
|
||||
void *hint_ = NULL)
|
||||
inline message_t(void *data_, size_t size_, free_fn *ffn_, void *hint_ = NULL)
|
||||
{
|
||||
int rc = zmq_msg_init_data(&msg, data_, size_, ffn_, hint_);
|
||||
if (rc != 0)
|
||||
@ -328,8 +321,7 @@ class message_t
|
||||
memcpy(data(), data_, size_);
|
||||
}
|
||||
|
||||
inline void
|
||||
rebuild (void *data_, size_t size_, free_fn *ffn_, void *hint_ = NULL)
|
||||
inline void rebuild(void *data_, size_t size_, free_fn *ffn_, void *hint_ = NULL)
|
||||
{
|
||||
int rc = zmq_msg_close(&msg);
|
||||
if (rc != 0)
|
||||
@ -371,10 +363,7 @@ class message_t
|
||||
return zmq_msg_size(const_cast<zmq_msg_t *>(&msg));
|
||||
}
|
||||
|
||||
template <typename T> T *data () ZMQ_NOTHROW
|
||||
{
|
||||
return static_cast<T *> (data ());
|
||||
}
|
||||
template<typename T> T *data() ZMQ_NOTHROW { return static_cast<T *>(data()); }
|
||||
|
||||
template<typename T> T const *data() const ZMQ_NOTHROW
|
||||
{
|
||||
@ -390,8 +379,7 @@ class message_t
|
||||
inline bool operator==(const message_t &other) const ZMQ_NOTHROW
|
||||
{
|
||||
const size_t my_size = size();
|
||||
return my_size == other.size ()
|
||||
&& 0 == memcmp (data (), other.data (), my_size);
|
||||
return my_size == other.size() && 0 == memcmp(data(), other.data(), my_size);
|
||||
}
|
||||
|
||||
inline bool operator!=(const message_t &other) const ZMQ_NOTHROW
|
||||
@ -485,10 +473,7 @@ class context_t
|
||||
}
|
||||
|
||||
#ifdef ZMQ_HAS_RVALUE_REFS
|
||||
inline context_t (context_t &&rhs) ZMQ_NOTHROW : ptr (rhs.ptr)
|
||||
{
|
||||
rhs.ptr = NULL;
|
||||
}
|
||||
inline context_t(context_t &&rhs) ZMQ_NOTHROW : ptr(rhs.ptr) { rhs.ptr = NULL; }
|
||||
inline context_t &operator=(context_t &&rhs) ZMQ_NOTHROW
|
||||
{
|
||||
std::swap(ptr, rhs.ptr);
|
||||
@ -522,10 +507,7 @@ class context_t
|
||||
// Normally you should never need to use this.
|
||||
inline ZMQ_EXPLICIT operator void *() ZMQ_NOTHROW { return ptr; }
|
||||
|
||||
inline ZMQ_EXPLICIT operator void const * () const ZMQ_NOTHROW
|
||||
{
|
||||
return ptr;
|
||||
}
|
||||
inline ZMQ_EXPLICIT operator void const *() const ZMQ_NOTHROW { return ptr; }
|
||||
|
||||
inline operator bool() const ZMQ_NOTHROW { return ptr != NULL; }
|
||||
|
||||
@ -575,8 +557,7 @@ class socket_t
|
||||
#endif
|
||||
|
||||
#ifdef ZMQ_HAS_RVALUE_REFS
|
||||
inline socket_t (socket_t &&rhs) ZMQ_NOTHROW : ptr (rhs.ptr),
|
||||
ctxptr (rhs.ctxptr)
|
||||
inline socket_t(socket_t &&rhs) ZMQ_NOTHROW : ptr(rhs.ptr), ctxptr(rhs.ctxptr)
|
||||
{
|
||||
rhs.ptr = NULL;
|
||||
rhs.ctxptr = NULL;
|
||||
@ -616,8 +597,7 @@ class socket_t
|
||||
throw error_t();
|
||||
}
|
||||
|
||||
inline void
|
||||
getsockopt (int option_, void *optval_, size_t *optvallen_) const
|
||||
inline void getsockopt(int option_, void *optval_, size_t *optvallen_) const
|
||||
{
|
||||
int rc = zmq_getsockopt(ptr, option_, optval_, optvallen_);
|
||||
if (rc != 0)
|
||||
@ -659,10 +639,7 @@ class socket_t
|
||||
throw error_t();
|
||||
}
|
||||
|
||||
inline void disconnect (std::string const &addr)
|
||||
{
|
||||
disconnect (addr.c_str ());
|
||||
}
|
||||
inline void disconnect(std::string const &addr) { disconnect(addr.c_str()); }
|
||||
|
||||
inline void disconnect(const char *addr_)
|
||||
{
|
||||
@ -700,10 +677,7 @@ class socket_t
|
||||
}
|
||||
|
||||
#ifdef ZMQ_HAS_RVALUE_REFS
|
||||
inline bool send (message_t &&msg_, int flags_ = 0)
|
||||
{
|
||||
return send (msg_, flags_);
|
||||
}
|
||||
inline bool send(message_t &&msg_, int flags_ = 0) { return send(msg_, flags_); }
|
||||
#endif
|
||||
|
||||
inline size_t recv(void *buf_, size_t len_, int flags_ = 0)
|
||||
@ -758,8 +732,7 @@ class monitor_t
|
||||
|
||||
|
||||
#ifdef ZMQ_HAS_RVALUE_REFS
|
||||
monitor_t (monitor_t &&rhs) ZMQ_NOTHROW
|
||||
: socketPtr (rhs.socketPtr),
|
||||
monitor_t(monitor_t &&rhs) ZMQ_NOTHROW : socketPtr(rhs.socketPtr),
|
||||
monitor_socket(rhs.monitor_socket)
|
||||
{
|
||||
rhs.socketPtr = NULL;
|
||||
@ -770,15 +743,13 @@ class monitor_t
|
||||
#endif
|
||||
|
||||
|
||||
void monitor (socket_t &socket,
|
||||
std::string const &addr,
|
||||
int events = ZMQ_EVENT_ALL)
|
||||
void
|
||||
monitor(socket_t &socket, std::string const &addr, int events = ZMQ_EVENT_ALL)
|
||||
{
|
||||
monitor(socket, addr.c_str(), events);
|
||||
}
|
||||
|
||||
void
|
||||
monitor (socket_t &socket, const char *addr_, int events = ZMQ_EVENT_ALL)
|
||||
void monitor(socket_t &socket, const char *addr_, int events = ZMQ_EVENT_ALL)
|
||||
{
|
||||
init(socket, addr_, events);
|
||||
while (true) {
|
||||
@ -786,8 +757,7 @@ class monitor_t
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
init (socket_t &socket, std::string const &addr, int events = ZMQ_EVENT_ALL)
|
||||
void init(socket_t &socket, std::string const &addr, int events = ZMQ_EVENT_ALL)
|
||||
{
|
||||
init(socket, addr.c_str(), events);
|
||||
}
|
||||
@ -840,8 +810,7 @@ class monitor_t
|
||||
memcpy(&msgEvent.value, data, sizeof(int32_t));
|
||||
zmq_event_t *event = &msgEvent;
|
||||
#else
|
||||
zmq_event_t *event =
|
||||
static_cast<zmq_event_t *> (zmq_msg_data (&eventMsg));
|
||||
zmq_event_t *event = static_cast<zmq_event_t *>(zmq_msg_data(&eventMsg));
|
||||
#endif
|
||||
|
||||
#ifdef ZMQ_NEW_MONITOR_EVENT_LAYOUT
|
||||
@ -947,8 +916,7 @@ class monitor_t
|
||||
}
|
||||
#endif
|
||||
virtual void on_monitor_started() {}
|
||||
virtual void on_event_connected (const zmq_event_t &event_,
|
||||
const char *addr_)
|
||||
virtual void on_event_connected(const zmq_event_t &event_, const char *addr_)
|
||||
{
|
||||
(void) event_;
|
||||
(void) addr_;
|
||||
@ -965,26 +933,22 @@ class monitor_t
|
||||
(void) event_;
|
||||
(void) addr_;
|
||||
}
|
||||
virtual void on_event_listening (const zmq_event_t &event_,
|
||||
const char *addr_)
|
||||
virtual void on_event_listening(const zmq_event_t &event_, const char *addr_)
|
||||
{
|
||||
(void) event_;
|
||||
(void) addr_;
|
||||
}
|
||||
virtual void on_event_bind_failed (const zmq_event_t &event_,
|
||||
const char *addr_)
|
||||
virtual void on_event_bind_failed(const zmq_event_t &event_, const char *addr_)
|
||||
{
|
||||
(void) event_;
|
||||
(void) addr_;
|
||||
}
|
||||
virtual void on_event_accepted (const zmq_event_t &event_,
|
||||
const char *addr_)
|
||||
virtual void on_event_accepted(const zmq_event_t &event_, const char *addr_)
|
||||
{
|
||||
(void) event_;
|
||||
(void) addr_;
|
||||
}
|
||||
virtual void on_event_accept_failed (const zmq_event_t &event_,
|
||||
const char *addr_)
|
||||
virtual void on_event_accept_failed(const zmq_event_t &event_, const char *addr_)
|
||||
{
|
||||
(void) event_;
|
||||
(void) addr_;
|
||||
@ -994,14 +958,12 @@ class monitor_t
|
||||
(void) event_;
|
||||
(void) addr_;
|
||||
}
|
||||
virtual void on_event_close_failed (const zmq_event_t &event_,
|
||||
const char *addr_)
|
||||
virtual void on_event_close_failed(const zmq_event_t &event_, const char *addr_)
|
||||
{
|
||||
(void) event_;
|
||||
(void) addr_;
|
||||
}
|
||||
virtual void on_event_disconnected (const zmq_event_t &event_,
|
||||
const char *addr_)
|
||||
virtual void on_event_disconnected(const zmq_event_t &event_, const char *addr_)
|
||||
{
|
||||
(void) event_;
|
||||
(void) addr_;
|
||||
@ -1059,8 +1021,7 @@ class monitor_t
|
||||
void *monitor_socket;
|
||||
};
|
||||
|
||||
#if defined(ZMQ_BUILD_DRAFT_API) && defined(ZMQ_CPP11) \
|
||||
&& defined(ZMQ_HAVE_POLLER)
|
||||
#if defined(ZMQ_BUILD_DRAFT_API) && defined(ZMQ_CPP11) && defined(ZMQ_HAVE_POLLER)
|
||||
template<typename T = void> class poller_t
|
||||
{
|
||||
public:
|
||||
@ -1075,9 +1036,7 @@ template <typename T = void> class poller_t
|
||||
|
||||
void remove(zmq::socket_t &socket)
|
||||
{
|
||||
if (0
|
||||
!= zmq_poller_remove (poller_ptr.get (),
|
||||
static_cast<void *> (socket))) {
|
||||
if (0 != zmq_poller_remove(poller_ptr.get(), static_cast<void *>(socket))) {
|
||||
throw error_t();
|
||||
}
|
||||
}
|
||||
@ -1085,8 +1044,8 @@ template <typename T = void> class poller_t
|
||||
void modify(zmq::socket_t &socket, short events)
|
||||
{
|
||||
if (0
|
||||
!= zmq_poller_modify (poller_ptr.get (),
|
||||
static_cast<void *> (socket), events)) {
|
||||
!= zmq_poller_modify(poller_ptr.get(), static_cast<void *>(socket),
|
||||
events)) {
|
||||
throw error_t();
|
||||
}
|
||||
}
|
||||
|
@ -52,8 +52,7 @@ class multipart_t
|
||||
typedef std::deque<message_t>::const_iterator const_iterator;
|
||||
|
||||
typedef std::deque<message_t>::reverse_iterator reverse_iterator;
|
||||
typedef std::deque<message_t>::const_reverse_iterator
|
||||
const_reverse_iterator;
|
||||
typedef std::deque<message_t>::const_reverse_iterator const_reverse_iterator;
|
||||
|
||||
// Default constructor
|
||||
multipart_t() {}
|
||||
@ -205,10 +204,7 @@ class multipart_t
|
||||
}
|
||||
|
||||
// Push message part to front
|
||||
void push (message_t &&message)
|
||||
{
|
||||
m_parts.push_front (std::move (message));
|
||||
}
|
||||
void push(message_t &&message) { m_parts.push_front(std::move(message)); }
|
||||
|
||||
// Push message part to back
|
||||
void add(message_t &&message) { m_parts.push_back(std::move(message)); }
|
||||
@ -216,8 +212,7 @@ class multipart_t
|
||||
// Pop string from front
|
||||
std::string popstr()
|
||||
{
|
||||
std::string string (m_parts.front ().data<char> (),
|
||||
m_parts.front ().size ());
|
||||
std::string string(m_parts.front().data<char>(), m_parts.front().size());
|
||||
m_parts.pop_front();
|
||||
return string;
|
||||
}
|
||||
@ -257,8 +252,7 @@ class multipart_t
|
||||
// Get a string copy of a specific message part
|
||||
std::string peekstr(size_t index) const
|
||||
{
|
||||
std::string string (m_parts[index].data<char> (),
|
||||
m_parts[index].size ());
|
||||
std::string string(m_parts[index].data<char>(), m_parts[index].size());
|
||||
return string;
|
||||
}
|
||||
|
||||
@ -307,8 +301,8 @@ class multipart_t
|
||||
break;
|
||||
}
|
||||
}
|
||||
ss << "\n[" << std::dec << std::setw (3) << std::setfill ('0')
|
||||
<< size << "] ";
|
||||
ss << "\n[" << std::dec << std::setw(3) << std::setfill('0') << size
|
||||
<< "] ";
|
||||
if (size >= 1000) {
|
||||
ss << "... (to big to print)";
|
||||
continue;
|
||||
@ -348,8 +342,7 @@ inline std::ostream &operator<< (std::ostream &os, const multipart_t &msg)
|
||||
|
||||
#endif // ZMQ_HAS_RVALUE_REFS
|
||||
|
||||
#if defined(ZMQ_BUILD_DRAFT_API) && defined(ZMQ_CPP11) \
|
||||
&& defined(ZMQ_HAVE_POLLER)
|
||||
#if defined(ZMQ_BUILD_DRAFT_API) && defined(ZMQ_CPP11) && defined(ZMQ_HAVE_POLLER)
|
||||
class active_poller_t
|
||||
{
|
||||
public:
|
||||
@ -373,8 +366,7 @@ class active_poller_t
|
||||
std::make_shared<handler_t>(std::move(handler)));
|
||||
try {
|
||||
base_poller.add(socket, events,
|
||||
inserted && *(it->second) ? it->second.get ()
|
||||
: nullptr);
|
||||
inserted && *(it->second) ? it->second.get() : nullptr);
|
||||
need_rebuild |= inserted;
|
||||
}
|
||||
catch (const zmq::error_t &) {
|
||||
@ -413,8 +405,8 @@ class active_poller_t
|
||||
std::for_each(poller_events.begin(), poller_events.begin() + count,
|
||||
[](zmq_poller_event_t &event) {
|
||||
if (event.user_data != NULL)
|
||||
(*reinterpret_cast<handler_t *> (
|
||||
event.user_data)) (event.events);
|
||||
(*reinterpret_cast<handler_t *>(event.user_data))(
|
||||
event.events);
|
||||
});
|
||||
return count;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user