qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject qpid-proton git commit: NO-JIRA: C++ binding: Rename `data_value` to `value`
Date Fri, 18 Sep 2015 23:16:28 GMT
Repository: qpid-proton
Updated Branches:
  refs/heads/master 7f1c83558 -> c7822d609


NO-JIRA: C++ binding: Rename `data_value` to `value`


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

Branch: refs/heads/master
Commit: c7822d609a00f179e1c82be0c14e10492c09265c
Parents: 7f1c835
Author: Alan Conway <aconway@redhat.com>
Authored: Fri Sep 18 19:16:13 2015 -0400
Committer: Alan Conway <aconway@redhat.com>
Committed: Fri Sep 18 19:16:13 2015 -0400

----------------------------------------------------------------------
 examples/cpp/broker.cpp                         |  1 +
 examples/cpp/direct_recv.cpp                    |  3 +-
 examples/cpp/direct_send.cpp                    |  3 +-
 examples/cpp/encode_decode.cpp                  | 32 ++++----
 examples/cpp/simple_recv.cpp                    |  3 +-
 examples/cpp/simple_send.cpp                    |  3 +-
 proton-c/bindings/cpp/include/proton/data.hpp   | 54 +------------
 proton-c/bindings/cpp/include/proton/value.hpp  | 79 ++++++++++++++++++++
 proton-c/bindings/cpp/src/data.cpp              |  2 +-
 proton-c/bindings/cpp/src/decoder.cpp           |  2 +-
 proton-c/bindings/cpp/src/encoder.cpp           |  2 +-
 proton-c/bindings/cpp/src/interop_test.cpp      | 10 +--
 .../bindings/cpp/src/sync_request_response.cpp  |  4 +-
 tests/tools/apps/cpp/reactor_send.cpp           |  3 +-
 14 files changed, 118 insertions(+), 83 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7822d60/examples/cpp/broker.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/broker.cpp b/examples/cpp/broker.cpp
index f8ea87b..991fb88 100644
--- a/examples/cpp/broker.cpp
+++ b/examples/cpp/broker.cpp
@@ -25,6 +25,7 @@
 #include "proton/container.hpp"
 #include "proton/messaging_handler.hpp"
 #include "proton/url.hpp"
+#include "proton/value.hpp"
 
 #include <iostream>
 #include <sstream>

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7822d60/examples/cpp/direct_recv.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/direct_recv.cpp b/examples/cpp/direct_recv.cpp
index b6e0e9e..e4d6b4e 100644
--- a/examples/cpp/direct_recv.cpp
+++ b/examples/cpp/direct_recv.cpp
@@ -26,6 +26,7 @@
 #include "proton/messaging_handler.hpp"
 #include "proton/link.hpp"
 #include "proton/url.hpp"
+#include "proton/value.hpp"
 
 #include <iostream>
 #include <map>
@@ -47,7 +48,7 @@ class direct_recv : public proton::messaging_handler {
 
     void on_message(proton::event &e) {
         proton::message& msg = e.message();
-        proton::data_value id = msg.id();
+        proton::value id = msg.id();
         if (id.type() == proton::ULONG) {
             if (id.get<int>() < received)
                 return; // ignore duplicate

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7822d60/examples/cpp/direct_send.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/direct_send.cpp b/examples/cpp/direct_send.cpp
index 910c9a0..4c5f4c5 100644
--- a/examples/cpp/direct_send.cpp
+++ b/examples/cpp/direct_send.cpp
@@ -25,6 +25,7 @@
 #include "proton/connection.hpp"
 #include "proton/container.hpp"
 #include "proton/messaging_handler.hpp"
+#include "proton/value.hpp"
 
 #include <iostream>
 #include <map>
@@ -49,7 +50,7 @@ class simple_send : public proton::messaging_handler {
         proton::sender& sender = e.sender();
         while (sender.credit() && sent < total) {
             proton::message msg;
-            msg.id(proton::data_value(sent + 1));
+            msg.id(proton::value(sent + 1));
             std::map<std::string, int> m;
             m["sequence"] = sent+1;
             msg.body(proton::as<proton::MAP>(m));

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7822d60/examples/cpp/encode_decode.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/encode_decode.cpp b/examples/cpp/encode_decode.cpp
index 5657e73..b6669a0 100644
--- a/examples/cpp/encode_decode.cpp
+++ b/examples/cpp/encode_decode.cpp
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-#include <proton/data.hpp>
+#include <proton/value.hpp>
 #include <algorithm>
 #include <iostream>
 #include <iterator>
@@ -37,7 +37,7 @@ void print(proton::data&);
 // Inserting and extracting simple C++ values.
 void simple_insert_extract() {
     cout << endl << "== Simple values: int, string, bool" << endl;
-    proton::data_value dv;
+    proton::value dv;
     dv.encoder() << 42 << "foo" << true;
     print(dv);
     int i;
@@ -49,7 +49,7 @@ void simple_insert_extract() {
     // Encode and decode as AMQP
     string amqp_data = dv.encoder().encode();
     cout << "Encoded as AMQP in " << amqp_data.size() << " bytes" <<
endl;
-    proton::data_value  dt2;
+    proton::value  dt2;
     dt2.decoder().decode(amqp_data);
     dt2.decoder() >> i >> s >> b;
     cout << "Decoded: " << i << ", " << s << ", " <<
b << endl;
@@ -57,7 +57,7 @@ void simple_insert_extract() {
 
 // Inserting values as a specific AMQP type
 void simple_insert_extract_exact_type() {
-    proton::data_value dv;
+    proton::value dv;
     cout << endl << "== Specific AMQP types: byte, long, symbol" << endl;
     dv.encoder() << proton::amqp_byte('x') << proton::amqp_long(123456789123456789)
<< proton::amqp_symbol("bar");
     print(dv);
@@ -118,7 +118,7 @@ void insert_extract_containers() {
     m["one"] = 1;
     m["two"] = 2;
 
-    proton::data_value dv;
+    proton::value dv;
     dv.encoder() << proton::as<proton::ARRAY>(a) << proton::as<proton::LIST>(l)
<< proton::as<proton::MAP>(m);
     print(dv);
 
@@ -132,18 +132,18 @@ void insert_extract_containers() {
 // Containers with mixed types, use value to represent arbitrary AMQP types.
 void mixed_containers() {
     cout << endl << "== List and map of mixed type values." << endl;
-    vector<proton::data_value> l;
-    l.push_back(proton::data_value(42));
-    l.push_back(proton::data_value(proton::amqp_string("foo")));
-    map<proton::data_value, proton::data_value> m;
-    m[proton::data_value("five")] = proton::data_value(5);
-    m[proton::data_value(4)] = proton::data_value("four");
-    proton::data_value dv;
+    vector<proton::value> l;
+    l.push_back(proton::value(42));
+    l.push_back(proton::value(proton::amqp_string("foo")));
+    map<proton::value, proton::value> m;
+    m[proton::value("five")] = proton::value(5);
+    m[proton::value(4)] = proton::value("four");
+    proton::value dv;
     dv.encoder() << proton::as<proton::LIST>(l) << proton::as<proton::MAP>(m);
     print(dv);
 
-    vector<proton::data_value> l1;
-    map<proton::data_value, proton::data_value> m1;
+    vector<proton::value> l1;
+    map<proton::value, proton::value> m1;
     dv.decoder().rewind();
     dv.decoder() >> proton::as<proton::LIST>(l1) >> proton::as<proton::MAP>(m1);
     cout << "Extracted: " << l1 << ", " << m1 << endl;
@@ -152,7 +152,7 @@ void mixed_containers() {
 // Insert using stream operators (see print_next for example of extracting with stream ops.)
 void insert_extract_stream_operators() {
     cout << endl << "== Insert with stream operators." << endl;
-    proton::data_value dv;
+    proton::value dv;
     // Note: array elements must be encoded with the exact type, they are not
     // automaticlly converted. Mismatched types for array elements will not
     // be detected until dv.encode() is called.
@@ -243,7 +243,7 @@ void print_next(proton::data& dv) {
         // A simple type. We could continue the switch for all AMQP types but
         // instead we us the `value` type which can hold and print any AMQP
         // value.
-        proton::data_value v;
+        proton::value v;
         dv.decoder() >> v;
         cout << type << "(" << v << ")";
     }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7822d60/examples/cpp/simple_recv.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/simple_recv.cpp b/examples/cpp/simple_recv.cpp
index f669e30..a3337d9 100644
--- a/examples/cpp/simple_recv.cpp
+++ b/examples/cpp/simple_recv.cpp
@@ -24,6 +24,7 @@
 #include "proton/container.hpp"
 #include "proton/messaging_handler.hpp"
 #include "proton/link.hpp"
+#include "proton/value.hpp"
 
 #include <iostream>
 #include <map>
@@ -47,7 +48,7 @@ class simple_recv : public proton::messaging_handler {
 
     void on_message(proton::event &e) {
         proton::message& msg = e.message();
-        proton::data_value id = msg.id();
+        proton::value id = msg.id();
         if (id.type() == proton::ULONG) {
             if (id.get<int>() < received)
                 return; // ignore duplicate

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7822d60/examples/cpp/simple_send.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/simple_send.cpp b/examples/cpp/simple_send.cpp
index 2898f80..971fbae 100644
--- a/examples/cpp/simple_send.cpp
+++ b/examples/cpp/simple_send.cpp
@@ -24,6 +24,7 @@
 #include "proton/container.hpp"
 #include "proton/messaging_handler.hpp"
 #include "proton/connection.hpp"
+#include "proton/value.hpp"
 
 #include <iostream>
 #include <map>
@@ -47,7 +48,7 @@ class simple_send : public proton::messaging_handler {
         proton::sender& sender = e.sender();
         while (sender.credit() && sent < total) {
             proton::message msg;
-            msg.id(proton::data_value(sent + 1));
+            msg.id(proton::value(sent + 1));
             std::map<std::string, int> m;
             m["sequence"] = sent+1;
             msg.body(proton::as<proton::MAP>(m));

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7822d60/proton-c/bindings/cpp/include/proton/data.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/data.hpp b/proton-c/bindings/cpp/include/proton/data.hpp
index f7fde1b..17e55fb 100644
--- a/proton-c/bindings/cpp/include/proton/data.hpp
+++ b/proton-c/bindings/cpp/include/proton/data.hpp
@@ -35,7 +35,7 @@ class data;
 
 /**
  * Holds a sequence of AMQP values, allows inserting and extracting via encoder() and decoder().
- * Cannot be directly instantiated, use `data_value`
+ * Cannot be directly instantiated, use `value`
  */
 class data : public facade<pn_data_t, data, comparable<data> > {
   public:
@@ -76,56 +76,6 @@ class data : public facade<pn_data_t, data, comparable<data> >
{
   friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const data&);
 };
 
-/** data with normal value semantics: copy, assign etc. */
-class data_value {
-  public:
-    data_value() : data_(data::create()) {}
-    data_value(const data_value& x) : data_(data::create()) { *data_ = *x.data_; }
-    data_value(const data& x) : data_(data::create()) { *data_ = x; }
-    template <class T> data_value(const T& x) : data_(data::create()) { *data_
= x; }
-
-    operator data&() { return *data_; }
-    operator const data&() const { return *data_; }
-
-    data_value& operator=(const data_value& x) { *data_ = *x.data_; return *this;
}
-    data_value& operator=(const data& x) { *data_ = x; return *this; }
-    template <class T> data_value& operator=(const T& x) { *data_ = x; return
*this; }
-
-    void clear() { data_->clear(); }
-    bool empty() const { return data_->empty(); }
-
-    /** Encoder to encode into this value */
-    class encoder& encoder() { return data_->encoder(); }
-
-    /** Decoder to decode from this value */
-    class decoder& decoder() { return data_->decoder(); }
-
-    /** Type of the current value*/
-    type_id type() { return decoder().type(); }
-
-    /** Get the current value, don't move the decoder pointer. */
-    template<class T> void get(T &t) { decoder() >> t; decoder().backup();
}
-
-    /** Get the current value */
-    template<class T> T get() { T t; get(t); return t; }
-    template<class T> operator T() { return get<T>(); }
-
-    bool operator==(const data_value& x) const { return *data_ == *x.data_; }
-    bool operator<(const data_value& x) const { return *data_ < *x.data_; }
-
-  friend inline class encoder& operator<<(class encoder& e, const data_value&
dv) {
-      return e << *dv.data_;
-  }
-  friend inline class decoder& operator>>(class decoder& d, data_value&
dv) {
-      return d >> *dv.data_;
-  }
-  friend inline std::ostream& operator<<(std::ostream& o, const data_value&
dv) {
-      return o << *dv.data_;
-  }
-  private:
-    pn_unique_ptr<data> data_;
-};
-
-
 }
 #endif // DATA_H
+

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7822d60/proton-c/bindings/cpp/include/proton/value.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/value.hpp b/proton-c/bindings/cpp/include/proton/value.hpp
new file mode 100644
index 0000000..c23b0a6
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/value.hpp
@@ -0,0 +1,79 @@
+#ifndef VALUE_H
+#define VALUE_H
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "proton/data.hpp"
+
+namespace proton {
+
+/** AMQP data  with normal value semantics: copy, assign etc. */
+class value {
+  public:
+    value() : data_(data::create()) {}
+    value(const value& x) : data_(data::create()) { *data_ = *x.data_; }
+    value(const data& x) : data_(data::create()) { *data_ = x; }
+    template <class T> value(const T& x) : data_(data::create()) { *data_ = x;
}
+
+    operator data&() { return *data_; }
+    operator const data&() const { return *data_; }
+
+    value& operator=(const value& x) { *data_ = *x.data_; return *this; }
+    value& operator=(const data& x) { *data_ = x; return *this; }
+    template <class T> value& operator=(const T& x) { *data_ = x; return *this;
}
+
+    void clear() { data_->clear(); }
+    bool empty() const { return data_->empty(); }
+
+    /** Encoder to encode into this value */
+    class encoder& encoder() { return data_->encoder(); }
+
+    /** Decoder to decode from this value */
+    class decoder& decoder() { return data_->decoder(); }
+
+    /** Type of the current value*/
+    type_id type() { return decoder().type(); }
+
+    /** Get the current value, don't move the decoder pointer. */
+    template<class T> void get(T &t) { decoder() >> t; decoder().backup();
}
+
+    /** Get the current value */
+    template<class T> T get() { T t; get(t); return t; }
+    template<class T> operator T() { return get<T>(); }
+
+    bool operator==(const value& x) const { return *data_ == *x.data_; }
+    bool operator<(const value& x) const { return *data_ < *x.data_; }
+
+  friend inline class encoder& operator<<(class encoder& e, const value&
dv) {
+      return e << *dv.data_;
+  }
+  friend inline class decoder& operator>>(class decoder& d, value& dv)
{
+      return d >> *dv.data_;
+  }
+  friend inline std::ostream& operator<<(std::ostream& o, const value&
dv) {
+      return o << *dv.data_;
+  }
+  private:
+    pn_unique_ptr<data> data_;
+};
+
+
+}
+#endif // VALUE_H
+

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7822d60/proton-c/bindings/cpp/src/data.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/data.cpp b/proton-c/bindings/cpp/src/data.cpp
index 2cc9279..ad82040 100644
--- a/proton-c/bindings/cpp/src/data.cpp
+++ b/proton-c/bindings/cpp/src/data.cpp
@@ -18,7 +18,7 @@
  */
 
 #include "proton_bits.hpp"
-#include "proton/data.hpp"
+#include "proton/value.hpp"
 
 #include <proton/codec.h>
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7822d60/proton-c/bindings/cpp/src/decoder.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/decoder.cpp b/proton-c/bindings/cpp/src/decoder.cpp
index e118e5a..78e92c8 100644
--- a/proton-c/bindings/cpp/src/decoder.cpp
+++ b/proton-c/bindings/cpp/src/decoder.cpp
@@ -18,7 +18,7 @@
  */
 
 #include "proton/decoder.hpp"
-#include "proton/data.hpp"
+#include "proton/value.hpp"
 #include <proton/codec.h>
 #include "proton_bits.hpp"
 #include "msg.hpp"

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7822d60/proton-c/bindings/cpp/src/encoder.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/encoder.cpp b/proton-c/bindings/cpp/src/encoder.cpp
index 9904b2a..ee52f8d 100644
--- a/proton-c/bindings/cpp/src/encoder.cpp
+++ b/proton-c/bindings/cpp/src/encoder.cpp
@@ -18,7 +18,7 @@
  */
 
 #include "proton/encoder.hpp"
-#include "proton/data.hpp"
+#include "proton/value.hpp"
 #include <proton/codec.h>
 #include "proton_bits.hpp"
 #include "msg.hpp"

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7822d60/proton-c/bindings/cpp/src/interop_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/interop_test.cpp b/proton-c/bindings/cpp/src/interop_test.cpp
index 8637d45..da80814 100644
--- a/proton-c/bindings/cpp/src/interop_test.cpp
+++ b/proton-c/bindings/cpp/src/interop_test.cpp
@@ -19,7 +19,7 @@
 
 #include "proton/decoder.hpp"
 #include "proton/encoder.hpp"
-#include "proton/data.hpp"
+#include "proton/value.hpp"
 #include "test_bits.hpp"
 #include <string>
 #include <sstream>
@@ -49,14 +49,14 @@ template <class T> std::string str(const T& value) {
 
 // Test data ostream operator
 void test_data_ostream() {
-    data_value dv;
+    value dv;
     dv.decoder().decode(read("primitives"));
     ASSERT_EQUAL("true, false, 42, 42, -42, 12345, -12345, 12345, -12345, 0.125, 0.125",
str(dv));
 }
 
 // Test extracting to exact AMQP types works corectly, extrating to invalid types fails.
 void test_decoder_primitves_exact() {
-    data_value dv;
+    value dv;
     dv.decoder().decode(read("primitives"));
     decoder& d(dv.decoder());
     ASSERT(d.more());
@@ -82,7 +82,7 @@ void test_decoder_primitves_exact() {
 
 // Test inserting primitive sand encoding as AMQP.
 void test_encoder_primitives() {
-    data_value dv;
+    value dv;
     encoder& e = dv.encoder();
     e << true << false;
     e << ::uint8_t(42);
@@ -97,7 +97,7 @@ void test_encoder_primitives() {
 
 // Test type conversions.
 void test_value_conversions() {
-    data_value v;
+    value v;
     ASSERT_EQUAL(true, bool(v = true));
     ASSERT_EQUAL(2, int(v=amqp_byte(2)));
     ASSERT_EQUAL(3, long(v=amqp_byte(3)));

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7822d60/proton-c/bindings/cpp/src/sync_request_response.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/sync_request_response.cpp b/proton-c/bindings/cpp/src/sync_request_response.cpp
index 8234010..69249c7 100644
--- a/proton-c/bindings/cpp/src/sync_request_response.cpp
+++ b/proton-c/bindings/cpp/src/sync_request_response.cpp
@@ -22,7 +22,7 @@
 #include "proton/sync_request_response.hpp"
 #include "proton/event.hpp"
 #include "proton/error.hpp"
-#include "proton/data.hpp"
+#include "proton/value.hpp"
 #include "blocking_connection_impl.hpp"
 #include "msg.hpp"
 
@@ -39,7 +39,7 @@ message sync_request_response::call(message &request) {
     if (address_.empty() && request.address().empty())
         throw error(MSG("Request message has no address"));
     // TODO: atomic increment.
-    data_value cid(++correlation_id_);
+    value cid(++correlation_id_);
     request.correlation_id(cid);
     request.reply_to(this->reply_to());
     sender_->send(request);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7822d60/tests/tools/apps/cpp/reactor_send.cpp
----------------------------------------------------------------------
diff --git a/tests/tools/apps/cpp/reactor_send.cpp b/tests/tools/apps/cpp/reactor_send.cpp
index 35c9552..721a7cd 100644
--- a/tests/tools/apps/cpp/reactor_send.cpp
+++ b/tests/tools/apps/cpp/reactor_send.cpp
@@ -26,6 +26,7 @@
 #include "proton/connection.hpp"
 #include "proton/decoder.hpp"
 #include "proton/reactor.h"
+#include "proton/value.hpp"
 
 #include <iostream>
 #include <map>
@@ -47,7 +48,7 @@ class reactor_send : public proton::messaging_handler {
     size_t received_bytes_;
     proton::amqp_binary received_content_;
     bool replying_;
-    proton::data_value id_value_;
+    proton::value id_value_;
     pn_reactor_t *reactor_;
   public:
 


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


Mime
View raw message