1 #ifndef OSMIUM_OSM_TYPES_FROM_STRING_HPP 2 #define OSMIUM_OSM_TYPES_FROM_STRING_HPP 62 if (*input !=
'\0' && !std::isspace(*input)) {
64 const auto id = std::strtoll(input, &
end, 10);
65 if (
id != std::numeric_limits<long long>::min() &&
66 id != std::numeric_limits<long long>::max() &&
71 throw std::range_error{std::string{
"illegal id: '"} + input +
"'"};
90 inline std::pair<osmium::item_type, osmium::object_id_type>
97 if (std::isdigit(*input)) {
105 throw std::range_error{std::string{
"not a valid id: '"} + input +
"'"};
110 inline uint32_t string_to_ulong(
const char* input,
const char* name) {
111 if (input[0] ==
'-' && input[1] ==
'1' && input[2] ==
'\0') {
114 if (*input !=
'\0' && *input !=
'-' && !std::isspace(*input)) {
116 const auto value = std::strtoul(input, &
end, 10);
117 if (value < std::numeric_limits<uint32_t>::max() && *
end ==
'\0') {
118 return static_cast<uint32_t>(value);
121 throw std::range_error{std::string{
"illegal "} + name +
": '" + input +
"'"};
137 return detail::string_to_ulong(input,
"version");
151 return detail::string_to_ulong(input,
"changeset");
167 if (input[0] ==
'-' && input[1] ==
'1' && input[2] ==
'\0') {
170 const auto value = detail::string_to_ulong(input,
"user id");
171 if (value > static_cast<uint32_t>(std::numeric_limits<int32_t>::max())) {
172 throw std::range_error{
"illegal user id"};
174 return static_cast<signed_user_id_type>(value);
188 return detail::string_to_ulong(input,
"user id");
202 return detail::string_to_ulong(input,
"value for num changes");
216 return detail::string_to_ulong(input,
"value for num comments");
221 #endif // OSMIUM_OSM_TYPES_FROM_STRING_HPP uint32_t object_version_type
Type for OSM object version number.
Definition: types.hpp:47
uint32_t user_id_type
Type for OSM user IDs.
Definition: types.hpp:49
#define OSMIUM_DEPRECATED
Definition: compatibility.hpp:50
type
Definition: entity_bits.hpp:63
item_type
Definition: item_type.hpp:43
InputIterator< Reader > end(Reader &)
Definition: reader_iterator.hpp:47
uint32_t num_changes_type
Type for changeset num_changes.
Definition: types.hpp:51
OSMIUM_DEPRECATED signed_user_id_type string_to_user_id(const char *input)
Definition: types_from_string.hpp:165
user_id_type string_to_uid(const char *input)
Definition: types_from_string.hpp:186
object_version_type string_to_object_version(const char *input)
Definition: types_from_string.hpp:135
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:53
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
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:149
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:214
num_changes_type string_to_num_changes(const char *input)
Definition: types_from_string.hpp:200