sgml: std::basic_string_view → std::basic_string
MSVC fails to deduce character type from std::string/wstring when converting to std::basic_string_view. Reference: f5bce32d06cdcf677ce8080027d3317c6387e715 Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
7e07d14de7
commit
48e35c1ebd
@ -11,7 +11,6 @@
|
||||
#include "string.hpp"
|
||||
#include <string.h>
|
||||
#include <exception>
|
||||
#include <string_view>
|
||||
#include <string>
|
||||
|
||||
#if defined(__GNUC__)
|
||||
@ -163,6 +162,22 @@ namespace stdex
|
||||
return npos;
|
||||
}
|
||||
|
||||
///
|
||||
/// Checks SGML string for error
|
||||
///
|
||||
/// \param[in] src SGML string
|
||||
/// \param[in] what Bitwise flag of stdex::sgml_* constants that force extra checks. Currently, only stdex::sgml_full is used, which enforces 7-bit/ASCII checking.
|
||||
///
|
||||
/// \return Index of error; or stdex::npos if no error detected.
|
||||
///
|
||||
template <class T_from, class TR_from = std::char_traits<T_from>, class AX_from = std::allocator<T_from>>
|
||||
size_t sgmlerr(
|
||||
_In_ const std::basic_string<T_from, TR_from, AX_from>& src,
|
||||
_In_ int what = 0)
|
||||
{
|
||||
return sgmlerr(src.data(), src.size(), what);
|
||||
}
|
||||
|
||||
///
|
||||
/// Convert SGML string to Unicode and append to string
|
||||
///
|
||||
@ -173,7 +188,7 @@ namespace stdex
|
||||
/// \param[in] offset Logical starting offset of source and destination strings. Unused when map parameter is nullptr.
|
||||
/// \param[in,out] map The vector to append index mapping between source and destination string to.
|
||||
///
|
||||
template <class T_to = wchar_t, class T_from, class TR_to = std::char_traits<T_to>, class AX_to = std::allocator<T_to>>
|
||||
template <class T_to, class T_from, class TR_to = std::char_traits<T_to>, class AX_to = std::allocator<T_to>>
|
||||
void sgml2strcat(
|
||||
_Inout_ std::basic_string<T_to, TR_to, AX_to>& dst,
|
||||
_In_reads_or_z_opt_(count_src) const T_from* src, _In_ size_t count_src,
|
||||
@ -244,7 +259,7 @@ namespace stdex
|
||||
/// \param[in] offset Logical starting offset of source and destination strings. Unused when map parameter is nullptr.
|
||||
/// \param[in,out] map The vector to append index mapping between source and destination string to.
|
||||
///
|
||||
template <class T_to = wchar_t, class T_from, class TR_to = std::char_traits<T_to>, class AX_to = std::allocator<T_to>, class TR_from = std::char_traits<T_from>, class AX_from = std::allocator<T_from>>
|
||||
template <class T_to, class T_from, class TR_to = std::char_traits<T_to>, class AX_to = std::allocator<T_to>, class TR_from = std::char_traits<T_from>, class AX_from = std::allocator<T_from>>
|
||||
void sgml2strcat(
|
||||
_Inout_ std::basic_string<T_to, TR_to, AX_to>& dst,
|
||||
_In_ const std::basic_string<T_from, TR_from, AX_from>& src,
|
||||
@ -268,7 +283,7 @@ namespace stdex
|
||||
///
|
||||
/// \return Final length of SGML string in code points excluding zero-terminator
|
||||
///
|
||||
template <class T_to = wchar_t, class T_from>
|
||||
template <class T_to, class T_from>
|
||||
size_t sgml2strcat(
|
||||
_Inout_cap_(count_dst) T_to* dst, _In_ size_t count_dst,
|
||||
_In_reads_or_z_opt_(count_src) const T_from* src, _In_ size_t count_src,
|
||||
@ -349,7 +364,7 @@ namespace stdex
|
||||
/// \param[in] offset Logical starting offset of source and destination strings. Unused when map parameter is nullptr.
|
||||
/// \param[in,out] map The vector to write index mapping between source and destination string to.
|
||||
///
|
||||
template <class T_to = wchar_t, class T_from, class TR_to = std::char_traits<T_to>, class AX_to = std::allocator<T_to>>
|
||||
template <class T_to, class T_from, class TR_to = std::char_traits<T_to>, class AX_to = std::allocator<T_to>>
|
||||
void sgml2strcpy(
|
||||
_Inout_ std::basic_string<T_to, TR_to, AX_to>& dst,
|
||||
_In_reads_or_z_opt_(count_src) const T_from* src, _In_ size_t count_src,
|
||||
@ -372,7 +387,7 @@ namespace stdex
|
||||
/// \param[in] offset Logical starting offset of source and destination strings. Unused when map parameter is nullptr.
|
||||
/// \param[in,out] map The vector to write index mapping between source and destination string to.
|
||||
///
|
||||
template<class T_to = wchar_t, class T_from, class TR_to = std::char_traits<T_to>, class AX_to = std::allocator<T_to>, class TR_from = std::char_traits<T_from>, class AX_from = std::allocator<T_from>>
|
||||
template<class T_to, class T_from, class TR_to = std::char_traits<T_to>, class AX_to = std::allocator<T_to>, class TR_from = std::char_traits<T_from>, class AX_from = std::allocator<T_from>>
|
||||
void sgml2strcpy(
|
||||
_Inout_ std::basic_string<T_to, TR_to, AX_to>& dst,
|
||||
_In_ const std::basic_string<T_from, TR_from, AX_from>& src,
|
||||
@ -396,7 +411,7 @@ namespace stdex
|
||||
///
|
||||
/// \return Final length of SGML string in code points excluding zero-terminator
|
||||
///
|
||||
template <class T_to = wchar_t, class T_from>
|
||||
template <class T_to, class T_from>
|
||||
size_t sgml2strcpy(
|
||||
_Inout_cap_(count_dst) T_to* dst, _In_ size_t count_dst,
|
||||
_In_reads_or_z_opt_(count_src) const T_from* src, _In_ size_t count_src,
|
||||
@ -546,7 +561,7 @@ namespace stdex
|
||||
/// \param[in] count_src Unicode string character count limit
|
||||
/// \param[in] what Bitwise flag of stdex::sgml_* constants that force extra characters otherwise not converted to SGML
|
||||
///
|
||||
template <class T_from = wchar_t, class TR_to = std::char_traits<char>, class AX_to = std::allocator<char>>
|
||||
template <class T_from, class TR_to = std::char_traits<char>, class AX_to = std::allocator<char>>
|
||||
void str2sgmlcat(
|
||||
_Inout_ std::basic_string<char, TR_to, AX_to>& dst,
|
||||
_In_reads_or_z_opt_(count_src) const T_from* src, _In_ size_t count_src,
|
||||
@ -638,10 +653,10 @@ namespace stdex
|
||||
/// \param[in] src Unicode string
|
||||
/// \param[in] what Bitwise flag of stdex::sgml_* constants that force extra characters otherwise not converted to SGML
|
||||
///
|
||||
template <class T_from = wchar_t, class TR_to = std::char_traits<char>, class AX_to = std::allocator<char>>
|
||||
template <class T_from, class TR_to = std::char_traits<char>, class AX_to = std::allocator<char>, class TR_from = std::char_traits<T_from>, class AX_from = std::allocator<T_from>>
|
||||
void str2sgmlcat(
|
||||
_Inout_ std::basic_string<char, TR_to, AX_to>& dst,
|
||||
_In_ const std::basic_string_view<T_from, std::char_traits<T_from>> src,
|
||||
_In_ const std::basic_string<T_from, TR_from, AX_from>& src,
|
||||
_In_ int what = 0)
|
||||
{
|
||||
str2sgmlcat(dst, src.data(), src.size(), what);
|
||||
@ -658,7 +673,7 @@ namespace stdex
|
||||
///
|
||||
/// \return Final length of SGML string in code points excluding zero-terminator
|
||||
///
|
||||
template <class T_from = wchar_t>
|
||||
template <class T_from>
|
||||
size_t str2sgmlcat(
|
||||
_Inout_cap_(count_dst) char* dst, _In_ size_t count_dst,
|
||||
_In_reads_or_z_opt_(count_src) const T_from* src, _In_ size_t count_src,
|
||||
@ -779,7 +794,7 @@ namespace stdex
|
||||
/// \param[in] count_src Unicode string character count limit
|
||||
/// \param[in] what Bitwise flag of stdex::sgml_* constants that force extra characters otherwise not converted to SGML
|
||||
///
|
||||
template <class T_from = wchar_t, class TR_to = std::char_traits<char>, class AX_to = std::allocator<char>>
|
||||
template <class T_from, class TR_to = std::char_traits<char>, class AX_to = std::allocator<char>>
|
||||
void str2sgmlcpy(
|
||||
_Inout_ std::basic_string<char, TR_to, AX_to>& dst,
|
||||
_In_reads_or_z_opt_(count_src) const T_from* src, _In_ size_t count_src,
|
||||
@ -796,10 +811,10 @@ namespace stdex
|
||||
/// \param[in] src Unicode string
|
||||
/// \param[in] what Bitwise flag of stdex::sgml_* constants that force extra characters otherwise not converted to SGML
|
||||
///
|
||||
template <class T_from = wchar_t, class TR_to = std::char_traits<char>, class AX_to = std::allocator<char>>
|
||||
template <class T_from, class TR_to = std::char_traits<char>, class AX_to = std::allocator<char>, class TR_from = std::char_traits<T_from>, class AX_from = std::allocator<T_from>>
|
||||
void str2sgmlcpy(
|
||||
_Inout_ std::basic_string<char, TR_to, AX_to>& dst,
|
||||
_In_ const std::basic_string_view<T_from, std::char_traits<T_from>> src,
|
||||
_In_ const std::basic_string<T_from, TR_from, AX_from>& src,
|
||||
_In_ int what = 0)
|
||||
{
|
||||
str2sgmlcpy(dst, src.data(), src.size(), what);
|
||||
@ -816,7 +831,7 @@ namespace stdex
|
||||
///
|
||||
/// \return Final length of SGML string in code points excluding zero-terminator
|
||||
///
|
||||
template <class T_from = wchar_t>
|
||||
template <class T_from>
|
||||
size_t str2sgmlcpy(
|
||||
_Inout_cap_(count_dst) char* dst, _In_ size_t count_dst,
|
||||
_In_reads_or_z_opt_(count_src) const T_from* src, _In_ size_t count_src,
|
||||
@ -837,7 +852,7 @@ namespace stdex
|
||||
///
|
||||
/// \return SGML string
|
||||
///
|
||||
template <class T_from = wchar_t>
|
||||
template <class T_from>
|
||||
std::string str2sgml(
|
||||
_In_reads_or_z_opt_(count_src) const T_from* src, _In_ size_t count_src,
|
||||
_In_ int what = 0)
|
||||
@ -855,9 +870,9 @@ namespace stdex
|
||||
///
|
||||
/// \return SGML string
|
||||
///
|
||||
template <class T_from = wchar_t>
|
||||
template <class T_from, class TR_from = std::char_traits<T_from>, class AX_from = std::allocator<T_from>>
|
||||
std::string str2sgml(
|
||||
_In_ const std::basic_string_view<T_from, std::char_traits<T_from>> src,
|
||||
_In_ const std::basic_string<T_from, TR_from, AX_from>& src,
|
||||
_In_ int what = 0)
|
||||
{
|
||||
return str2sgml(src.data(), src.size(), what);
|
||||
|
Loading…
x
Reference in New Issue
Block a user