1 #ifndef OSMIUM_OSM_TYPES_FROM_STRING_HPP
2 #define OSMIUM_OSM_TYPES_FROM_STRING_HPP
61 if (*input !=
'\0' && !std::isspace(*input)) {
63 auto id = std::strtoll(input, &end, 10);
64 if (
id != std::numeric_limits<long long>::min() &&
id != std::numeric_limits<long long>::max() && *end ==
'\0') {
68 throw std::range_error(std::string(
"illegal id: '") + input +
"'");
87 inline std::pair<osmium::item_type, osmium::object_id_type>
94 if (std::isdigit(*input)) {
102 throw std::range_error(std::string(
"not a valid id: '") + input +
"'");
107 inline unsigned long string_to_ulong(
const char* input,
const char *name) {
108 if (*input !=
'\0' && *input !=
'-' && !std::isspace(*input)) {
110 auto value = std::strtoul(input, &end, 10);
111 if (value != std::numeric_limits<unsigned long>::max() && *end ==
'\0') {
115 throw std::range_error(std::string(
"illegal ") + name +
": '" + input +
"'");
131 return static_cast_with_assert<object_version_type>(detail::string_to_ulong(input,
"version"));
145 return static_cast_with_assert<changeset_id_type>(detail::string_to_ulong(input,
"changeset"));
159 if (input[0] ==
'-' && input[1] ==
'1' && input[2] ==
'\0') {
162 return static_cast_with_assert<signed_user_id_type>(detail::string_to_ulong(input,
"user id"));
176 return static_cast_with_assert<num_changes_type>(detail::string_to_ulong(input,
"value for num changes"));
190 return static_cast_with_assert<num_comments_type>(detail::string_to_ulong(input,
"value for num comments"));
195 #endif // OSMIUM_OSM_TYPES_FROM_STRING_HPP
uint32_t object_version_type
Type for OSM object version number.
Definition: types.hpp:47
type
Definition: entity_bits.hpp:63
item_type
Definition: item_type.hpp:43
uint32_t num_changes_type
Type for changeset num_changes.
Definition: types.hpp:51
object_version_type string_to_object_version(const char *input)
Definition: types_from_string.hpp:129
type from_item_type(osmium::item_type item_type) noexcept
Definition: entity_bits.hpp:106
object_id_type string_to_object_id(const char *input)
Definition: types_from_string.hpp:59
Namespace for everything in the Osmium library.
Definition: assembler.hpp:66
uint32_t num_comments_type
Type for changeset num_comments.
Definition: types.hpp:52
int32_t signed_user_id_type
Type for signed OSM user IDs.
Definition: types.hpp:50
osmium::io::InputIterator< osmium::io::Reader > end(osmium::io::Reader &)
Definition: reader_iterator.hpp:45
uint32_t changeset_id_type
Type for OSM changeset IDs.
Definition: types.hpp:48
int64_t object_id_type
Type for OSM object (node, way, or relation) IDs.
Definition: types.hpp:45
changeset_id_type string_to_changeset_id(const char *input)
Definition: types_from_string.hpp:143
signed_user_id_type string_to_user_id(const char *input)
Definition: types_from_string.hpp:157
item_type char_to_item_type(const char c) noexcept
Definition: item_type.hpp:88
Definition: entity_bits.hpp:65
num_comments_type string_to_num_comments(const char *input)
Definition: types_from_string.hpp:188
num_changes_type string_to_num_changes(const char *input)
Definition: types_from_string.hpp:174