You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2018/05/08 15:58:53 UTC
qpid-proton git commit: PROTON-1841: [cpp] add missing ostream<< and
to_string for proton::message
Repository: qpid-proton
Updated Branches:
refs/heads/master 0a5c18a10 -> 3d46b4f02
PROTON-1841: [cpp] add missing ostream<< and to_string for proton::message
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/3d46b4f0
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/3d46b4f0
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/3d46b4f0
Branch: refs/heads/master
Commit: 3d46b4f0220e7e56ce5167ab87d4df15f3ca1583
Parents: 0a5c18a
Author: Alan Conway <ac...@redhat.com>
Authored: Wed May 2 11:54:20 2018 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue May 8 11:58:00 2018 -0400
----------------------------------------------------------------------
cpp/docs/user.doxygen.in | 1 -
cpp/include/proton/message.hpp | 6 ++++++
cpp/src/message.cpp | 10 ++++++++++
cpp/src/message_test.cpp | 14 ++++++++++++++
4 files changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d46b4f0/cpp/docs/user.doxygen.in
----------------------------------------------------------------------
diff --git a/cpp/docs/user.doxygen.in b/cpp/docs/user.doxygen.in
index 30aa5d1..6bcd1bd 100644
--- a/cpp/docs/user.doxygen.in
+++ b/cpp/docs/user.doxygen.in
@@ -26,7 +26,6 @@ OUTPUT_LANGUAGE = English
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ALWAYS_DETAILED_SEC = NO
-INLINE_INHERITED_MEMB = YES
JAVADOC_AUTOBRIEF = YES
MULTILINE_CPP_IS_BRIEF = NO
INHERIT_DOCS = YES
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d46b4f0/cpp/include/proton/message.hpp
----------------------------------------------------------------------
diff --git a/cpp/include/proton/message.hpp b/cpp/include/proton/message.hpp
index 50e12e4..347eadb 100644
--- a/cpp/include/proton/message.hpp
+++ b/cpp/include/proton/message.hpp
@@ -317,6 +317,9 @@ class message {
/// Default priority assigned to new messages.
PN_CPP_EXTERN static const uint8_t default_priority;
+ /// Human readable string representation
+ friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const message&);
+
/// @cond INTERNAL
private:
struct impl;
@@ -329,6 +332,9 @@ class message {
/// @endcond
};
+/// Human readable string representation
+PN_CPP_EXTERN std::string to_string(const message&);
+
} // proton
#endif // PROTON_MESSAGE_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d46b4f0/cpp/src/message.cpp
----------------------------------------------------------------------
diff --git a/cpp/src/message.cpp b/cpp/src/message.cpp
index 5e9487b..5c0df8d 100644
--- a/cpp/src/message.cpp
+++ b/cpp/src/message.cpp
@@ -320,4 +320,14 @@ void message::group_sequence(int32_t d) { pn_message_set_group_sequence(pn_msg()
const uint8_t message::default_priority = PN_DEFAULT_PRIORITY;
+std::ostream& operator<<(std::ostream& o, const message& m) {
+ return o << inspectable(m.pn_msg());
+}
+
+std::string to_string(const message& m) {
+ std::ostringstream os;
+ os << m;
+ return os.str();
+}
+
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d46b4f0/cpp/src/message_test.cpp
----------------------------------------------------------------------
diff --git a/cpp/src/message_test.cpp b/cpp/src/message_test.cpp
index 4508216..9a0036a 100644
--- a/cpp/src/message_test.cpp
+++ b/cpp/src/message_test.cpp
@@ -194,6 +194,19 @@ void test_message_reuse() {
ASSERT_EQUAL(value("b"), m1.properties().get("a"));
}
+void test_message_print() {
+ message m("hello");
+ m.to("to");
+ m.user("user");
+ m.subject("subject");
+ m.content_type("weird");
+ m.correlation_id(23);
+ m.properties().put("foo", "bar");
+ m.properties().put("num", 9);
+ m.delivery_annotations().put("deliverme", "please");
+ ASSERT_EQUAL("Message{address=\"to\", user_id=\"user\", subject=\"subject\", correlation_id=23, content_type=\"weird\", body=\"hello\"}", to_string(m));
+}
+
}
int main(int, char**) {
@@ -203,5 +216,6 @@ int main(int, char**) {
RUN_TEST(failed, test_message_body());
RUN_TEST(failed, test_message_maps());
RUN_TEST(failed, test_message_reuse());
+ RUN_TEST(failed, test_message_print());
return failed;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org