Skip to content

Commit 6c5864c

Browse files
committed
update protozero to 1.6.7
1 parent b203e54 commit 6c5864c

File tree

10 files changed

+152
-80
lines changed

10 files changed

+152
-80
lines changed

contrib/protozero/README.contrib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Source: https://github.com/mapbox/protozero
2-
Revision: v1.6.3
2+
Revision: v1.6.7

contrib/protozero/include/protozero/byteswap.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,29 +51,35 @@ inline uint64_t byteswap_impl(uint64_t value) noexcept {
5151

5252
} // end namespace detail
5353

54+
/// byteswap the data pointed to by ptr in-place.
5455
inline void byteswap_inplace(uint32_t* ptr) noexcept {
5556
*ptr = detail::byteswap_impl(*ptr);
5657
}
5758

59+
/// byteswap the data pointed to by ptr in-place.
5860
inline void byteswap_inplace(uint64_t* ptr) noexcept {
5961
*ptr = detail::byteswap_impl(*ptr);
6062
}
6163

64+
/// byteswap the data pointed to by ptr in-place.
6265
inline void byteswap_inplace(int32_t* ptr) noexcept {
6366
auto bptr = reinterpret_cast<uint32_t*>(ptr);
6467
*bptr = detail::byteswap_impl(*bptr);
6568
}
6669

70+
/// byteswap the data pointed to by ptr in-place.
6771
inline void byteswap_inplace(int64_t* ptr) noexcept {
6872
auto bptr = reinterpret_cast<uint64_t*>(ptr);
6973
*bptr = detail::byteswap_impl(*bptr);
7074
}
7175

76+
/// byteswap the data pointed to by ptr in-place.
7277
inline void byteswap_inplace(float* ptr) noexcept {
7378
auto bptr = reinterpret_cast<uint32_t*>(ptr);
7479
*bptr = detail::byteswap_impl(*bptr);
7580
}
7681

82+
/// byteswap the data pointed to by ptr in-place.
7783
inline void byteswap_inplace(double* ptr) noexcept {
7884
auto bptr = reinterpret_cast<uint64_t*>(ptr);
7985
*bptr = detail::byteswap_impl(*bptr);

contrib/protozero/include/protozero/data_view.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ class data_view {
5555
* @param length Length of the data.
5656
*/
5757
constexpr data_view(const char* ptr, std::size_t length) noexcept
58-
: m_data(ptr),
59-
m_size(length) {
58+
: m_data{ptr},
59+
m_size{length} {
6060
}
6161

6262
/**
@@ -65,8 +65,8 @@ class data_view {
6565
* @param str String with the data.
6666
*/
6767
data_view(const std::string& str) noexcept // NOLINT(google-explicit-constructor, hicpp-explicit-conversions)
68-
: m_data(str.data()),
69-
m_size(str.size()) {
68+
: m_data{str.data()},
69+
m_size{str.size()} {
7070
}
7171

7272
/**
@@ -75,8 +75,8 @@ class data_view {
7575
* @param ptr Pointer to the data.
7676
*/
7777
data_view(const char* ptr) noexcept // NOLINT(google-explicit-constructor, hicpp-explicit-conversions)
78-
: m_data(ptr),
79-
m_size(std::strlen(ptr)) {
78+
: m_data{ptr},
79+
m_size{std::strlen(ptr)} {
8080
}
8181

8282
/**

contrib/protozero/include/protozero/iterators.hpp

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class iterator_range :
5656
* Default constructor. Create empty iterator_range.
5757
*/
5858
constexpr iterator_range() :
59-
P(iterator{}, iterator{}) {
59+
P{iterator{}, iterator{}} {
6060
}
6161

6262
/**
@@ -66,8 +66,8 @@ class iterator_range :
6666
* @param last_iterator Iterator to end of range.
6767
*/
6868
constexpr iterator_range(iterator&& first_iterator, iterator&& last_iterator) :
69-
P(std::forward<iterator>(first_iterator),
70-
std::forward<iterator>(last_iterator)) {
69+
P{std::forward<iterator>(first_iterator),
70+
std::forward<iterator>(last_iterator)} {
7171
}
7272

7373
/// Return iterator to beginning of range.
@@ -164,6 +164,8 @@ class const_fixed_iterator {
164164

165165
public:
166166

167+
/// @cond usual iterator functions not documented
168+
167169
using iterator_category = std::random_access_iterator_tag;
168170
using value_type = T;
169171
using difference_type = std::ptrdiff_t;
@@ -173,7 +175,7 @@ class const_fixed_iterator {
173175
const_fixed_iterator() noexcept = default;
174176

175177
explicit const_fixed_iterator(const char* data) noexcept :
176-
m_data(data) {
178+
m_data{data} {
177179
}
178180

179181
const_fixed_iterator(const const_fixed_iterator&) noexcept = default;
@@ -204,14 +206,6 @@ class const_fixed_iterator {
204206
return tmp;
205207
}
206208

207-
bool operator==(const_fixed_iterator rhs) const noexcept {
208-
return m_data == rhs.m_data;
209-
}
210-
211-
bool operator!=(const_fixed_iterator rhs) const noexcept {
212-
return !(*this == rhs);
213-
}
214-
215209
const_fixed_iterator& operator--() noexcept {
216210
m_data -= sizeof(value_type);
217211
return *this;
@@ -223,6 +217,14 @@ class const_fixed_iterator {
223217
return tmp;
224218
}
225219

220+
friend bool operator==(const_fixed_iterator lhs, const_fixed_iterator rhs) noexcept {
221+
return lhs.m_data == rhs.m_data;
222+
}
223+
224+
friend bool operator!=(const_fixed_iterator lhs, const_fixed_iterator rhs) noexcept {
225+
return !(lhs == rhs);
226+
}
227+
226228
friend bool operator<(const_fixed_iterator lhs, const_fixed_iterator rhs) noexcept {
227229
return lhs.m_data < rhs.m_data;
228230
}
@@ -237,7 +239,6 @@ class const_fixed_iterator {
237239

238240
friend bool operator>=(const_fixed_iterator lhs, const_fixed_iterator rhs) noexcept {
239241
return !(lhs < rhs);
240-
241242
}
242243

243244
const_fixed_iterator& operator+=(difference_type val) noexcept {
@@ -276,6 +277,8 @@ class const_fixed_iterator {
276277
return *(*this + n);
277278
}
278279

280+
/// @endcond
281+
279282
}; // class const_fixed_iterator
280283

281284
/**
@@ -295,6 +298,8 @@ class const_varint_iterator {
295298

296299
public:
297300

301+
/// @cond usual iterator functions not documented
302+
298303
using iterator_category = std::forward_iterator_tag;
299304
using value_type = T;
300305
using difference_type = std::ptrdiff_t;
@@ -318,8 +323,8 @@ class const_varint_iterator {
318323
const_varint_iterator() noexcept = default;
319324

320325
const_varint_iterator(const char* data, const char* end) noexcept :
321-
m_data(data),
322-
m_end(end) {
326+
m_data{data},
327+
m_end{end} {
323328
}
324329

325330
const_varint_iterator(const const_varint_iterator&) noexcept = default;
@@ -357,6 +362,8 @@ class const_varint_iterator {
357362
return !(*this == rhs);
358363
}
359364

365+
/// @endcond
366+
360367
}; // class const_varint_iterator
361368

362369
/**
@@ -368,18 +375,20 @@ class const_svarint_iterator : public const_varint_iterator<T> {
368375

369376
public:
370377

378+
/// @cond usual iterator functions not documented
379+
371380
using iterator_category = std::forward_iterator_tag;
372381
using value_type = T;
373382
using difference_type = std::ptrdiff_t;
374383
using pointer = value_type*;
375384
using reference = value_type&;
376385

377386
const_svarint_iterator() noexcept :
378-
const_varint_iterator<T>() {
387+
const_varint_iterator<T>{} {
379388
}
380389

381390
const_svarint_iterator(const char* data, const char* end) noexcept :
382-
const_varint_iterator<T>(data, end) {
391+
const_varint_iterator<T>{data, end} {
383392
}
384393

385394
const_svarint_iterator(const const_svarint_iterator&) = default;
@@ -409,6 +418,8 @@ class const_svarint_iterator : public const_varint_iterator<T> {
409418
return tmp;
410419
}
411420

421+
/// @endcond
422+
412423
}; // class const_svarint_iterator
413424

414425
} // end namespace protozero
@@ -419,6 +430,8 @@ namespace std {
419430
// functions can't be partially specialized, we have to do this for
420431
// every value_type we are using.
421432

433+
/// @cond individual overloads do not need to be documented
434+
422435
template <>
423436
inline typename protozero::const_varint_iterator<int32_t>::difference_type
424437
distance<protozero::const_varint_iterator<int32_t>>(protozero::const_varint_iterator<int32_t> first, // NOLINT(readability-inconsistent-declaration-parameter-name)
@@ -461,6 +474,8 @@ namespace std {
461474
return protozero::const_svarint_iterator<int64_t>::distance(first, last);
462475
}
463476

477+
/// @endcond
478+
464479
} // end namespace std
465480

466481
#endif // PROTOZERO_ITERATORS_HPP

contrib/protozero/include/protozero/pbf_builder.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class pbf_builder : public pbf_writer {
5555
* doesn't have to be empty. The pbf_message object will just append data.
5656
*/
5757
explicit pbf_builder(std::string& data) noexcept :
58-
pbf_writer(data) {
58+
pbf_writer{data} {
5959
}
6060

6161
/**
@@ -67,7 +67,7 @@ class pbf_builder : public pbf_writer {
6767
*/
6868
template <typename P>
6969
pbf_builder(pbf_writer& parent_writer, P tag) noexcept :
70-
pbf_writer(parent_writer, pbf_tag_type(tag)) {
70+
pbf_writer{parent_writer, pbf_tag_type(tag)} {
7171
}
7272

7373
/// @cond INTERNAL

contrib/protozero/include/protozero/pbf_message.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class pbf_message : public pbf_reader {
7878
*/
7979
template <typename... Args>
8080
pbf_message(Args&&... args) noexcept : // NOLINT(google-explicit-constructor, hicpp-explicit-conversions)
81-
pbf_reader(std::forward<Args>(args)...) {
81+
pbf_reader{std::forward<Args>(args)...} {
8282
}
8383

8484
/**

contrib/protozero/include/protozero/pbf_reader.hpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ class pbf_reader {
9999
template <typename T>
100100
T get_varint() {
101101
const auto val = static_cast<T>(decode_varint(&m_data, m_end));
102-
assert(m_data <= m_end);
103102
return val;
104103
}
105104

@@ -114,7 +113,7 @@ class pbf_reader {
114113
}
115114

116115
void skip_bytes(pbf_length_type len) {
117-
if (m_data + len > m_end) {
116+
if (m_end - m_data < static_cast<ptrdiff_t>(len)) {
118117
throw end_of_buffer_exception{};
119118
}
120119
m_data += len;
@@ -153,8 +152,8 @@ class pbf_reader {
153152
* @post There is no current field.
154153
*/
155154
explicit pbf_reader(const data_view& view) noexcept
156-
: m_data(view.data()),
157-
m_end(view.data() + view.size()) {
155+
: m_data{view.data()},
156+
m_end{view.data() + view.size()} {
158157
}
159158

160159
/**
@@ -168,8 +167,8 @@ class pbf_reader {
168167
* @post There is no current field.
169168
*/
170169
pbf_reader(const char* data, std::size_t size) noexcept
171-
: m_data(data),
172-
m_end(data + size) {
170+
: m_data{data},
171+
m_end{data + size} {
173172
}
174173

175174
#ifndef PROTOZERO_STRICT_API
@@ -185,8 +184,8 @@ class pbf_reader {
185184
* @deprecated Use one of the other constructors.
186185
*/
187186
explicit pbf_reader(const std::pair<const char*, std::size_t>& data) noexcept
188-
: m_data(data.first),
189-
m_end(data.first + data.second) {
187+
: m_data{data.first},
188+
m_end{data.first + data.second} {
190189
}
191190
#endif
192191

@@ -201,8 +200,8 @@ class pbf_reader {
201200
* @post There is no current field.
202201
*/
203202
explicit pbf_reader(const std::string& data) noexcept
204-
: m_data(data.data()),
205-
m_end(data.data() + data.size()) {
203+
: m_data{data.data()},
204+
m_end{data.data() + data.size()} {
206205
}
207206

208207
/**
@@ -244,7 +243,14 @@ class pbf_reader {
244243
* read.
245244
*/
246245
operator bool() const noexcept { // NOLINT(google-explicit-constructor, hicpp-explicit-conversions)
247-
return m_data < m_end;
246+
return m_data != m_end;
247+
}
248+
249+
/**
250+
* Get a view of the not yet read data.
251+
*/
252+
data_view data() const noexcept {
253+
return {m_data, static_cast<std::size_t>(m_end - m_data)};
248254
}
249255

250256
/**
@@ -471,7 +477,6 @@ class pbf_reader {
471477
default:
472478
break;
473479
}
474-
assert(m_data <= m_end);
475480
}
476481

477482
///@{

0 commit comments

Comments
 (0)