|
|
@ -25,10 +25,14 @@
|
|
|
|
#ifndef __ZMQ_HPP_INCLUDED__
|
|
|
|
#ifndef __ZMQ_HPP_INCLUDED__
|
|
|
|
#define __ZMQ_HPP_INCLUDED__
|
|
|
|
#define __ZMQ_HPP_INCLUDED__
|
|
|
|
|
|
|
|
|
|
|
|
#if __cplusplus >= 201103L
|
|
|
|
#if (__cplusplus >= 201103L)
|
|
|
|
#define ZMQ_CPP11
|
|
|
|
#define ZMQ_CPP11
|
|
|
|
#define ZMQ_NOTHROW noexcept
|
|
|
|
#define ZMQ_NOTHROW noexcept
|
|
|
|
#define ZMQ_EXPLICIT explicit
|
|
|
|
#define ZMQ_EXPLICIT explicit
|
|
|
|
|
|
|
|
#elif (defined(_MSC_VER) && (_MSC_VER >= 1900))
|
|
|
|
|
|
|
|
#define ZMQ_CPP11
|
|
|
|
|
|
|
|
#define ZMQ_NOTHROW noexcept
|
|
|
|
|
|
|
|
#define ZMQ_EXPLICIT explicit
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
#define ZMQ_CPP03
|
|
|
|
#define ZMQ_CPP03
|
|
|
|
#define ZMQ_NOTHROW
|
|
|
|
#define ZMQ_NOTHROW
|
|
|
@ -66,6 +70,9 @@
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
#define ZMQ_DELETED_FUNCTION
|
|
|
|
#define ZMQ_DELETED_FUNCTION
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#elif defined(_MSC_VER) && (_MSC_VER >= 1900)
|
|
|
|
|
|
|
|
#define ZMQ_HAS_RVALUE_REFS
|
|
|
|
|
|
|
|
#define ZMQ_DELETED_FUNCTION = delete
|
|
|
|
#elif defined(_MSC_VER) && (_MSC_VER >= 1600)
|
|
|
|
#elif defined(_MSC_VER) && (_MSC_VER >= 1600)
|
|
|
|
#define ZMQ_HAS_RVALUE_REFS
|
|
|
|
#define ZMQ_HAS_RVALUE_REFS
|
|
|
|
#define ZMQ_DELETED_FUNCTION
|
|
|
|
#define ZMQ_DELETED_FUNCTION
|
|
|
@ -111,12 +118,17 @@ namespace zmq
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
|
error_t () : errnum (zmq_errno ()) {}
|
|
|
|
error_t () : errnum (zmq_errno ()) {}
|
|
|
|
|
|
|
|
#ifdef ZMQ_CPP11
|
|
|
|
virtual const char *what () const throw ()
|
|
|
|
virtual const char *what () const noexcept
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return zmq_strerror (errnum);
|
|
|
|
return zmq_strerror (errnum);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
virtual const char *what() const throw ()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return zmq_strerror(errnum);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
int num () const
|
|
|
|
int num () const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return errnum;
|
|
|
|
return errnum;
|
|
|
@ -351,6 +363,14 @@ namespace zmq
|
|
|
|
return static_cast<T const*>( data() );
|
|
|
|
return static_cast<T const*>( data() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline bool equal(const message_t* other) const ZMQ_NOTHROW
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (size() != other->size())
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
std::string a(data<char>(), size());
|
|
|
|
|
|
|
|
std::string b(other->data<char>(), other->size());
|
|
|
|
|
|
|
|
return a == b;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
// The underlying message
|
|
|
|
// The underlying message
|
|
|
@ -402,14 +422,17 @@ namespace zmq
|
|
|
|
|
|
|
|
|
|
|
|
inline ~context_t () ZMQ_NOTHROW
|
|
|
|
inline ~context_t () ZMQ_NOTHROW
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int rc = zmq_ctx_destroy (ptr);
|
|
|
|
close();
|
|
|
|
ZMQ_ASSERT (rc == 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void close() ZMQ_NOTHROW
|
|
|
|
inline void close() ZMQ_NOTHROW
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int rc = zmq_ctx_shutdown (ptr);
|
|
|
|
if (ptr == NULL)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int rc = zmq_ctx_destroy (ptr);
|
|
|
|
ZMQ_ASSERT (rc == 0);
|
|
|
|
ZMQ_ASSERT (rc == 0);
|
|
|
|
|
|
|
|
ptr = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Be careful with this, it's probably only useful for
|
|
|
|
// Be careful with this, it's probably only useful for
|
|
|
@ -487,12 +510,12 @@ namespace zmq
|
|
|
|
close();
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline ZMQ_EXPLICIT operator void* () ZMQ_NOTHROW
|
|
|
|
inline operator void* () ZMQ_NOTHROW
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return ptr;
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline ZMQ_EXPLICIT operator void const* () const ZMQ_NOTHROW
|
|
|
|
inline operator void const* () const ZMQ_NOTHROW
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return ptr;
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|