⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 string_access.hpp

📁 用STL的方式封装了WindowsAPI、COM调用、ACE、ATL、MFC、WTL等多种组件
💻 HPP
📖 第 1 页 / 共 3 页
字号:
{
    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__shims__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 */

/* /////////////////////////////////////////////////////////////////////////
 * 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.
 */

/* C-style ANSI string */
/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_a_t const *c_str_ptr_a(ss_char_a_t const *s)
{
    return (NULL != s) ? s : "";
}

/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_a_t const *c_str_ptr(ss_char_a_t const *s)
{
    return c_str_ptr_a(s);
}

/* C-style Unicode string */
/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_w_t const *c_str_ptr_w(ss_char_w_t const *s)
{
    return (NULL != s) ? s : L"";
}

/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_w_t const *c_str_ptr(ss_char_w_t const *s)
{
    return c_str_ptr_w(s);
}

/* C-style ANSI string */
#ifdef _STLSOFT_STRING_ACCESS_ALLOW_NON_CONST
/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_a_t const *c_str_ptr_a(ss_char_a_t *s)
{
    return (NULL != s) ? s : "";
}

/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_a_t const *c_str_ptr(ss_char_a_t *s)
{
    return c_str_ptr_a(s);
}

/* C-style Unicode string */
/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_w_t const *c_str_ptr_w(ss_char_w_t *s)
{
    return (NULL != s) ? s : L"";
}

/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_w_t const *c_str_ptr(ss_char_w_t *s)
{
    return c_str_ptr_w(s);
}
#endif /* _STLSOFT_STRING_ACCESS_ALLOW_NON_CONST */

/* std::basic_string */
#ifndef STLSOFT_STRING_ACCESS_NO_STD_STRING
# if defined(STLSOFT_COMPILER_IS_MSVC) && \
     _MSC_VER < 1100
/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_a_t const *c_str_ptr_a(string const &s)
{
    return s.c_str();
}

/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_a_t const *c_str_ptr(string const &s)
{
    return c_str_ptr_a(s);
}

/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_w_t const *c_str_ptr_w(wstring const &s)
{
    return s.c_str();
}

/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_w_t const *c_str_ptr(wstring const &s)
{
    return c_str_ptr_w(s);
}
# else /* ? compiler */
/// \brief Returns the corresponding C-string pointer of \c s
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 Returns the corresponding C-string pointer of \c s
inline ss_char_w_t const *c_str_ptr_w(_stlsoft_wstring_t const &s)
{
    return s.c_str();
}
#  endif /* compiler */

/// \brief Returns the corresponding C-string pointer of \c s
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)
/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_a_t const *c_str_ptr_a(stlport::string const &s)
{
    return s.c_str();
}

/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_w_t const *c_str_ptr_w(stlport::wstring const &s)
{
    return s.c_str();
}

/// \brief Returns the corresponding C-string pointer of \c s
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_data
 *
 * This can be applied to an expression, and the return value is either a
 * pointer to the character string or to an empty string.
 */

/* C-style ANSI string */
/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_a_t const *c_str_data_a(ss_char_a_t const *s)
{
    return (NULL != s) ? s : "";
}

/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_a_t const *c_str_data(ss_char_a_t const *s)
{
    return c_str_data_a(s);
}

/* C-style Unicode string */
/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_w_t const *c_str_data_w(ss_char_w_t const *s)
{
    return (NULL != s) ? s : L"";
}

/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_w_t const *c_str_data(ss_char_w_t const *s)
{
    return c_str_data_w(s);
}

/* C-style ANSI string */
#ifdef _STLSOFT_STRING_ACCESS_ALLOW_NON_CONST
/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_a_t const *c_str_data_a(ss_char_a_t *s)
{
    return (NULL != s) ? s : "";
}

/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_a_t const *c_str_data(ss_char_a_t *s)
{
    return c_str_data_a(s);
}

/* C-style Unicode string */
/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_w_t const *c_str_data_w(ss_char_w_t *s)
{
    return (NULL != s) ? s : L"";
}

/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_w_t const *c_str_data(ss_char_w_t *s)
{
    return c_str_data_w(s);
}
#endif /* _STLSOFT_STRING_ACCESS_ALLOW_NON_CONST */

/* std::basic_string */
#ifndef STLSOFT_STRING_ACCESS_NO_STD_STRING
# if defined(STLSOFT_COMPILER_IS_MSVC) && \
     _MSC_VER < 1100
/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_a_t const *c_str_data_a(string const &s)
{
    return s.data();
}

/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_a_t const *c_str_data(string const &s)
{
    return c_str_data_a(s);
}

/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_w_t const *c_str_data_w(wstring const &s)
{
    return s.data();
}

/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_w_t const *c_str_data(wstring const &s)
{
    return c_str_data_w(s);
}
# else /* ? compiler */
/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_a_t const *c_str_data_a(stlsoft_ns_qual_std(string) const &s)
{
    return s.data();
}

#  if !defined(STLSOFT_COMPILER_IS_GCC) || \
      !(__GNUC__ < 3)
/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_w_t const *c_str_data_w(_stlsoft_wstring_t const &s)
{
    return s.data();
}
#  endif /* compiler */

/// \brief Returns the corresponding C-string pointer of \c s
template<   ss_typename_param_k C
        ,   ss_typename_param_k T
        ,   ss_typename_param_k A
        >
inline C const *c_str_data(stlsoft_ns_qual_std(basic_string)<C, T, A> const &s)
{
    return s.data();
}
# 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)
/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_a_t const *c_str_data_a(stlport::string const &s)
{
    return s.data();
}

/// \brief Returns the corresponding C-string pointer of \c s
inline ss_char_w_t const *c_str_data_w(stlport::wstring const &s)
{
    return s.data();
}

/// \brief Returns the corresponding C-string pointer of \c s
template <ss_typename_param_k C>
inline C const *c_str_data(stlport::basic_string<C> const &s)
{
    return s.data();
}
#endif /* _STLP_USE_NAMESPACES && _STLP_USE_OWN_NAMESPACE */

#if 0
/** \brief Function template that provide generic implementations of
 *   c_str_data_a for any type for which c_str_ptr_a is defined.
 *
 * \ingroup group__shims__string_access
 */
template <ss_typename_param_k S>
inline ss_char_a_t const *c_str_data_a(S const &s)
{
    return stlsoft_ns_qual(c_str_data_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_data_w for any type for which c_str_ptr_w is defined.
 *
 * \ingroup group__shims__string_access
 */
template <ss_typename_param_k S>
inline ss_char_w_t const *c_str_data_w(S const &s)
{
    return stlsoft_ns_qual(c_str_data_w)(static_cast<ss_char_w_t const*>(stlsoft_ns_qual(c_str_ptr_w)(s))));
}
#endif /* 0 */

/* /////////////////////////////////////////////////////////////////////////
 * c_str_len
 *
 * This can be applied to an expression, and the return value is the number of
 * characters in the character string in the expression.
 */

/* C-style ANSI string */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -