diff --git a/include/stdex/string.hpp b/include/stdex/string.hpp index 7692bcceb..19ca49b26 100644 --- a/include/stdex/string.hpp +++ b/include/stdex/string.hpp @@ -20,7 +20,6 @@ #include #include #include -#include namespace stdex { @@ -282,19 +281,6 @@ namespace stdex return strnlen(str, N); } - /// - /// Calculate zero-terminated string length. - /// - /// \param[in] str String - /// - /// \return Number of code units excluding zero terminator in the string. - /// - template - inline size_t strnlen(_In_ const std::basic_string_view> str) - { - return strnlen(str.data(), str.size()); - } - constexpr auto npos{ static_cast(-1) }; /// @@ -351,22 +337,6 @@ namespace stdex return strnchr(str, N, chr); } - /// - /// Find a code unit in a string. - /// - /// \param[in] str String - /// \param[in] chr Code unit to search for - /// - /// \return Offset to the first occurence of chr code unit or stdex::npos if not found. - /// - template - inline size_t strnchr( - _In_ const std::basic_string_view> str, - _In_ T chr) - { - return strchr(str.data(), str.size(), chr); - } - /// /// Find a code unit in a string. /// @@ -425,20 +395,6 @@ namespace stdex return strrnchr(str, N, chr); } - /// - /// Find a code unit in a string. - /// - /// \param[in] str String - /// \param[in] chr Code unit to search for - /// - /// \return Offset to the first occurence of chr code unit or stdex::npos if not found. - /// - template - inline size_t strrnchr(_In_ const std::basic_string_view> str, _In_ T chr) - { - return strrnchr(str.data(), str.size(), chr); - } - /// /// Find a code unit in a string ASCII-case-insensitive /// @@ -563,40 +519,6 @@ namespace stdex return strnichr(str, N, chr, locale); } - /// - /// Find a code unit in a string ASCII-case-insensitive - /// - /// \param[in] str String - /// \param[in] chr Code unit to search for - /// - /// \return Offset to the first occurence of chr code unit or stdex::npos if not found. - /// - template - inline size_t strnichr( - _In_ const std::basic_string_view> str, - _In_ T chr) - { - return strichr(str.data(), str.size(), chr); - } - - /// - /// Find a code unit in a string case-insensitive - /// - /// \param[in] str String - /// \param[in] chr Code unit to search for - /// \param[in] locale C++ locale to use - /// - /// \return Offset to the first occurence of chr code unit or stdex::npos if not found. - /// - template - inline size_t strnichr( - _In_ const std::basic_string_view> str, - _In_ T chr, - _In_ const std::locale& locale) - { - return strichr(str.data(), str.size(), chr, locale); - } - /// /// Find a code unit in a string ASCII-case-insensitive /// @@ -725,40 +647,6 @@ namespace stdex return strrnichr(str, N, chr, locale); } - /// - /// Find a code unit in a string ASCII-case-insensitive - /// - /// \param[in] str String - /// \param[in] chr Code unit to search for - /// - /// \return Offset to the last occurence of chr code unit or stdex::npos if not found. - /// - template - inline size_t strrnichr( - _In_ const std::basic_string_view> str, - _In_ T chr) - { - return strrnichr(str.data(), str.size(), chr); - } - - /// - /// Find a code unit in a string case-insensitive - /// - /// \param[in] str String - /// \param[in] chr Code unit to search for - /// \param[in] locale C++ locale to use - /// - /// \return Offset to the last occurence of chr code unit or stdex::npos if not found. - /// - template - inline size_t strrnichr( - _In_ const std::basic_string_view> str, - _In_ T chr, - _In_ const std::locale& locale) - { - return strrnichr(str.data(), str.size(), chr, locale); - } - ///// ///// Checks if string contains all ASCII-white-space ///// @@ -869,36 +757,6 @@ namespace stdex return isblank(str, N, locale); } - /// - /// Checks if string contains all ASCII-white-space - /// - /// \param[in] str String - /// - /// \return `true` if all characters are white-space or `false` when any non-white-space character is found in string. - /// - template - inline bool isblank(_In_ const std::basic_string_view> str) - { - return isblank(str.data(), str.size()); - } - - /// - /// Checks if string contains all white-space - /// - /// \param[in] str String - /// \param[in] locale C++ locale to use - /// - /// \return `true` if all characters are white-space or `false` when any non-white-space character is found in string. - /// - template - inline bool isblank( - _In_ const std::basic_string_view> str, - _In_ size_t count, - _In_ const std::locale& locale) - { - return isblank(str.data(), str.size(), locale); - } - /// /// Binary compare two strings /// @@ -989,22 +847,6 @@ namespace stdex return strncmp(str1, N1, str2, N2); } - /// - /// Binary compare two strings - /// - /// \param[in] str1 String 1 - /// \param[in] str2 String 2 - /// - /// \return Negative if str1str2; zero if str1==str2 - /// - template - inline int strncmp( - _In_ const std::basic_string_view> str1, - _In_ const std::basic_string_view> str2) - { - return strncmp(str1.data(), str1.size(), str2.data(), str2.size()); - } - /// /// Binary compare two strings ASCII-case-insensitive /// @@ -1197,40 +1039,6 @@ namespace stdex strnicmp(str1, N1, str2, N2, locale); } - /// - /// Binary compare two strings case-insensitive - /// - /// \param[in] str1 String 1 - /// \param[in] str2 String 2 - /// - /// \return Negative if str1str2; zero if str1==str2 - /// - template - inline int strnicmp( - _In_ const std::basic_string_view> str1, - _In_ const std::basic_string_view> str2) - { - return strnicmp(str1.data(), str1.size(), str2.data(), str2.size()); - } - - /// - /// Binary compare two strings ASCII-case-insensitive - /// - /// \param[in] str1 String 1 - /// \param[in] str2 String 2 - /// \param[in] locale C++ locale to use - /// - /// \return Negative if str1str2; zero if str1==str2 - /// - template - inline int strnicmp( - _In_ const std::basic_string_view> str1, - _In_ const std::basic_string_view> str2, - _In_ const std::locale& locale) - { - return strnicmp(str1.data(), str1.size(), str2.data(), str2.size(), locale); - } - /// /// Lexigraphically compare two strings /// @@ -1293,24 +1101,6 @@ namespace stdex return strncoll(str1, N1, str2, N2, locale); } - /// - /// Lexigraphically compare two strings - /// - /// \param[in] str1 String 1 - /// \param[in] str2 String 2 - /// \param[in] locale C++ locale to use - /// - /// \return Negative if str1str2; zero if str1==str2 - /// - template - inline int strncoll( - _In_ const std::basic_string_view> str1, - _In_ const std::basic_string_view> str2, - _In_ const std::locale& locale) - { - return strncoll(str1.data(), str1.size(), str2.data(), str2.size(), locale); - } - /// /// Search for a substring /// @@ -1382,22 +1172,6 @@ namespace stdex return strnstr(str, N1, sample); } - /// - /// Search for a substring - /// - /// \param[in] str String to search in - /// \param[in] sample Substring to search for - /// - /// \return Offset inside str where sample string is found; stdex::npos if not found - /// - template - inline size_t strnstr( - _In_ const std::basic_string_view> str, - _In_z_ const T2* sample) - { - return strnstr(str.data(), str.size(), sample); - } - /// /// Search for a substring ASCII-case-insensitive /// @@ -1552,40 +1326,6 @@ namespace stdex return strnistr(str, N1, sample, locale); } - /// - /// Search for a substring ASCII-case-insensitive - /// - /// \param[in] str String to search in - /// \param[in] sample Substring to search for - /// - /// \return Offset inside str where sample string is found; stdex::npos if not found - /// - template - inline size_t strnistr( - _In_ const std::basic_string_view> str, - _In_z_ const T2* sample) - { - return strnistr(str.data(), str.size(), sample); - } - - /// - /// Search for a substring case-insensitive - /// - /// \param[in] str String to search in - /// \param[in] sample Substring to search for - /// \param[in] locale C++ locale to use - /// - /// \return Offset inside str where sample string is found; stdex::npos if not found - /// - template - inline size_t strnistr( - _In_ const std::basic_string_view> str, - _In_z_ const T2* sample, - _In_ const std::locale& locale) - { - return strnistr(str.data(), str.size(), sample, locale); - } - /// /// Copy zero-terminated string /// @@ -1794,22 +1534,6 @@ namespace stdex return strndup(str, N); } - /// - /// Returns duplicated string on the heap - /// - /// In contrast with the stdlib C strdup, the memory is allocated using operator new T[]. - /// This allows returned string to be fed into std::unique_ptr for auto release. - /// - /// \param[in] str String to duplicate. Must be zero-terminated. - /// - /// \return Pointer to duplicated string; or nullptr if str is nullptr. Use delete operator to free the memory. - /// - template - inline _Check_return_ _Ret_maybenull_z_ T* strndup(_In_ const std::basic_string_view> str) - { - return strndup(str.data(), str.size()); - } - /// /// Convert CRLF to LF /// Source and destination strings may point to the same buffer for inline conversion. @@ -2057,24 +1781,6 @@ namespace stdex return strtoint(str, N, end, radix); } - /// - /// Parse string for a signed integer - /// - /// \param[in] str String - /// \param[out] end On return, count of code units processed - /// \param[in] radix Number radix (0 - autodetect; 2..36) - /// - /// \return Binary integer value - /// - template - T_bin strtoint( - _In_ const std::basic_string_view> str, - _Out_opt_ size_t* end, - _In_ int radix) - { - return strtoint(str.data(), str.size(), end, radix); - } - /// /// Parse string for an unsigned integer /// @@ -2126,24 +1832,6 @@ namespace stdex return strtouint(str, N, end, radix); } - /// - /// Parse string for an unsigned integer - /// - /// \param[in] str String - /// \param[out] end On return, count of code units processed - /// \param[in] radix Number radix (0 - autodetect; 2..36) - /// - /// \return Binary integer value - /// - template - inline T_bin strtouint( - _In_ const std::basic_string_view> str, - _Out_opt_ size_t* end, - _In_ int radix) - { - return strtouint(str.data(), str.size(), end, radix); - } - /// /// Parse string for a signed 32-bit integer /// @@ -2181,24 +1869,6 @@ namespace stdex return strto32(str, N, end, radix); } - /// - /// Parse string for a signed 32-bit integer - /// - /// \param[in] str String - /// \param[out] end On return, count of code units processed - /// \param[in] radix Number radix (0 - autodetect; 2..36) - /// - /// \return Binary integer value - /// - template - inline int32_t strto32( - _In_ const std::basic_string_view> str, - _Out_opt_ size_t* end, - _In_ int radix) - { - return strto32(str.data(), str.size(), end, radix); - } - /// /// Parse string for a signed 64-bit integer /// @@ -2236,24 +1906,6 @@ namespace stdex return strto64(str, N, end, radix); } - /// - /// Parse string for a signed 64-bit integer - /// - /// \param[in] str String - /// \param[out] end On return, count of code units processed - /// \param[in] radix Number radix (0 - autodetect; 2..36) - /// - /// \return Binary integer value - /// - template - inline int64_t strto64( - _In_ const std::basic_string_view> str, - _Out_opt_ size_t* end, - _In_ int radix) - { - return strto64(str.data(), str.size(), end, radix); - } - /// /// Parse string for a signed 32/64-bit integer /// Dependent on platform CPU architecture @@ -2297,25 +1949,6 @@ namespace stdex return strtoi(str, N, end, radix); } - /// - /// Parse string for a signed 32/64-bit integer - /// Dependent on platform CPU architecture - /// - /// \param[in] str String - /// \param[out] end On return, count of code units processed - /// \param[in] radix Number radix (0 - autodetect; 2..36) - /// - /// \return Binary integer value - /// - template - inline intptr_t strtoi( - _In_ const std::basic_string_view> str, - _Out_opt_ size_t* end, - _In_ int radix) - { - return strtoi(str.data(), str.size(), end, radix); - } - /// /// Parse string for an unsigned 32-bit integer /// @@ -2353,24 +1986,6 @@ namespace stdex return strtou32(str, N, end, radix); } - /// - /// Parse string for an unsigned 32-bit integer - /// - /// \param[in] str String - /// \param[out] end On return, count of code units processed - /// \param[in] radix Number radix (0 - autodetect; 2..36) - /// - /// \return Binary integer value - /// - template - inline uint32_t strtou32( - _In_ const std::basic_string_view> str, - _Out_opt_ size_t* end, - _In_ int radix) - { - return strtou32(str.data(), str.size(), end, radix); - } - /// /// Parse string for an unsigned 64-bit integer /// @@ -2408,24 +2023,6 @@ namespace stdex return strtou64(str, N, end, radix); } - /// - /// Parse string for an unsigned 64-bit integer - /// - /// \param[in] str String - /// \param[out] end On return, count of code units processed - /// \param[in] radix Number radix (0 - autodetect; 2..36) - /// - /// \return Binary integer value - /// - template - inline uint64_t strtou64( - _In_ const std::basic_string_view> str, - _Out_opt_ size_t* end, - _In_ int radix) - { - return strtou64(str.data(), str.size(), end, radix); - } - /// /// Parse string for an unsigned 32/64-bit integer /// Dependent on platform CPU architecture @@ -2469,25 +2066,6 @@ namespace stdex return strtoui(str, N, end, radix); } - /// - /// Parse string for an unsigned 32/64-bit integer - /// Dependent on platform CPU architecture - /// - /// \param[in] str String - /// \param[out] end On return, count of code units processed - /// \param[in] radix Number radix (0 - autodetect; 2..36) - /// - /// \return Binary integer value - /// - template - inline size_t strtoui( - _In_ const std::basic_string_view> str, - _Out_opt_ size_t* end, - _In_ int radix) - { - return strtoui(str.data(), str.size(), end, radix); - } - /// \cond internal inline int vsnprintf(_Out_z_cap_(capacity) char* str, _In_ size_t capacity, _In_z_ _Printf_format_string_params_(2) const char* format, _In_opt_ locale_t locale, _In_ va_list arg) {