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 +
"'");
88 if (std::isdigit(*input)) {
96 throw std::range_error(std::string(
"not a valid id: '") + input +
"'");
101 inline unsigned long string_to_ulong(
const char* input,
const char *name) {
102 if (*input !=
'\0' && *input !=
'-' && !std::isspace(*input)) {
104 auto value = std::strtoul(input, &end, 10);
105 if (value != std::numeric_limits<unsigned long>::max() && *end ==
'\0') {
109 throw std::range_error(std::string(
"illegal ") + name +
": '" + input +
"'");
125 return static_cast_with_assert<object_version_type>(detail::string_to_ulong(input,
"version"));
139 return static_cast_with_assert<changeset_id_type>(detail::string_to_ulong(input,
"changeset"));
153 if (input[0] ==
'-' && input[1] ==
'1' && input[2] ==
'\0') {
156 return static_cast_with_assert<signed_user_id_type>(detail::string_to_ulong(input,
"user id"));
170 return static_cast_with_assert<num_changes_type>(detail::string_to_ulong(input,
"value for num changes"));
184 return static_cast_with_assert<num_comments_type>(detail::string_to_ulong(input,
"value for num comments"));
189 #endif // OSMIUM_OSM_TYPES_FROM_STRING_HPP type
Definition: entity_bits.hpp:60
item_type
Definition: item_type.hpp:43
object_version_type string_to_object_version(const char *input)
Definition: types_from_string.hpp:123
type from_item_type(osmium::item_type item_type) noexcept
Definition: entity_bits.hpp:97
object_id_type string_to_object_id(const char *input)
Definition: types_from_string.hpp:59
int64_t object_id_type
Type for OSM object (node, way, or relation) IDs.
Definition: types.hpp:45
Namespace for everything in the Osmium library.
Definition: assembler.hpp:59
osmium::io::InputIterator< osmium::io::Reader > end(osmium::io::Reader &)
Definition: reader_iterator.hpp:45
changeset_id_type string_to_changeset_id(const char *input)
Definition: types_from_string.hpp:137
int32_t signed_user_id_type
Type for signed OSM user IDs.
Definition: types.hpp:50
signed_user_id_type string_to_user_id(const char *input)
Definition: types_from_string.hpp:151
item_type char_to_item_type(const char c) noexcept
Definition: item_type.hpp:88
Definition: entity_bits.hpp:62
uint32_t object_version_type
Type for OSM object version number.
Definition: types.hpp:47
uint32_t num_changes_type
Type for changeset num_changes.
Definition: types.hpp:51
uint32_t changeset_id_type
Type for OSM changeset IDs.
Definition: types.hpp:48
uint32_t num_comments_type
Type for changeset num_comments.
Definition: types.hpp:52
num_comments_type string_to_num_comments(const char *input)
Definition: types_from_string.hpp:182
num_changes_type string_to_num_changes(const char *input)
Definition: types_from_string.hpp:168