qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject [41/50] [abbrv] qpid-proton git commit: PROTON-1084 [cpp binding] Add message annotation support
Date Wed, 30 Dec 2015 21:13:29 GMT
PROTON-1084 [cpp binding] Add message annotation support


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/12d2cd62
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/12d2cd62
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/12d2cd62

Branch: refs/heads/go1
Commit: 12d2cd62cca1a5040c4aa091213d7415ad618b99
Parents: c41ff06
Author: Kim van der Riet <kpvdr@apache.org>
Authored: Tue Dec 22 10:52:42 2015 -0500
Committer: Kim van der Riet <kpvdr@apache.org>
Committed: Tue Dec 22 10:52:42 2015 -0500

----------------------------------------------------------------------
 .../bindings/cpp/include/proton/message.hpp     |  7 +++
 proton-c/bindings/cpp/src/message.cpp           | 48 ++++++++++++++++++++
 2 files changed, 55 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/12d2cd62/proton-c/bindings/cpp/include/proton/message.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/message.hpp b/proton-c/bindings/cpp/include/proton/message.hpp
index f04ea07..b132f5f 100644
--- a/proton-c/bindings/cpp/include/proton/message.hpp
+++ b/proton-c/bindings/cpp/include/proton/message.hpp
@@ -132,6 +132,13 @@ class message
     /** Erase an application property. Returns false if there was no such property. */
     PN_CPP_EXTERN bool erase_property(const std::string &name);
 
+    PN_CPP_EXTERN void annotations(const value&);
+    PN_CPP_EXTERN const data annotations() const;
+    PN_CPP_EXTERN data annotations();
+    PN_CPP_EXTERN void annotation(const proton::amqp_symbol &key, const value &val);
+    PN_CPP_EXTERN value annotation(const proton::amqp_symbol &key) const;
+    PN_CPP_EXTERN bool erase_annotation(const proton::amqp_symbol &key);
+
     /** Encode into a string, growing the string if necessary. */
     PN_CPP_EXTERN void encode(std::string &bytes) const;
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/12d2cd62/proton-c/bindings/cpp/src/message.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/message.cpp b/proton-c/bindings/cpp/src/message.cpp
index dc7e50f..cb29029 100644
--- a/proton-c/bindings/cpp/src/message.cpp
+++ b/proton-c/bindings/cpp/src/message.cpp
@@ -248,6 +248,54 @@ bool message::erase_property(const std::string& name) {
     return false;
 }
 
+void message::annotations(const value& v) {
+    annotations().copy(v);
+}
+
+const data message::annotations() const {
+    return pn_message_annotations(message_);
+}
+
+data message::annotations() {
+    return pn_message_annotations(message_);
+}
+
+namespace {
+typedef std::map<proton::amqp_symbol, value> annotation_map;
+}
+
+void message::annotation(const proton::amqp_symbol &k, const value &v) {
+    annotation_map m;
+    if (!annotations().empty())
+        annotations().get(m);
+    m[k] = v;
+    annotations(m);
+}
+
+value message::annotation(const proton::amqp_symbol &k) const {
+    if (!annotations().empty()) {
+        annotation_map m;
+        annotations().get(m);
+        annotation_map::const_iterator i = m.find(k);
+        if (i != m.end())
+            return i->second;
+    }
+    return value();
+
+}
+
+bool message::erase_annotation(const proton::amqp_symbol &k) {
+    if (!annotations().empty()) {
+        annotation_map m;
+        annotations().get(m);
+        if (m.erase(k)) {
+            annotations(m);
+            return true;
+        }
+    }
+    return false;
+}
+
 void message::encode(std::string &s) const {
     size_t sz = s.capacity();
     if (sz < 512) sz = 512;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message