[libosmium] 01/05: Imported Upstream version 2.10.3

Bas Couwenberg sebastic at debian.org
Sun Nov 20 17:24:02 UTC 2016


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository libosmium.

commit 22092f86fd3508ac3f89f4394c316c3e5a2d8a66
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Sun Nov 20 18:03:35 2016 +0100

    Imported Upstream version 2.10.3
---
 .travis.yml                                     | 32 ++++++++-
 CHANGELOG.md                                    | 11 +++-
 CMakeLists.txt                                  |  2 +-
 include/osmium/io/detail/queue_util.hpp         |  2 +
 include/osmium/object_pointer_collection.hpp    | 35 +++++++---
 include/osmium/osm/object_comparisons.hpp       |  9 +++
 include/osmium/version.hpp                      |  4 +-
 include/protozero/config.hpp                    | 11 ----
 include/protozero/iterators.hpp                 | 33 ----------
 include/protozero/pbf_reader.hpp                |  5 +-
 include/protozero/version.hpp                   |  4 +-
 test/CMakeLists.txt                             |  1 +
 test/t/index/test_object_pointer_collection.cpp | 86 +++++++++++++++++++++++++
 13 files changed, 173 insertions(+), 62 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 9918112..91ee842 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -109,7 +109,7 @@ matrix:
 
 
     - os: linux
-      compiler: linux-gcc50-release
+      compiler: linux-gcc5-release
       addons:
         apt:
           sources: ['ubuntu-toolchain-r-test', 'boost-latest']
@@ -117,7 +117,7 @@ matrix:
       env: COMPILER='g++-5' BUILD_TYPE='Release'
 
     - os: linux
-      compiler: linux-gcc50-dev
+      compiler: linux-gcc5-dev
       addons:
         apt:
           sources: ['ubuntu-toolchain-r-test', 'boost-latest']
@@ -125,6 +125,23 @@ matrix:
       env: COMPILER='g++-5' BUILD_TYPE='Dev'
 
 
+    - os: linux
+      compiler: linux-gcc6-release
+      addons:
+        apt:
+          sources: ['ubuntu-toolchain-r-test', 'boost-latest']
+          packages: ['g++-6', 'libboost1.55-all-dev', 'libgdal-dev', 'libgeos++-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin']
+      env: COMPILER='g++-6' BUILD_TYPE='Release'
+
+    - os: linux
+      compiler: linux-gcc6-dev
+      addons:
+        apt:
+          sources: ['ubuntu-toolchain-r-test', 'boost-latest']
+          packages: ['g++-6', 'libboost1.55-all-dev', 'libgdal-dev', 'libgeos++-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin']
+      env: COMPILER='g++-6' BUILD_TYPE='Dev'
+
+
     # 3/ OSX Clang Builds
     - os: osx
       osx_image: xcode6.4
@@ -148,6 +165,17 @@ matrix:
       env: COMPILER='clang++' BUILD_TYPE='Dev'
 
 
+    - os: osx
+      osx_image: xcode8
+      compiler: xcode8-clang-release
+      env: COMPILER='clang++' BUILD_TYPE='Release'
+
+    - os: osx
+      osx_image: xcode8
+      compiler: xcode8-clang-dev
+      env: COMPILER='clang++' BUILD_TYPE='Dev'
+
+
 install:
   - DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
   - mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ef5c656..94a6b15 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).
 ### Fixed
 
 
+## [2.10.3] - 2016-11-20
+
+### Changed
+
+- Round out ObjectPointerCollection implementation and test it.
+- Updated embedded protozero to 1.4.5.
+
+
 ## [2.10.2] - 2016-11-16
 
 ### Changed
@@ -480,7 +488,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
   Doxygen (up to version 1.8.8). This version contains a workaround to fix
   this.
 
-[unreleased]: https://github.com/osmcode/libosmium/compare/v2.10.2...HEAD
+[unreleased]: https://github.com/osmcode/libosmium/compare/v2.10.3...HEAD
+[2.10.3]: https://github.com/osmcode/libosmium/compare/v2.10.2...v2.10.3
 [2.10.2]: https://github.com/osmcode/libosmium/compare/v2.10.1...v2.10.2
 [2.10.1]: https://github.com/osmcode/libosmium/compare/v2.10.0...v2.10.1
 [2.10.0]: https://github.com/osmcode/libosmium/compare/v2.9.0...v2.10.0
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6f10b0c..3d65bea 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,7 +25,7 @@ project(libosmium)
 
 set(LIBOSMIUM_VERSION_MAJOR 2)
 set(LIBOSMIUM_VERSION_MINOR 10)
-set(LIBOSMIUM_VERSION_PATCH 2)
+set(LIBOSMIUM_VERSION_PATCH 3)
 
 set(LIBOSMIUM_VERSION
     "${LIBOSMIUM_VERSION_MAJOR}.${LIBOSMIUM_VERSION_MINOR}.${LIBOSMIUM_VERSION_PATCH}")
diff --git a/include/osmium/io/detail/queue_util.hpp b/include/osmium/io/detail/queue_util.hpp
index 021ea7d..386cd22 100644
--- a/include/osmium/io/detail/queue_util.hpp
+++ b/include/osmium/io/detail/queue_util.hpp
@@ -33,6 +33,7 @@ DEALINGS IN THE SOFTWARE.
 
 */
 
+#include <cassert>
 #include <exception>
 #include <future>
 #include <string>
@@ -132,6 +133,7 @@ namespace osmium {
                     if (!m_has_reached_end_of_data) {
                         std::future<T> data_future;
                         m_queue.wait_and_pop(data_future);
+                        assert(data_future.valid());
                         data = std::move(data_future.get());
                         if (at_end_of_data(data)) {
                             m_has_reached_end_of_data = true;
diff --git a/include/osmium/object_pointer_collection.hpp b/include/osmium/object_pointer_collection.hpp
index 4db1c08..71e1502 100644
--- a/include/osmium/object_pointer_collection.hpp
+++ b/include/osmium/object_pointer_collection.hpp
@@ -61,20 +61,24 @@ namespace osmium {
      *   osmium::memory::Buffer buffer = reader.read();
      *   osmium::apply(buffer, objects);
      *
+     * It is not possible to remove pointers from the collection except by
+     * clearing the whole collection.
+     *
      */
     class ObjectPointerCollection : public osmium::handler::Handler {
 
-        std::vector<osmium::OSMObject*> m_objects;
+        std::vector<osmium::OSMObject*> m_objects{};
 
     public:
 
         using iterator       = boost::indirect_iterator<std::vector<osmium::OSMObject*>::iterator, osmium::OSMObject>;
         using const_iterator = boost::indirect_iterator<std::vector<osmium::OSMObject*>::const_iterator, const osmium::OSMObject>;
 
-        ObjectPointerCollection() noexcept :
-            m_objects() {
-        }
+        ObjectPointerCollection() = default;
 
+        /**
+         * Add a pointer to an object to the collection.
+         */
         void osm_object(osmium::OSMObject& object) {
             m_objects.push_back(&object);
         }
@@ -87,20 +91,35 @@ namespace osmium {
             std::sort(m_objects.begin(), m_objects.end(), std::forward<TCompare>(compare));
         }
 
+        /// Is the collection empty?
+        bool empty() const noexcept {
+            return m_objects.empty();
+        }
+
+        /// Return size of the collection.
+        size_t size() const noexcept {
+            return m_objects.size();
+        }
+
+        /// Clear the collection,
+        void clear() {
+            m_objects.clear();
+        }
+
         iterator begin() {
-            return iterator { m_objects.begin() };
+            return iterator{m_objects.begin()};
         }
 
         iterator end() {
-            return iterator { m_objects.end() };
+            return iterator{m_objects.end()};
         }
 
         const_iterator cbegin() const {
-            return const_iterator { m_objects.cbegin() };
+            return const_iterator{m_objects.cbegin()};
         }
 
         const_iterator cend() const {
-            return const_iterator { m_objects.cend() };
+            return const_iterator{m_objects.cend()};
         }
 
     }; // class ObjectPointerCollection
diff --git a/include/osmium/osm/object_comparisons.hpp b/include/osmium/osm/object_comparisons.hpp
index aa0241d..e48773b 100644
--- a/include/osmium/osm/object_comparisons.hpp
+++ b/include/osmium/osm/object_comparisons.hpp
@@ -33,6 +33,7 @@ DEALINGS IN THE SOFTWARE.
 
 */
 
+#include <cassert>
 #include <tuple>
 
 #include <osmium/osm/object.hpp>
@@ -51,7 +52,9 @@ namespace osmium {
             return lhs == rhs;
         }
 
+        /// @pre lhs and rhs must not be nullptr
         bool operator()(const osmium::OSMObject* lhs, const osmium::OSMObject* rhs) const noexcept {
+            assert(lhs && rhs);
             return *lhs == *rhs;
         }
 
@@ -68,7 +71,9 @@ namespace osmium {
                    lhs.id() == rhs.id();
         }
 
+        /// @pre lhs and rhs must not be nullptr
         bool operator()(const osmium::OSMObject* lhs, const osmium::OSMObject* rhs) const noexcept {
+            assert(lhs && rhs);
             return operator()(*lhs, *rhs);
         }
 
@@ -84,7 +89,9 @@ namespace osmium {
             return lhs < rhs;
         }
 
+        /// @pre lhs and rhs must not be nullptr
         bool operator()(const osmium::OSMObject* lhs, const osmium::OSMObject* rhs) const noexcept {
+            assert(lhs && rhs);
             return *lhs < *rhs;
         }
 
@@ -104,7 +111,9 @@ namespace osmium {
                    const_tie(rhs.type(), rhs.id() < 0, rhs.positive_id(), lhs.version(), lhs.timestamp());
         }
 
+        /// @pre lhs and rhs must not be nullptr
         bool operator()(const osmium::OSMObject* lhs, const osmium::OSMObject* rhs) const noexcept {
+            assert(lhs && rhs);
             return operator()(*lhs, *rhs);
         }
 
diff --git a/include/osmium/version.hpp b/include/osmium/version.hpp
index bae10dd..4c66b99 100644
--- a/include/osmium/version.hpp
+++ b/include/osmium/version.hpp
@@ -35,8 +35,8 @@ DEALINGS IN THE SOFTWARE.
 
 #define LIBOSMIUM_VERSION_MAJOR 2
 #define LIBOSMIUM_VERSION_MINOR 10
-#define LIBOSMIUM_VERSION_PATCH 2
+#define LIBOSMIUM_VERSION_PATCH 3
 
-#define LIBOSMIUM_VERSION_STRING "2.10.2"
+#define LIBOSMIUM_VERSION_STRING "2.10.3"
 
 #endif // OSMIUM_VERSION_HPP
diff --git a/include/protozero/config.hpp b/include/protozero/config.hpp
index 8465c96..6fc7749 100644
--- a/include/protozero/config.hpp
+++ b/include/protozero/config.hpp
@@ -35,17 +35,6 @@ documentation.
 # define PROTOZERO_BYTE_ORDER PROTOZERO_LITTLE_ENDIAN
 #endif
 
-// On some ARM machines and depending on compiler settings access to unaligned
-// floating point values will result in a SIGBUS. Do not use the bare pointers
-// in this case.
-#if PROTOZERO_BYTE_ORDER == PROTOZERO_LITTLE_ENDIAN
-# if !defined(__arm__) && !defined(_M_ARM)
-#  ifndef PROTOZERO_DO_NOT_USE_BARE_POINTER
-#   define PROTOZERO_USE_BARE_POINTER_FOR_PACKED_FIXED
-#  endif
-# endif
-#endif
-
 // Check whether __builtin_bswap is available
 #if defined(__GNUC__) || defined(__clang__)
 # define PROTOZERO_USE_BUILTIN_BSWAP
diff --git a/include/protozero/iterators.hpp b/include/protozero/iterators.hpp
index 40259a9..a19f202 100644
--- a/include/protozero/iterators.hpp
+++ b/include/protozero/iterators.hpp
@@ -138,25 +138,6 @@ inline void swap(iterator_range<T>& lhs, iterator_range<T>& rhs) noexcept {
     lhs.swap(rhs);
 }
 
-#ifdef PROTOZERO_USE_BARE_POINTER_FOR_PACKED_FIXED
-
-template <typename T>
-using const_fixed_iterator = const T*;
-
-/**
- * Create iterator_range from char pointers to beginning and end of range.
- *
- * @param first Beginning of range.
- * @param last End of range.
- */
-template <typename T>
-inline iterator_range<const_fixed_iterator<T>> create_fixed_iterator_range(const char* first, const char* last) {
-    return iterator_range<const_fixed_iterator<T>>{reinterpret_cast<const T*>(first),
-                                                   reinterpret_cast<const T*>(last)};
-}
-
-#else
-
 /**
  * A forward iterator used for accessing packed repeated fields of fixed
  * length (fixed32, sfixed32, float, double).
@@ -227,20 +208,6 @@ public:
 }; // class const_fixed_iterator
 
 /**
- * Create iterator_range from char pointers to beginning and end of range.
- *
- * @param first Beginning of range.
- * @param last End of range.
- */
-template <typename T>
-inline iterator_range<const_fixed_iterator<T>> create_fixed_iterator_range(const char* first, const char* last) {
-    return iterator_range<const_fixed_iterator<T>>{const_fixed_iterator<T>(first, last),
-                                                   const_fixed_iterator<T>(last, last)};
-}
-
-#endif
-
-/**
  * A forward iterator used for accessing packed repeated varint fields
  * (int32, uint32, int64, uint64, bool, enum).
  */
diff --git a/include/protozero/pbf_reader.hpp b/include/protozero/pbf_reader.hpp
index 69f2d72..8754cab 100644
--- a/include/protozero/pbf_reader.hpp
+++ b/include/protozero/pbf_reader.hpp
@@ -87,7 +87,8 @@ class pbf_reader {
         protozero_assert(tag() != 0 && "call next() before accessing field value");
         const auto len = get_len_and_skip();
         protozero_assert(len % sizeof(T) == 0);
-        return create_fixed_iterator_range<T>(m_data - len, m_data);
+        return iterator_range<const_fixed_iterator<T>>{const_fixed_iterator<T>(m_data - len, m_data),
+                                                       const_fixed_iterator<T>(m_data, m_data)};
     }
 
     template <typename T>
@@ -178,7 +179,7 @@ public:
      *
      * @post There is no current field.
      */
-    pbf_reader(std::pair<const char*, std::size_t> data) noexcept
+    pbf_reader(const std::pair<const char*, std::size_t>& data) noexcept
         : m_data(data.first),
           m_end(data.first + data.second),
           m_wire_type(pbf_wire_type::unknown),
diff --git a/include/protozero/version.hpp b/include/protozero/version.hpp
index c3e91a3..d7cea48 100644
--- a/include/protozero/version.hpp
+++ b/include/protozero/version.hpp
@@ -23,13 +23,13 @@ documentation.
 #define PROTOZERO_VERSION_MINOR 4
 
 /// The patch number
-#define PROTOZERO_VERSION_PATCH 4
+#define PROTOZERO_VERSION_PATCH 5
 
 /// The complete version number
 #define PROTOZERO_VERSION_CODE (PROTOZERO_VERSION_MAJOR * 10000 + PROTOZERO_VERSION_MINOR * 100 + PROTOZERO_VERSION_PATCH)
 
 /// Version number as string
-#define PROTOZERO_VERSION_STRING "1.4.4"
+#define PROTOZERO_VERSION_STRING "1.4.5"
 
 
 #endif // PROTOZERO_VERSION_HPP
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 051574e..ca025c7 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -158,6 +158,7 @@ add_unit_test(geom test_wkt)
 add_unit_test(index test_id_set)
 add_unit_test(index test_id_to_location ENABLE_IF ${SPARSEHASH_FOUND})
 add_unit_test(index test_file_based_index)
+add_unit_test(index test_object_pointer_collection)
 
 add_unit_test(io test_compression_factory)
 add_unit_test(io test_bzip2 ENABLE_IF ${BZIP2_FOUND} LIBS ${BZIP2_LIBRARIES})
diff --git a/test/t/index/test_object_pointer_collection.cpp b/test/t/index/test_object_pointer_collection.cpp
new file mode 100644
index 0000000..cd5ae73
--- /dev/null
+++ b/test/t/index/test_object_pointer_collection.cpp
@@ -0,0 +1,86 @@
+
+#include "catch.hpp"
+
+#include <osmium/builder/attr.hpp>
+#include <osmium/memory/buffer.hpp>
+#include <osmium/object_pointer_collection.hpp>
+#include <osmium/osm/object_comparisons.hpp>
+#include <osmium/visitor.hpp>
+
+using namespace osmium::builder::attr;
+
+TEST_CASE("Create ObjectPointerCollection") {
+    osmium::memory::Buffer buffer{1024, osmium::memory::Buffer::auto_grow::yes};
+
+    osmium::builder::add_node(buffer,
+        _id(3),
+        _version(3)
+    );
+
+    osmium::builder::add_node(buffer,
+        _id(1),
+        _version(2)
+    );
+
+    osmium::builder::add_node(buffer,
+        _id(1),
+        _version(4)
+    );
+
+    osmium::ObjectPointerCollection collection;
+    REQUIRE(collection.empty());
+    REQUIRE(collection.size() == 0);
+
+    osmium::apply(buffer, collection);
+
+    REQUIRE_FALSE(collection.empty());
+    REQUIRE(collection.size() == 3);
+
+    auto it = collection.cbegin();
+    REQUIRE(it->id() == 3);
+    REQUIRE(it->version() == 3);
+    ++it;
+    REQUIRE(it->id() == 1);
+    REQUIRE(it->version() == 2);
+    ++it;
+    REQUIRE(it->id() == 1);
+    REQUIRE(it->version() == 4);
+    ++it;
+    REQUIRE(it == collection.cend());
+
+    collection.sort(osmium::object_order_type_id_version{});
+
+    REQUIRE(collection.size() == 3);
+
+    it = collection.cbegin();
+    REQUIRE(it->id() == 1);
+    REQUIRE(it->version() == 2);
+    ++it;
+    REQUIRE(it->id() == 1);
+    REQUIRE(it->version() == 4);
+    ++it;
+    REQUIRE(it->id() == 3);
+    REQUIRE(it->version() == 3);
+    ++it;
+    REQUIRE(it == collection.cend());
+
+    collection.sort(osmium::object_order_type_id_reverse_version{});
+
+    it = collection.cbegin();
+    REQUIRE(it->id() == 1);
+    REQUIRE(it->version() == 4);
+    ++it;
+    REQUIRE(it->id() == 1);
+    REQUIRE(it->version() == 2);
+    ++it;
+    REQUIRE(it->id() == 3);
+    REQUIRE(it->version() == 3);
+    ++it;
+    REQUIRE(it == collection.cend());
+
+    collection.clear();
+
+    REQUIRE(collection.empty());
+    REQUIRE(collection.size() == 0);
+}
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/libosmium.git



More information about the Pkg-grass-devel mailing list