📄 basic_string.hpp
字号:
{
return s.length();
}
# endif /* compiler */
/** \brief \ref group__concept__shim__string_access__c_str_len function
* for specialisations of <code>std::basic_string</code> with
* <code>char</code>.
*
* \ingroup group__concept__shim__string_access
*
* \return Length (in bytes) of the string <code>s</code>.
*/
template< ss_typename_param_k T
, ss_typename_param_k A
>
inline ss_size_t c_str_len_a(stlsoft_ns_qual_std(basic_string)<ss_char_a_t, T, A> const& s)
{
return s.length();
}
/** \brief \ref group__concept__shim__string_access__c_str_len function
* for specialisations of <code>std::basic_string</code> with
* <code>wchar_t</code>.
*
* \ingroup group__concept__shim__string_access
*
* \return Length (in characters) of the string <code>s</code>.
*/
template< ss_typename_param_k T
, ss_typename_param_k A
>
inline ss_size_t c_str_len_w(stlsoft_ns_qual_std(basic_string)<ss_char_w_t, T, A> const& s)
{
return s.length();
}
/** \brief \ref group__concept__shim__string_access__c_str_len function
* for arbitrary specialisations of <code>std::basic_string</code>.
*
* \ingroup group__concept__shim__string_access
*
* \return Length of the string <code>s</code>.
*/
template< ss_typename_param_k C
, ss_typename_param_k T
, ss_typename_param_k A
>
inline ss_size_t c_str_len(stlsoft_ns_qual_std(basic_string)<C, T, A> const& s)
{
return s.length();
}
# endif /* STLSOFT_COMPILER_IS_MSVC && _MSC_VER < 1100 */
#endif /* STLSOFT_STRING_ACCESS_NO_STD_STRING */
/* stlport::basic_string */
#if defined(_STLP_USE_NAMESPACES) && \
defined(_STLP_USE_OWN_NAMESPACE) && \
!defined(_STLP_REDEFINE_STD) && \
( !defined(_STLPORT_MAJOR) || \
_STLPORT_MAJOR < 5)
inline ss_size_t c_str_len_a(stlport::string const& s)
{
return s.length();
}
inline ss_size_t c_str_len_w(stlport::wstring const& s)
{
return s.length();
}
template <ss_typename_param_k C>
inline ss_size_t c_str_len(stlport::basic_string<C> const& s)
{
return s.length();
}
#endif /* _STLP_USE_NAMESPACES && _STLP_USE_OWN_NAMESPACE */
/* /////////////////////////////////////////////////////////////////////////
* c_str_ptr
*
* This can be applied to an expression, and the return value is either a
* pointer to the character string or to an empty string.
*/
/* std::basic_string */
#ifndef STLSOFT_STRING_ACCESS_NO_STD_STRING
# if defined(STLSOFT_COMPILER_IS_MSVC) && \
_MSC_VER < 1100
inline ss_char_a_t const* c_str_ptr_a(string const& s)
{
return s.c_str();
}
inline ss_char_a_t const* c_str_ptr(string const& s)
{
return c_str_ptr_a(s);
}
inline ss_char_w_t const* c_str_ptr_w(wstring const& s)
{
return s.c_str();
}
inline ss_char_w_t const* c_str_ptr(wstring const& s)
{
return c_str_ptr_w(s);
}
# else /* ? compiler */
/** \brief \ref group__concept__shim__string_access__c_str_ptr function
* for <code>std::string</code>.
*
* \ingroup group__concept__shim__string_access
*
* \return None-NULL, non-mutating pointer to a nul-terminated C-style
* string of <code>char</code>.
*/
inline ss_char_a_t const* c_str_ptr_a(stlsoft_ns_qual_std(string) const& s)
{
return s.c_str();
}
# if !defined(STLSOFT_COMPILER_IS_GCC) || \
!(__GNUC__ < 3)
/** \brief \ref group__concept__shim__string_access__c_str_ptr function
* for <code>std::wstring</code>.
*
* \ingroup group__concept__shim__string_access
*
* \return None-NULL, non-mutating pointer to a nul-terminated C-style
* string of <code>wchar_t</code>.
*/
inline ss_char_w_t const* c_str_ptr_w(_stlsoft_wstring_t const& s)
{
return s.c_str();
}
# endif /* compiler */
/** \brief \ref group__concept__shim__string_access__c_str_ptr function
* for specialisations of <code>std::basic_string</code> with
* <code>char</code>.
*
* \ingroup group__concept__shim__string_access
*
* \return None-NULL, non-mutating pointer to a nul-terminated C-style
* string of <code>char</code>.
*/
template< ss_typename_param_k T
, ss_typename_param_k A
>
inline ss_char_a_t const* c_str_ptr_a(stlsoft_ns_qual_std(basic_string)<ss_char_a_t, T, A> const& s)
{
return s.c_str();
}
/** \brief \ref group__concept__shim__string_access__c_str_ptr function
* for specialisations of <code>std::basic_string</code> with
* <code>wchar_t</code>.
*
* \ingroup group__concept__shim__string_access
*
* \return None-NULL, non-mutating pointer to a nul-terminated C-style
* string of <code>wchar_t</code>.
*/
template< ss_typename_param_k T
, ss_typename_param_k A
>
inline ss_char_w_t const* c_str_ptr_w(stlsoft_ns_qual_std(basic_string)<ss_char_w_t, T, A> const& s)
{
return s.c_str();
}
/** \brief \ref group__concept__shim__string_access__c_str_ptr function
* for arbitrary specialisations of <code>std::basic_string</code>.
*
* \ingroup group__concept__shim__string_access
*
* \return None-NULL, non-mutating pointer to a nul-terminated C-style
* string.
*/
template< ss_typename_param_k C
, ss_typename_param_k T
, ss_typename_param_k A
>
inline C const* c_str_ptr(stlsoft_ns_qual_std(basic_string)<C, T, A> const& s)
{
return s.c_str();
}
# endif /* STLSOFT_COMPILER_IS_MSVC && _MSC_VER < 1100 */
#endif /* STLSOFT_STRING_ACCESS_NO_STD_STRING */
/* stlport::basic_string */
#if defined(_STLP_USE_NAMESPACES) && \
defined(_STLP_USE_OWN_NAMESPACE) && \
!defined(_STLP_REDEFINE_STD) && \
( !defined(_STLPORT_MAJOR) || \
_STLPORT_MAJOR < 5)
inline ss_char_a_t const* c_str_ptr_a(stlport::string const& s)
{
return s.c_str();
}
inline ss_char_w_t const* c_str_ptr_w(stlport::wstring const& s)
{
return s.c_str();
}
template <ss_typename_param_k C>
inline C const* c_str_ptr(stlport::basic_string<C> const& s)
{
return s.c_str();
}
#endif /* _STLP_USE_NAMESPACES && _STLP_USE_OWN_NAMESPACE */
/* /////////////////////////////////////////////////////////////////////////
* c_str_ptr_null
*
* This can be applied to an expression, and the return value is either a
* pointer to the character string or NULL.
*/
/* std::basic_string */
#ifndef STLSOFT_STRING_ACCESS_NO_STD_STRING
# if defined(STLSOFT_COMPILER_IS_MSVC) && \
_MSC_VER < 1100
inline ss_char_a_t const* c_str_ptr_null_a(string const& s)
{
return (0 == s.length()) ? 0 : s.c_str();
}
inline ss_char_a_t const* c_str_ptr_null(string const& s)
{
return c_str_ptr_null_a(s);
}
inline ss_char_w_t const* c_str_ptr_null_w(wstring const& s)
{
return (0 == s.length()) ? 0 : s.c_str();
}
inline ss_char_w_t const* c_str_ptr_null(wstring const& s)
{
return c_str_ptr_null_w(s);
}
# else /* ? compiler */
/** \brief \ref group__concept__shim__string_access__c_str_ptr_null function
* for <code>std::string</code>.
*
* \ingroup group__concept__shim__string_access
*
* \return Possibly NULL, non-mutating pointer to a nul-terminated C-style
* string of <code>char</code>.
*/
inline ss_char_a_t const* c_str_ptr_null_a(stlsoft_ns_qual_std(string) const& s)
{
return (0 == s.length()) ? 0 : s.c_str();
}
# if !defined(STLSOFT_COMPILER_IS_GCC) || \
!(__GNUC__ < 3)
/** \brief \ref group__concept__shim__string_access__c_str_ptr_null function
* for <code>std::wstring</code>.
*
* \ingroup group__concept__shim__string_access
*
* \return Possibly NULL, non-mutating pointer to a nul-terminated C-style
* string of <code>wchar_t</code>.
*/
inline ss_char_w_t const* c_str_ptr_null_w(_stlsoft_wstring_t const& s)
{
return (0 == s.length()) ? 0 : s.c_str();
}
# endif /* compiler */
/** \brief \ref group__concept__shim__string_access__c_str_ptr_null function
* for specialisations of <code>std::basic_string</code> with
* <code>char</code>.
*
* \ingroup group__concept__shim__string_access
*
* \return Possibly NULL, non-mutating pointer to a nul-terminated C-style
* string of <code>char</code>.
*/
template< ss_typename_param_k T
, ss_typename_param_k A
>
inline ss_char_a_t const* c_str_ptr_null_a(stlsoft_ns_qual_std(basic_string)<ss_char_a_t, T, A> const& s)
{
return (0 == s.length()) ? 0 : s.c_str();
}
/** \brief \ref group__concept__shim__string_access__c_str_ptr_null function
* for specialisations of <code>std::basic_string</code> with
* <code>wchar_t</code>.
*
* \ingroup group__concept__shim__string_access
*
* \return Possibly NULL, non-mutating pointer to a nul-terminated C-style
* string of <code>wchar_t</code>.
*/
template< ss_typename_param_k T
, ss_typename_param_k A
>
inline ss_char_w_t const* c_str_ptr_null_w(stlsoft_ns_qual_std(basic_string)<ss_char_w_t, T, A> const& s)
{
return (0 == s.length()) ? 0 : s.c_str();
}
/** \brief \ref group__concept__shim__string_access__c_str_ptr_null function
* for arbitrary specialisations of <code>std::basic_string</code>.
*
* \ingroup group__concept__shim__string_access
*
* \return Possibly NULL, non-mutating pointer to a nul-terminated C-style
* string.
*/
template< ss_typename_param_k C
, ss_typename_param_k T
, ss_typename_param_k A
>
inline C const* c_str_ptr_null(stlsoft_ns_qual_std(basic_string)<C, T, A> const& s)
{
return (0 == s.length()) ? 0 : s.c_str();
}
# endif /* STLSOFT_COMPILER_IS_MSVC && _MSC_VER < 1100 */
#endif /* STLSOFT_STRING_ACCESS_NO_STD_STRING */
/* stlport::basic_string */
#if defined(_STLP_USE_NAMESPACES) && \
defined(_STLP_USE_OWN_NAMESPACE) && \
!defined(_STLP_REDEFINE_STD) && \
( !defined(_STLPORT_MAJOR) || \
_STLPORT_MAJOR < 5)
inline ss_char_a_t const* c_str_ptr_null_a(stlport::string const& s)
{
return (0 == s.length()) ? 0 : s.c_str();
}
inline ss_char_w_t const* c_str_ptr_null_w(stlport::wstring const& s)
{
return (0 == s.length()) ? 0 : s.c_str();
}
template <ss_typename_param_k C>
inline C const* c_str_ptr_null(stlport::basic_string<C> const& s)
{
return (0 == s.length()) ? 0 : s.c_str();
}
#endif /* _STLP_USE_NAMESPACES && _STLP_USE_OWN_NAMESPACE */
#if 0
/** \brief Function template that provide generic implementations of
* c_str_ptr_null_a for any type for which c_str_ptr_a is defined.
*
* \ingroup group__concept__shim__string_access
*
*/
template <ss_typename_param_k S>
inline ss_char_a_t const* c_str_ptr_null_a(S const& s)
{
return stlsoft_ns_qual(c_str_ptr_null_a)(static_cast<ss_char_a_t const*>(stlsoft_ns_qual(c_str_ptr_a)(s))));
}
/** \brief Function template that provide generic implementations of
* c_str_ptr_null_w for any type for which c_str_ptr_w is defined.
*
* \ingroup group__concept__shim__string_access
*
*/
template <ss_typename_param_k S>
inline ss_char_w_t const* c_str_ptr_null_w(S const& s)
{
return stlsoft_ns_qual(c_str_ptr_null_w)(static_cast<ss_char_w_t const*>(stlsoft_ns_qual(c_str_ptr_w)(s))));
}
#endif /* 0 */
////////////////////////////////////////////////////////////////////////////
// Unit-testing
#ifdef STLSOFT_UNITTEST
# include "./unittest/basic_string_unittest_.h"
#endif /* STLSOFT_UNITTEST */
/* ////////////////////////////////////////////////////////////////////// */
#ifndef _STLSOFT_NO_NAMESPACE
} // namespace stlsoft
#endif /* _STLSOFT_NO_NAMESPACE */
/* ////////////////////////////////////////////////////////////////////// */
#endif /* !STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_STRING_STD_HPP_BASIC_STRING */
/* ////////////////////////////////////////////////////////////////////// */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -