diff --git a/src/util/NumberParser.cxx b/src/util/NumberParser.cxx index 995e9f9ca..b9d796dbb 100644 --- a/src/util/NumberParser.cxx +++ b/src/util/NumberParser.cxx @@ -1,5 +1,5 @@ /* - * Copyright 2009-2019 Max Kellermann + * Copyright 2009-2022 Max Kellermann * http://www.musicpd.org * * Redistribution and use in source and binary forms, with or without @@ -29,22 +29,21 @@ */ #include "NumberParser.hxx" -#include "StringView.hxx" #include #include int64_t -ParseInt64(StringView s, const char **endptr_r, int base) noexcept +ParseInt64(std::string_view s, const char **endptr_r, int base) noexcept { char buffer[32]; - *std::copy_n(s.data, std::min(s.size, std::size(buffer) - 1), + *std::copy_n(s.data(), std::min(s.size(), std::size(buffer) - 1), buffer) = 0; char *endptr; const auto result = ParseInt64(buffer, &endptr, base); if (endptr_r != nullptr) - *endptr_r = s.data + (endptr - buffer); + *endptr_r = s.data() + (endptr - buffer); return result; } diff --git a/src/util/NumberParser.hxx b/src/util/NumberParser.hxx index d0ecbd061..dd65ffe68 100644 --- a/src/util/NumberParser.hxx +++ b/src/util/NumberParser.hxx @@ -1,5 +1,5 @@ /* - * Copyright 2009-2019 Max Kellermann + * Copyright 2009-2022 Max Kellermann * http://www.musicpd.org * * Redistribution and use in source and binary forms, with or without @@ -28,16 +28,14 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef NUMBER_PARSER_HXX -#define NUMBER_PARSER_HXX +#pragma once #include #include +#include #include -struct StringView; - static inline unsigned ParseUnsigned(const char *p, char **endptr=nullptr, int base=10) noexcept { @@ -71,7 +69,7 @@ ParseInt64(const char *p, char **endptr=nullptr, int base=10) noexcept } int64_t -ParseInt64(StringView s, const char **endptr_r=nullptr, int base=10) noexcept; +ParseInt64(std::string_view s, const char **endptr_r=nullptr, int base=10) noexcept; static inline double ParseDouble(const char *p, char **endptr=nullptr) noexcept @@ -91,5 +89,3 @@ ParseFloat(const char *p, char **endptr=nullptr) noexcept return strtof(p, endptr); #endif } - -#endif