Repository: qpid-proton Updated Branches: refs/heads/master 1b43731d6 -> 63a904d0b
PROTON-1200: Move data.hpp into codec; fix a stray include Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/63a904d0 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/63a904d0 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/63a904d0 Branch: refs/heads/master Commit: 63a904d0ba40c7dcea2c6147b5b2efce69a75d6a Parents: 1b43731 Author: Justin Ross <[email protected]> Authored: Mon May 16 21:15:06 2016 -0700 Committer: Justin Ross <[email protected]> Committed: Mon May 16 21:15:06 2016 -0700 ---------------------------------------------------------------------- .../bindings/cpp/include/proton/codec/data.hpp | 133 +++++++++++++++++++ .../cpp/include/proton/codec/decoder.hpp | 2 +- .../cpp/include/proton/codec/encoder.hpp | 2 +- .../bindings/cpp/include/proton/container.hpp | 10 +- proton-c/bindings/cpp/include/proton/data.hpp | 133 ------------------- proton-c/bindings/cpp/src/codec_test.cpp | 2 +- proton-c/bindings/cpp/src/contexts.hpp | 2 +- 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/value.cpp | 2 +- 11 files changed, 146 insertions(+), 146 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/63a904d0/proton-c/bindings/cpp/include/proton/codec/data.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/codec/data.hpp b/proton-c/bindings/cpp/include/proton/codec/data.hpp new file mode 100644 index 0000000..968f243 --- /dev/null +++ b/proton-c/bindings/cpp/include/proton/codec/data.hpp @@ -0,0 +1,133 @@ +#ifndef PROTON_CODEC_DATA_HPP +#define PROTON_CODEC_DATA_HPP + +/* + * + * 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/internal/object.hpp" +#include "proton/types_fwd.hpp" +#include "proton/type_id.hpp" + +struct pn_data_t; + +namespace proton { + +class value; + +// XXX -> internal namespace +namespace codec { + +/// @cond INTERNAL +/// Wrapper for a proton data object. +class data : public internal::object<pn_data_t> { + /// Wrap an existing proton-C data object. + data(pn_data_t* d) : internal::object<pn_data_t>(d) {} + + public: + /// Create an empty data. + data() : internal::object<pn_data_t>(0) {} + + /// Create a new data object. + PN_CPP_EXTERN static data create(); + + /// Copy the contents of another data object. + PN_CPP_EXTERN void copy(const data&); + + /// Clear the data. + PN_CPP_EXTERN void clear(); + + /// Rewind current position to the start. + PN_CPP_EXTERN void rewind(); + + /// True if there are no values. + PN_CPP_EXTERN bool empty() const; + + /// Append the contents of another data object. + PN_CPP_EXTERN int append(data src); + + /// Append up to limit items from data object. + PN_CPP_EXTERN int appendn(data src, int limit); + + PN_CPP_EXTERN bool next(); + PN_CPP_EXTERN void* point() const; + PN_CPP_EXTERN void restore(void* h); + + protected: + void narrow(); + void widen(); + + friend class internal::factory<data>; + friend struct state_guard; + friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const data&); +}; +/// @endcond + +/// **Experimental** - Save and restore codec state +/// +/// A state_guard saves the state and restores it in the destructor +/// unless cancel() is called. +struct state_guard { + /// @cond INTERNAL + data& data_; + void* point_; + bool cancel_; + /// @endcond + + /// @cond INTERNAL + state_guard(data& d) : data_(d), point_(data_.point()), cancel_(false) {} + /// @endcond + + ~state_guard() { if (!cancel_) data_.restore(point_); } + + /// Discard the saved state. + void cancel() { cancel_ = true; } +}; + +/// **Experimental** - Start encoding a complex type. +struct start { + /// @cond INTERNAL + /// XXX Document + start(type_id type_=NULL_TYPE, type_id element_=NULL_TYPE, + bool described_=false, size_t size_=0) : + type(type_), element(element_), is_described(described_), size(size_) {} + + type_id type; ///< The container type: ARRAY, LIST, MAP or DESCRIBED. + type_id element; ///< the element type for array only. + bool is_described; ///< true if first value is a descriptor. + size_t size; ///< the element count excluding the descriptor (if any) + /// @endcond + + /// @cond INTERNAL + /// XXX Document + static start array(type_id element, bool described=false) { return start(ARRAY, element, described); } + static start list() { return start(LIST); } + static start map() { return start(MAP); } + static start described() { return start(DESCRIBED, NULL_TYPE, true); } + /// @endcond +}; + +/// **Experimental** - Finish inserting or extracting a complex type. +struct finish {}; + +} // codec +} // proton + +#endif // PROTON_CODEC_DATA_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/63a904d0/proton-c/bindings/cpp/include/proton/codec/decoder.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/codec/decoder.hpp b/proton-c/bindings/cpp/include/proton/codec/decoder.hpp index 7904982..3363811 100644 --- a/proton-c/bindings/cpp/include/proton/codec/decoder.hpp +++ b/proton-c/bindings/cpp/include/proton/codec/decoder.hpp @@ -22,7 +22,7 @@ * */ -#include "proton/data.hpp" +#include "proton/codec/data.hpp" #include "proton/internal/type_traits.hpp" #include "proton/types_fwd.hpp" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/63a904d0/proton-c/bindings/cpp/include/proton/codec/encoder.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/codec/encoder.hpp b/proton-c/bindings/cpp/include/proton/codec/encoder.hpp index e174c73..a476ffc 100644 --- a/proton-c/bindings/cpp/include/proton/codec/encoder.hpp +++ b/proton-c/bindings/cpp/include/proton/codec/encoder.hpp @@ -22,7 +22,7 @@ * */ -#include "proton/data.hpp" +#include "proton/codec/data.hpp" #include "proton/internal/type_traits.hpp" #include "proton/types_fwd.hpp" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/63a904d0/proton-c/bindings/cpp/include/proton/container.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/container.hpp b/proton-c/bindings/cpp/include/proton/container.hpp index 7e9807a..f7ae36d 100644 --- a/proton-c/bindings/cpp/include/proton/container.hpp +++ b/proton-c/bindings/cpp/include/proton/container.hpp @@ -24,11 +24,11 @@ // FIXME aconway 2016-05-04: doc -#include <proton/connection_options.hpp> -#include <proton/error_condition.hpp> -#include <proton/listener.hpp> -#include <proton/internal/pn_unique_ptr.hpp> -#include <proton/thread_safe.hpp> +#include "proton/connection_options.hpp" +#include "proton/error_condition.hpp" +#include "proton/listener.hpp" +#include "proton/internal/pn_unique_ptr.hpp" +#include "proton/thread_safe.hpp" #include <string> http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/63a904d0/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 deleted file mode 100644 index 968f243..0000000 --- a/proton-c/bindings/cpp/include/proton/data.hpp +++ /dev/null @@ -1,133 +0,0 @@ -#ifndef PROTON_CODEC_DATA_HPP -#define PROTON_CODEC_DATA_HPP - -/* - * - * 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/internal/object.hpp" -#include "proton/types_fwd.hpp" -#include "proton/type_id.hpp" - -struct pn_data_t; - -namespace proton { - -class value; - -// XXX -> internal namespace -namespace codec { - -/// @cond INTERNAL -/// Wrapper for a proton data object. -class data : public internal::object<pn_data_t> { - /// Wrap an existing proton-C data object. - data(pn_data_t* d) : internal::object<pn_data_t>(d) {} - - public: - /// Create an empty data. - data() : internal::object<pn_data_t>(0) {} - - /// Create a new data object. - PN_CPP_EXTERN static data create(); - - /// Copy the contents of another data object. - PN_CPP_EXTERN void copy(const data&); - - /// Clear the data. - PN_CPP_EXTERN void clear(); - - /// Rewind current position to the start. - PN_CPP_EXTERN void rewind(); - - /// True if there are no values. - PN_CPP_EXTERN bool empty() const; - - /// Append the contents of another data object. - PN_CPP_EXTERN int append(data src); - - /// Append up to limit items from data object. - PN_CPP_EXTERN int appendn(data src, int limit); - - PN_CPP_EXTERN bool next(); - PN_CPP_EXTERN void* point() const; - PN_CPP_EXTERN void restore(void* h); - - protected: - void narrow(); - void widen(); - - friend class internal::factory<data>; - friend struct state_guard; - friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const data&); -}; -/// @endcond - -/// **Experimental** - Save and restore codec state -/// -/// A state_guard saves the state and restores it in the destructor -/// unless cancel() is called. -struct state_guard { - /// @cond INTERNAL - data& data_; - void* point_; - bool cancel_; - /// @endcond - - /// @cond INTERNAL - state_guard(data& d) : data_(d), point_(data_.point()), cancel_(false) {} - /// @endcond - - ~state_guard() { if (!cancel_) data_.restore(point_); } - - /// Discard the saved state. - void cancel() { cancel_ = true; } -}; - -/// **Experimental** - Start encoding a complex type. -struct start { - /// @cond INTERNAL - /// XXX Document - start(type_id type_=NULL_TYPE, type_id element_=NULL_TYPE, - bool described_=false, size_t size_=0) : - type(type_), element(element_), is_described(described_), size(size_) {} - - type_id type; ///< The container type: ARRAY, LIST, MAP or DESCRIBED. - type_id element; ///< the element type for array only. - bool is_described; ///< true if first value is a descriptor. - size_t size; ///< the element count excluding the descriptor (if any) - /// @endcond - - /// @cond INTERNAL - /// XXX Document - static start array(type_id element, bool described=false) { return start(ARRAY, element, described); } - static start list() { return start(LIST); } - static start map() { return start(MAP); } - static start described() { return start(DESCRIBED, NULL_TYPE, true); } - /// @endcond -}; - -/// **Experimental** - Finish inserting or extracting a complex type. -struct finish {}; - -} // codec -} // proton - -#endif // PROTON_CODEC_DATA_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/63a904d0/proton-c/bindings/cpp/src/codec_test.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/codec_test.cpp b/proton-c/bindings/cpp/src/codec_test.cpp index 293da17..3aa7541 100644 --- a/proton-c/bindings/cpp/src/codec_test.cpp +++ b/proton-c/bindings/cpp/src/codec_test.cpp @@ -20,7 +20,7 @@ #include "test_bits.hpp" #include <proton/types.hpp> -#include <proton/data.hpp> +#include <proton/codec/data.hpp> #include <proton/config.hpp> namespace { http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/63a904d0/proton-c/bindings/cpp/src/contexts.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/contexts.hpp b/proton-c/bindings/cpp/src/contexts.hpp index 05a4fa7..74a763c 100644 --- a/proton-c/bindings/cpp/src/contexts.hpp +++ b/proton-c/bindings/cpp/src/contexts.hpp @@ -28,7 +28,7 @@ #include "proton/event_loop.hpp" #include "proton/listen_handler.hpp" #include "proton/message.hpp" -#include "proton/pn_unique_ptr.hpp" +#include "proton/internal/pn_unique_ptr.hpp" #include "proton/io/link_namer.hpp" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/63a904d0/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 3f5aa5e..e4b71dd 100644 --- a/proton-c/bindings/cpp/src/data.cpp +++ b/proton-c/bindings/cpp/src/data.cpp @@ -21,7 +21,7 @@ #include <proton/binary.hpp> #include <proton/codec/encoder.hpp> -#include <proton/data.hpp> +#include <proton/codec/data.hpp> #include <proton/decimal.hpp> #include <proton/message_id.hpp> #include <proton/symbol.hpp> http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/63a904d0/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 d6ba4e5..fa7055e 100644 --- a/proton-c/bindings/cpp/src/decoder.cpp +++ b/proton-c/bindings/cpp/src/decoder.cpp @@ -20,7 +20,7 @@ #include <proton/annotation_key.hpp> #include <proton/binary.hpp> #include <proton/codec/encoder.hpp> -#include <proton/data.hpp> +#include <proton/codec/data.hpp> #include <proton/decimal.hpp> #include <proton/message_id.hpp> #include <proton/scalar.hpp> http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/63a904d0/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 3abd2ca..4932d13 100644 --- a/proton-c/bindings/cpp/src/encoder.cpp +++ b/proton-c/bindings/cpp/src/encoder.cpp @@ -24,7 +24,7 @@ #include <proton/annotation_key.hpp> #include <proton/binary.hpp> #include <proton/codec/encoder.hpp> -#include <proton/data.hpp> +#include <proton/codec/data.hpp> #include <proton/decimal.hpp> #include <proton/message_id.hpp> #include <proton/internal/scalar_base.hpp> http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/63a904d0/proton-c/bindings/cpp/src/value.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/value.cpp b/proton-c/bindings/cpp/src/value.cpp index ca229b9..dd4f108 100644 --- a/proton-c/bindings/cpp/src/value.cpp +++ b/proton-c/bindings/cpp/src/value.cpp @@ -18,7 +18,7 @@ */ #include "proton_bits.hpp" -#include "proton/data.hpp" +#include "proton/codec/data.hpp" #include "proton/value.hpp" #include "proton/types.hpp" #include "proton/scalar.hpp" --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
