update libosmium to v2.6.0

This commit is contained in:
Dane Springmeyer
2016-02-10 13:41:22 -08:00
parent bb06bfbbd7
commit c40375a424
253 changed files with 1431 additions and 28359 deletions
+25 -17
View File
@@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@@ -39,9 +39,9 @@ DEALINGS IN THE SOFTWARE.
#include <cstring>
#include <functional>
#include <iterator>
#include <memory>
#include <stdexcept>
#include <utility>
#include <vector>
#include <osmium/memory/item.hpp>
#include <osmium/memory/item_iterator.hpp>
@@ -108,7 +108,7 @@ namespace osmium {
private:
std::vector<unsigned char> m_memory;
std::unique_ptr<unsigned char[]> m_memory;
unsigned char* m_data;
size_t m_capacity;
size_t m_written;
@@ -195,8 +195,8 @@ namespace osmium {
* of the alignment.
*/
explicit Buffer(size_t capacity, auto_grow auto_grow = auto_grow::yes) :
m_memory(capacity),
m_data(m_memory.data()),
m_memory(new unsigned char[capacity]),
m_data(m_memory.get()),
m_capacity(capacity),
m_written(0),
m_committed(0),
@@ -302,18 +302,22 @@ namespace osmium {
* memory management.
* @throws std::invalid_argument if the size isn't a multiple
* of the alignment.
* @throws std::bad_alloc if there isn't enough memory available.
*/
void grow(size_t size) {
assert(m_data);
if (m_memory.empty()) {
if (!m_memory) {
throw std::logic_error("Can't grow Buffer if it doesn't use internal memory management.");
}
if (m_capacity < size) {
if (size % align_bytes != 0) {
throw std::invalid_argument("buffer capacity needs to be multiple of alignment");
}
m_memory.resize(size);
m_data = m_memory.data();
std::unique_ptr<unsigned char[]> memory(new unsigned char[size]);
std::copy_n(m_memory.get(), m_capacity, memory.get());
using std::swap;
swap(m_memory, memory);
m_data = m_memory.get();
m_capacity = size;
}
}
@@ -418,7 +422,7 @@ namespace osmium {
}
// if there's still not enough space, then try growing the buffer.
if (m_written + size > m_capacity) {
if (!m_memory.empty() && (m_auto_grow == auto_grow::yes)) {
if (m_memory && (m_auto_grow == auto_grow::yes)) {
// double buffer size until there is enough space
size_t new_capacity = m_capacity * 2;
while (m_written + size > new_capacity) {
@@ -654,16 +658,16 @@ namespace osmium {
return m_data != nullptr;
}
friend void swap(Buffer& lhs, Buffer& rhs) {
void swap(Buffer& other) {
using std::swap;
swap(lhs.m_memory, rhs.m_memory);
swap(lhs.m_data, rhs.m_data);
swap(lhs.m_capacity, rhs.m_capacity);
swap(lhs.m_written, rhs.m_written);
swap(lhs.m_committed, rhs.m_committed);
swap(lhs.m_auto_grow, rhs.m_auto_grow);
swap(lhs.m_full, rhs.m_full);
swap(m_memory, other.m_memory);
swap(m_data, other.m_data);
swap(m_capacity, other.m_capacity);
swap(m_written, other.m_written);
swap(m_committed, other.m_committed);
swap(m_auto_grow, other.m_auto_grow);
swap(m_full, other.m_full);
}
/**
@@ -714,6 +718,10 @@ namespace osmium {
}; // class Buffer
inline void swap(Buffer& lhs, Buffer& rhs) {
lhs.swap(rhs);
}
/**
* Compare two buffers for equality.
*
+9 -3
View File
@@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@@ -95,12 +95,18 @@ namespace osmium {
}
template <typename TChar, typename TTraits>
friend std::basic_ostream<TChar, TTraits>& operator<<(std::basic_ostream<TChar, TTraits>& out, const CollectionIterator<TMember>& iter) {
return out << static_cast<const void*>(iter.m_data);
void print(std::basic_ostream<TChar, TTraits>& out) const {
out << static_cast<const void*>(m_data);
}
}; // class CollectionIterator
template <typename TChar, typename TTraits, typename TMember>
inline std::basic_ostream<TChar, TTraits>& operator<<(std::basic_ostream<TChar, TTraits>& out, const CollectionIterator<TMember>& iter) {
iter.print(out);
return out;
}
template <typename TMember, osmium::item_type TCollectionItemType>
class Collection : public Item {
+1 -1
View File
@@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@@ -209,12 +209,18 @@ namespace osmium {
}
template <typename TChar, typename TTraits>
friend std::basic_ostream<TChar, TTraits>& operator<<(std::basic_ostream<TChar, TTraits>& out, const ItemIterator<TMember>& iter) {
return out << static_cast<void*>(iter.m_data);
void print(std::basic_ostream<TChar, TTraits>& out) const {
out << static_cast<const void*>(m_data);
}
}; // class ItemIterator
template <typename TChar, typename TTraits, typename TMember>
inline std::basic_ostream<TChar, TTraits>& operator<<(std::basic_ostream<TChar, TTraits>& out, const ItemIterator<TMember>& iter) {
iter.print(out);
return out;
}
} // namespace memory
} // namespace osmium