string_access.hpp
来自「用STL的方式封装了WindowsAPI、COM调用、ACE、ATL、MFC、W」· HPP 代码 · 共 541 行 · 第 1/2 页
HPP
541 行
inline as_bool_t operator !=(LPCTSTR lhs, c_str_ptr_null_CWindow_proxy const &rhs)
{
return lhs != static_cast<LPCTSTR>(rhs);
}
inline as_bool_t operator !=(c_str_ptr_null_CWindow_proxy const &lhs, LPCTSTR rhs)
{
return static_cast<LPCTSTR>(lhs) != rhs;
}
#endif /* __ATLWIN_H__ */
/* /////////////////////////////////////////////////////////////////////////
* IOStream compatibility
*/
#ifdef __ATLWIN_H__
template<ss_typename_param_k S>
inline S &operator <<(S & s, c_str_ptr_null_CWindow_proxy const &shim)
{
s << static_cast<LPCTSTR>(shim);
return s;
}
template <ss_typename_param_k S>
inline S &operator <<(S & s, c_str_ptr_CWindow_proxy const &shim)
{
s << static_cast<LPCTSTR>(shim);
return s;
}
#endif /* __ATLWIN_H__ */
/* /////////////////////////////////////////////////////////////////////////
* 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.
*/
/* CWindow */
#ifdef __ATLWIN_H__
/// \brief Returns the corresponding C-string pointer of the CWindow \c w, or a null pointer
inline c_str_ptr_null_CWindow_proxy c_str_ptr_null(atlstl_ns_qual_atl(CWindow) const &w)
{
return c_str_ptr_null_CWindow_proxy(w);
}
/// \brief Returns the corresponding C-string pointer of the CWindow \c w, or a null pointer
# ifdef UNICODE
inline c_str_ptr_null_CWindow_proxy c_str_ptr_null_w(atlstl_ns_qual_atl(CWindow) const &w)
# else /* ? UNICODE */
inline c_str_ptr_null_CWindow_proxy c_str_ptr_null_a(atlstl_ns_qual_atl(CWindow) const &w)
# endif /* UNICODE */
{
return c_str_ptr_null(w);
}
#endif /* __ATLWIN_H__ */
/* CComBSTR */
/// \brief Returns the corresponding C-string pointer of the CComBSTR \c s, or a null pointer
inline LPCOLESTR c_str_ptr_null(atlstl_ns_qual_atl(CComBSTR) const &s)
{
/* NULL is a valid BSTR value, so may return that */
return s.m_str;
}
inline LPCOLESTR c_str_ptr_null_w(atlstl_ns_qual_atl(CComBSTR) const &s)
{
return c_str_ptr_null(s);
}
/* /////////////////////////////////////////////////////////////////////////
* 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.
*/
/* CWindow */
#ifdef __ATLWIN_H__
/// \brief Returns the corresponding C-string pointer of the text of the CWindow \c w
inline c_str_ptr_CWindow_proxy c_str_ptr(atlstl_ns_qual_atl(CWindow) const &w)
{
return c_str_ptr_CWindow_proxy(w);
}
/// \brief Returns the corresponding C-string pointer of the CWindow \c w, or a null pointer
# ifdef UNICODE
inline c_str_ptr_CWindow_proxy c_str_ptr_w(atlstl_ns_qual_atl(CWindow) const &w)
# else /* ? UNICODE */
inline c_str_ptr_CWindow_proxy c_str_ptr_a(atlstl_ns_qual_atl(CWindow) const &w)
# endif /* UNICODE */
{
return c_str_ptr(w);
}
#endif /* __ATLWIN_H__ */
/* CComBSTR */
/// \brief Returns the corresponding C-string pointer of the CComBSTR \c s
inline LPCOLESTR c_str_ptr(atlstl_ns_qual_atl(CComBSTR) const &s)
{
/* NULL is a valid BSTR value, so check for that */
return (s.m_str != 0) ? s.m_str : L"";
}
inline LPCOLESTR c_str_ptr_w(atlstl_ns_qual_atl(CComBSTR) const &s)
{
return c_str_ptr(s);
}
/* /////////////////////////////////////////////////////////////////////////
* 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.
*/
/* CWindow */
#ifdef __ATLWIN_H__
/// \brief Returns the corresponding possibly un-terminated C-string pointer of the text of the CWindow \c w
inline c_str_ptr_CWindow_proxy c_str_data(atlstl_ns_qual_atl(CWindow) const &w)
{
return c_str_ptr(w);
}
/// \brief Returns the corresponding C-string pointer of the CWindow \c w, or a null pointer
# ifdef UNICODE
inline c_str_ptr_CWindow_proxy c_str_data_w(atlstl_ns_qual_atl(CWindow) const &w)
# else /* ? UNICODE */
inline c_str_ptr_CWindow_proxy c_str_data_a(atlstl_ns_qual_atl(CWindow) const &w)
# endif /* UNICODE */
{
return c_str_data(w);
}
#endif /* __ATLWIN_H__ */
/// \brief Returns the corresponding possibly un-terminated C-string pointer of the CComBSTR \c s
inline LPCOLESTR c_str_data(atlstl_ns_qual_atl(CComBSTR) const &s)
{
return c_str_ptr(s);
}
inline LPCOLESTR c_str_data_w(atlstl_ns_qual_atl(CComBSTR) const &s)
{
return c_str_data(s);
}
/* /////////////////////////////////////////////////////////////////////////
* 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.
*/
/* CWindow */
#ifdef __ATLWIN_H__
/// \brief Returns the length (in characters) of the contents of the window \c w, <b><i>not</i></b> including the null-terminating character
inline as_size_t c_str_len(atlstl_ns_qual_atl(CWindow) const &w)
{
return static_cast<as_size_t>(w.GetWindowTextLength());
}
#endif /* __ATLWIN_H__ */
/* CComBSTR */
/// \brief Returns the length (in characters) of the CComBSTR \c s, <b><i>not</i></b> including the null-terminating character
inline as_size_t c_str_len(atlstl_ns_qual_atl(CComBSTR) const &s)
{
return s.Length();
}
/* /////////////////////////////////////////////////////////////////////////
* c_str_size
*
* This can be applied to an expression, and the return value is the number of
* bytes required to store the character string in the expression, NOT including
* the null-terminating character.
*/
/* CWindow */
#ifdef __ATLWIN_H__
#if 0
/// \brief Returns the size (in bytes) of the contents of the window \c w, <b><i>not</i></b> including the null-terminating character
inline as_size_t c_str_size(atlstl_ns_qual_atl(CWindow) const &w)
{
return c_str_len(w) * sizeof(TCHAR);
}
#endif /* 0 */
#endif /* __ATLWIN_H__ */
/* CComBSTR */
#if 0
/// \brief Returns the size (in bytes) of the CComBSTR \c s, <b><i>not</i></b> including the null-terminating character
inline as_size_t c_str_size(atlstl_ns_qual_atl(CComBSTR) const &s)
{
return c_str_len(s) * sizeof(OLECHAR);
}
#endif /* 0 */
////////////////////////////////////////////////////////////////////////////
// Unit-testing
#ifdef STLSOFT_UNITTEST
# include "./unittest/string_access_unittest_.h"
#endif /* STLSOFT_UNITTEST */
/* ////////////////////////////////////////////////////////////////////// */
#ifndef _ATLSTL_NO_NAMESPACE
# if defined(_STLSOFT_NO_NAMESPACE) || \
defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
} // namespace atlstl
# else
} // namespace stlsoft::atlstl_project
} // namespace stlsoft
# endif /* _STLSOFT_NO_NAMESPACE */
#endif /* !_ATLSTL_NO_NAMESPACE */
/* /////////////////////////////////////////////////////////////////////////
* Namespace
*
* The string access shims exist either in the stlsoft namespace, or in the
* global namespace. This is required by the lookup rules.
*
*/
#ifndef _ATLSTL_NO_NAMESPACE
# if !defined(_STLSOFT_NO_NAMESPACE) && \
!defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
namespace stlsoft
{
# else /* ? _STLSOFT_NO_NAMESPACE */
/* There is no stlsoft namespace, so must define in the global namespace */
# endif /* !_STLSOFT_NO_NAMESPACE */
using ::atlstl::c_str_ptr_null;
#if defined(__ATLWIN_H__) && \
!defined(UNICODE)
using ::atlstl::c_str_ptr_null_a;
#endif /* __ATLWIN_H__ && !UNICODE*/
using ::atlstl::c_str_ptr_null_w;
using ::atlstl::c_str_ptr;
#if defined(__ATLWIN_H__) && \
!defined(UNICODE)
using ::atlstl::c_str_ptr_a;
#endif /* __ATLWIN_H__ && !UNICODE*/
using ::atlstl::c_str_ptr_w;
using ::atlstl::c_str_data;
#if defined(__ATLWIN_H__) && \
!defined(UNICODE)
using ::atlstl::c_str_data_a;
#endif /* __ATLWIN_H__ && !UNICODE*/
using ::atlstl::c_str_data_w;
using ::atlstl::c_str_len;
#if 0
using ::atlstl::c_str_size;
#endif /* 0 */
# if !defined(_STLSOFT_NO_NAMESPACE) && \
!defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
} // namespace stlsoft
# else /* ? _STLSOFT_NO_NAMESPACE */
/* There is no stlsoft namespace, so must define in the global namespace */
# endif /* !_STLSOFT_NO_NAMESPACE */
#endif /* !_ATLSTL_NO_NAMESPACE */
/* ////////////////////////////////////////////////////////////////////// */
#endif /* !ATLSTL_INCL_ATLSTL_HPP_STRING_ACCESS */
/* ////////////////////////////////////////////////////////////////////// */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?