Skip to content

Commit

Permalink
Cleanup and some new asserts for o5m parser code
Browse files Browse the repository at this point in the history
  • Loading branch information
joto committed Apr 22, 2021
1 parent 66c5efe commit 7e0a086
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions include/osmium/io/detail/o5m_input_format.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ DEALINGS IN THE SOFTWARE.

#include <algorithm>
#include <array>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstring>
Expand Down Expand Up @@ -129,6 +130,8 @@ namespace osmium {
}

void add(const char* string, std::size_t size) {
assert(string);

if (m_table.empty()) {
m_table.resize(entry_size * number_of_entries);
}
Expand Down Expand Up @@ -260,8 +263,10 @@ namespace osmium {
}

const char* decode_string(const char** dataptr, const char* const end) {
assert(*dataptr != end);

if (**dataptr == 0x00) { // get inline string
(*dataptr)++;
++(*dataptr);
if (*dataptr == end) {
throw o5m_error{"string format error"};
}
Expand All @@ -273,6 +278,8 @@ namespace osmium {
}

std::pair<osmium::user_id_type, const char*> decode_user(const char** dataptr, const char* const end) {
assert(*dataptr != end);

const bool update_pointer = (**dataptr == 0x00);
const char* data = decode_string(dataptr, end);
const char* start = data;
Expand Down Expand Up @@ -367,7 +374,7 @@ namespace osmium {
object.set_uid(uid_user.first);
user = uid_user.second;
} else {
object.set_uid(user_id_type(0));
object.set_uid(user_id_type{0});
}
}
}
Expand Down Expand Up @@ -436,6 +443,8 @@ namespace osmium {
}

std::pair<osmium::item_type, const char*> decode_role(const char** dataptr, const char* const end) {
assert(*dataptr != end);

const bool update_pointer = (**dataptr == 0x00);
const char* data = decode_string(dataptr, end);
const char* start = data;
Expand Down

0 comments on commit 7e0a086

Please sign in to comment.