Skip to content

Commit f945a7d

Browse files
author
Giuseppe Corbelli
committed
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
1 parent a96e0de commit f945a7d

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

zmq_addon.hpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#define __ZMQ_ADDON_HPP_INCLUDED__
2626

2727
#include <zmq.hpp>
28+
2829
#include <deque>
2930
#include <iomanip>
3031
#include <sstream>
@@ -328,7 +329,7 @@ class multipart_t
328329
{
329330
return &m_parts[index];
330331
}
331-
332+
332333
// Get a string copy of a specific message part
333334
std::string peekstr(size_t index) const
334335
{
@@ -582,10 +583,15 @@ class multipart_t
582583
// Disable implicit copying (moving is more efficient)
583584
multipart_t(const multipart_t& other) ZMQ_DELETED_FUNCTION;
584585
void operator=(const multipart_t& other) ZMQ_DELETED_FUNCTION;
585-
};
586+
}; // class multipart_t
586587

587-
#endif
588+
#endif // ZMQ_HAS_RVALUE_REFS
588589

590+
inline std::ostream& operator<<(std::ostream& os, const multipart_t& msg)
591+
{
592+
return os << msg.str();
589593
}
590594

591-
#endif
595+
} // namespace zmq
596+
597+
#endif // __ZMQ_ADDON_HPP_INCLUDED__

0 commit comments

Comments
 (0)