mirror of
https://github.com/zeromq/cppzmq.git
synced 2024-12-13 10:52:57 +01:00
Problem: Detail namespace used in API
Solution: Move types into zmq namespace
This commit is contained in:
parent
a34d2a3da9
commit
0ef29c1b30
31
zmq.hpp
31
zmq.hpp
@ -712,14 +712,16 @@ struct recv_buffer_size
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
|
|
||||||
#if defined(ZMQ_HAS_OPTIONAL) && (ZMQ_HAS_OPTIONAL > 0)
|
#if defined(ZMQ_HAS_OPTIONAL) && (ZMQ_HAS_OPTIONAL > 0)
|
||||||
|
|
||||||
using send_result_t = std::optional<size_t>;
|
using send_result_t = std::optional<size_t>;
|
||||||
using recv_result_t = std::optional<size_t>;
|
using recv_result_t = std::optional<size_t>;
|
||||||
using recv_buffer_result_t = std::optional<recv_buffer_size>;
|
using recv_buffer_result_t = std::optional<recv_buffer_size>;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
// A C++11 type emulating the most basic
|
// A C++11 type emulating the most basic
|
||||||
// operations of std::optional for trivial types
|
// operations of std::optional for trivial types
|
||||||
template<class T> class trivial_optional
|
template<class T> class trivial_optional
|
||||||
@ -773,12 +775,17 @@ template<class T> class trivial_optional
|
|||||||
T _value{};
|
T _value{};
|
||||||
bool _has_value{false};
|
bool _has_value{false};
|
||||||
};
|
};
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
using send_result_t = detail::trivial_optional<size_t>;
|
||||||
|
using recv_result_t = detail::trivial_optional<size_t>;
|
||||||
|
using recv_buffer_result_t = detail::trivial_optional<recv_buffer_size>;
|
||||||
|
|
||||||
using send_result_t = trivial_optional<size_t>;
|
|
||||||
using recv_result_t = trivial_optional<size_t>;
|
|
||||||
using recv_buffer_result_t = trivial_optional<recv_buffer_size>;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
constexpr T enum_bit_or(T a, T b) noexcept
|
constexpr T enum_bit_or(T a, T b) noexcept
|
||||||
{
|
{
|
||||||
@ -1303,7 +1310,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ZMQ_CPP11
|
#ifdef ZMQ_CPP11
|
||||||
detail::send_result_t send(const_buffer buf, send_flags flags = send_flags::none)
|
send_result_t send(const_buffer buf, send_flags flags = send_flags::none)
|
||||||
{
|
{
|
||||||
const int nbytes =
|
const int nbytes =
|
||||||
zmq_send(_handle, buf.data(), buf.size(), static_cast<int>(flags));
|
zmq_send(_handle, buf.data(), buf.size(), static_cast<int>(flags));
|
||||||
@ -1314,7 +1321,7 @@ public:
|
|||||||
throw error_t();
|
throw error_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
detail::send_result_t send(message_t &msg, send_flags flags)
|
send_result_t send(message_t &msg, send_flags flags)
|
||||||
{
|
{
|
||||||
int nbytes = zmq_msg_send(msg.handle(), _handle, static_cast<int>(flags));
|
int nbytes = zmq_msg_send(msg.handle(), _handle, static_cast<int>(flags));
|
||||||
if (nbytes >= 0)
|
if (nbytes >= 0)
|
||||||
@ -1324,7 +1331,7 @@ public:
|
|||||||
throw error_t();
|
throw error_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
detail::send_result_t send(message_t &&msg, send_flags flags)
|
send_result_t send(message_t &&msg, send_flags flags)
|
||||||
{
|
{
|
||||||
return send(msg, flags);
|
return send(msg, flags);
|
||||||
}
|
}
|
||||||
@ -1357,7 +1364,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ZMQ_CPP11
|
#ifdef ZMQ_CPP11
|
||||||
ZMQ_NODISCARD detail::recv_buffer_result_t recv(mutable_buffer buf,
|
ZMQ_NODISCARD
|
||||||
|
recv_buffer_result_t recv(mutable_buffer buf,
|
||||||
recv_flags flags = recv_flags::none)
|
recv_flags flags = recv_flags::none)
|
||||||
{
|
{
|
||||||
const int nbytes =
|
const int nbytes =
|
||||||
@ -1371,7 +1379,8 @@ public:
|
|||||||
throw error_t();
|
throw error_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
ZMQ_NODISCARD detail::recv_result_t recv(message_t &msg, recv_flags flags = recv_flags::none)
|
ZMQ_NODISCARD
|
||||||
|
recv_result_t recv(message_t &msg, recv_flags flags = recv_flags::none)
|
||||||
{
|
{
|
||||||
const int nbytes = zmq_msg_recv(msg.handle(), _handle, static_cast<int>(flags));
|
const int nbytes = zmq_msg_recv(msg.handle(), _handle, static_cast<int>(flags));
|
||||||
if (nbytes >= 0) {
|
if (nbytes >= 0) {
|
||||||
|
@ -53,7 +53,8 @@ namespace zmq
|
|||||||
message parts. It is adviced to close this socket in that event.
|
message parts. It is adviced to close this socket in that event.
|
||||||
*/
|
*/
|
||||||
template<class OutputIt>
|
template<class OutputIt>
|
||||||
ZMQ_NODISCARD detail::recv_result_t recv_multipart(socket_ref s, OutputIt out,
|
ZMQ_NODISCARD
|
||||||
|
recv_result_t recv_multipart(socket_ref s, OutputIt out,
|
||||||
recv_flags flags = recv_flags::none)
|
recv_flags flags = recv_flags::none)
|
||||||
{
|
{
|
||||||
size_t msg_count = 0;
|
size_t msg_count = 0;
|
||||||
@ -93,7 +94,7 @@ template<class Range,
|
|||||||
&& (std::is_same<detail::range_value_t<Range>, message_t>::value
|
&& (std::is_same<detail::range_value_t<Range>, message_t>::value
|
||||||
|| detail::is_buffer<detail::range_value_t<Range>>::value)
|
|| detail::is_buffer<detail::range_value_t<Range>>::value)
|
||||||
>::type>
|
>::type>
|
||||||
detail::send_result_t send_multipart(socket_ref s, Range&& msgs,
|
send_result_t send_multipart(socket_ref s, Range&& msgs,
|
||||||
send_flags flags = send_flags::none)
|
send_flags flags = send_flags::none)
|
||||||
{
|
{
|
||||||
using std::begin;
|
using std::begin;
|
||||||
|
Loading…
Reference in New Issue
Block a user