1 #ifndef OSMIUM_OSM_TYPES_FROM_STRING_HPP 2 #define OSMIUM_OSM_TYPES_FROM_STRING_HPP 62 if (*input !=
'\0' && !std::isspace(*input)) {
64 auto id = std::strtoll(input, &end, 10);
65 if (
id != std::numeric_limits<long long>::min() &&
id != std::numeric_limits<long long>::max() && *end ==
'\0') {
69 throw std::range_error(std::string(
"illegal id: '") + input +
"'");
88 inline std::pair<osmium::item_type, osmium::object_id_type>
95 if (std::isdigit(*input)) {
103 throw std::range_error(std::string(
"not a valid id: '") + input +
"'");
108 inline unsigned long string_to_ulong(
const char* input,
const char* name) {
109 if (*input !=
'\0' && *input !=
'-' && !std::isspace(*input)) {
111 auto value = std::strtoul(input, &end, 10);
112 if (value != std::numeric_limits<unsigned long>::max() && *end ==
'\0') {
116 throw std::range_error(std::string(
"illegal ") + name +
": '" + input +
"'");
132 return static_cast_with_assert<object_version_type>(detail::string_to_ulong(input,
"version"));
146 return static_cast_with_assert<changeset_id_type>(detail::string_to_ulong(input,
"changeset"));
160 if (input[0] ==
'-' && input[1] ==
'1' && input[2] ==
'\0') {
163 return static_cast_with_assert<signed_user_id_type>(detail::string_to_ulong(input,
"user id"));
177 return static_cast_with_assert<num_changes_type>(detail::string_to_ulong(input,
"value for num changes"));
191 return static_cast_with_assert<num_comments_type>(detail::string_to_ulong(input,
"value for num comments"));
196 #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:130
type from_item_type(osmium::item_type item_type) noexcept
Definition: entity_bits.hpp:108
object_id_type string_to_object_id(const char *input)
Definition: types_from_string.hpp:60
Namespace for everything in the Osmium library.
Definition: assembler.hpp:63
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:144
signed_user_id_type string_to_user_id(const char *input)
Definition: types_from_string.hpp:158
item_type char_to_item_type(const char c) noexcept
Definition: item_type.hpp:88
Definition: entity_bits.hpp:67
num_comments_type string_to_num_comments(const char *input)
Definition: types_from_string.hpp:189
num_changes_type string_to_num_changes(const char *input)
Definition: types_from_string.hpp:175