From f945a7d032923e53675aa00ae288df6e5897f71b Mon Sep 17 00:00:00 2001 From: Giuseppe Corbelli Date: Wed, 7 Mar 2018 14:11:41 +0100 Subject: [PATCH] Added an operator<<(std::ostream) to easily print out multipart_t contents using already defined str() method. Added some comments to mark the end of preprocessor instructions / class def / namespace def --- zmq_addon.hpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/zmq_addon.hpp b/zmq_addon.hpp index 0e93ebd..4dd6f05 100644 --- a/zmq_addon.hpp +++ b/zmq_addon.hpp @@ -25,6 +25,7 @@ #define __ZMQ_ADDON_HPP_INCLUDED__ #include + #include #include #include @@ -328,7 +329,7 @@ public: { return &m_parts[index]; } - + // Get a string copy of a specific message part std::string peekstr(size_t index) const { @@ -582,10 +583,15 @@ private: // Disable implicit copying (moving is more efficient) multipart_t(const multipart_t& other) ZMQ_DELETED_FUNCTION; void operator=(const multipart_t& other) ZMQ_DELETED_FUNCTION; -}; +}; // class multipart_t -#endif +#endif // ZMQ_HAS_RVALUE_REFS +inline std::ostream& operator<<(std::ostream& os, const multipart_t& msg) +{ + return os << msg.str(); } -#endif +} // namespace zmq + +#endif // __ZMQ_ADDON_HPP_INCLUDED__