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

📄 ccombstr_veneer.hpp

📁 新版本TR1的stl
💻 HPP
📖 第 1 页 / 共 2 页
字号:
inline as_bool_t operator !=(LPCWSTR lhs, ccombstr_veneer const& rhs)
{
    return !operator ==(lhs, rhs);
}

inline as_bool_t operator !=(ccombstr_veneer const& lhs, LPCWSTR rhs)
{
    return !operator ==(lhs, rhs);
}

/* /////////////////////////////////////////////////////////////////////////
 * swapping
 */

inline void swap(ccombstr_veneer& lhs, ccombstr_veneer& rhs)
{
    lhs.swap(rhs);
}

/* /////////////////////////////////////////////////////////////////////////
 * Shims
 */

/** \brief \ref group__concept__shim__string_access__c_str_data for comstl::ccombstr_veneer
 *
 * \ingroup group__concept__shim__string_access
 */
inline LPCOLESTR c_str_data(atlstl_ns_qual(ccombstr_veneer) const& str)
{
    return str.data();
}

#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
inline LPCOLESTR c_str_data_w(atlstl_ns_qual(ccombstr_veneer) const& str)       { return c_str_data(str); }
#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */


/** \brief \ref group__concept__shim__string_access__c_str_len for comstl::ccombstr_veneer
 *
 * \ingroup group__concept__shim__string_access
 */
inline as_size_t c_str_len(atlstl_ns_qual(ccombstr_veneer) const& str)
{
    return str.length();
}

#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
inline as_size_t c_str_len_w(atlstl_ns_qual(ccombstr_veneer) const& str)        { return c_str_len(str); }
#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */


/** \brief \ref group__concept__shim__string_access__c_str_ptr for comstl::ccombstr_veneer
 *
 * \ingroup group__concept__shim__string_access
 */
inline LPCOLESTR c_str_ptr(atlstl_ns_qual(ccombstr_veneer) const& str)
{
    return str.c_str();
}

#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
inline LPCOLESTR c_str_ptr_w(atlstl_ns_qual(ccombstr_veneer) const& str)        { return c_str_ptr(str); }
#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */


/** \brief \ref group__concept__shim__string_access__c_str_ptr_null for comstl::ccombstr_veneer
 *
 * \ingroup group__concept__shim__string_access
 */
inline LPCOLESTR c_str_ptr_null(atlstl_ns_qual(ccombstr_veneer) const& str)
{
    return !str.empty() ? str.c_str() : NULL;
}

#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
inline LPCOLESTR c_str_ptr_null_w(atlstl_ns_qual(ccombstr_veneer) const& str)   { return c_str_ptr_null(str); }
#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */




/** \brief \ref group__concept__shim__stream_insertion "stream insertion shim" for comstl::ccombstr_veneer
 *
 * \ingroup group__concept__shim__stream_insertion
 */
template<ss_typename_param_k S>
inline S& operator <<(S& s, atlstl_ns_qual(ccombstr_veneer) const& str)
{
    s << str.c_str();

    return s;
}

/* /////////////////////////////////////////////////////////////////////////
 * Unit-testing
 */

#ifdef STLSOFT_UNITTEST
# include "./unittest/ccombstr_veneer_unittest_.h"
#endif /* STLSOFT_UNITTEST */

/* /////////////////////////////////////////////////////////////////////////
 * Implementation
 */

#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION

inline ccombstr_veneer::ccombstr_veneer()
    : parent_class_type()
{
    stlsoft_constraint_must_be_same_size(CComBSTR, class_type);
}

inline ccombstr_veneer::ccombstr_veneer(class_type const& rhs)
    : parent_class_type(rhs)
{
    stlsoft_constraint_must_be_same_size(CComBSTR, class_type);
}

inline ccombstr_veneer::ccombstr_veneer(CComBSTR const& rhs)
    : parent_class_type(rhs)
{
    stlsoft_constraint_must_be_same_size(CComBSTR, class_type);
}

inline ccombstr_veneer::ccombstr_veneer(LPCSTR s)
/* There's a bug in some implementations of ATL 3.x, so we go for the assigment,
 * doing the conversion ourselves
 */
#if _ATL_VER >= 0x0700
    : parent_class_type(s)
#endif /* _ATL_VER */
{
#if _ATL_VER < 0x0700
    USES_CONVERSION;
    *this = A2COLE(s);
#endif /* _ATL_VER */

    ATLSTL_ASSERT(s == NULL || length() == strlen(s));

    stlsoft_constraint_must_be_same_size(CComBSTR, class_type);
}

inline ccombstr_veneer::ccombstr_veneer(LPCWSTR s)
#if _ATL_VER >= 0x0300
    : parent_class_type(s)
#endif /* _ATL_VER */
{
#if _ATL_VER < 0x0300
    USES_CONVERSION;
    *this = s;
#endif /* _ATL_VER */

    ATLSTL_ASSERT(s == NULL || length() == wcslen(s));

    stlsoft_constraint_must_be_same_size(CComBSTR, class_type);
}

inline ccombstr_veneer::ccombstr_veneer(LPCOLESTR from, LPCOLESTR to)
    : parent_class_type(static_cast<int>(to - from), from)
{
    stlsoft_constraint_must_be_same_size(CComBSTR, class_type);
}

inline void ccombstr_veneer::swap(ccombstr_veneer::class_type& rhs)
{
    std_swap(m_str, rhs.m_str);
}

inline ccombstr_veneer::ccombstr_veneer(ccombstr_veneer::size_type length, LPCOLESTR from)
    : parent_class_type(static_cast<int>(length), from)
{
    stlsoft_constraint_must_be_same_size(CComBSTR, class_type);
}

inline ccombstr_veneer::ccombstr_veneer(as_size_t cch, OLECHAR ch)
{
    stlsoft_constraint_must_be_same_size(CComBSTR, class_type);

    typedef stlsoft_ns_qual(auto_buffer)<OLECHAR>   buffer_t;

    buffer_t    buffer(cch);

    _wcsnset(&buffer[0], ch, cch);

    class_type(cch, buffer.data()).swap(*this);
}

inline ccombstr_veneer::class_type const& ccombstr_veneer::operator =(ccombstr_veneer::class_type const& rhs)
{
    parent_class_type::operator =(rhs);

    return *this;
}

inline ccombstr_veneer::class_type const& ccombstr_veneer::operator =(CComBSTR const& rhs)
{
    parent_class_type::operator =(rhs);

    return *this;
}

inline ccombstr_veneer::class_type const& ccombstr_veneer::operator =(LPCSTR s)
{
/* There's a bug in some implementations of ATL 3.x, so we go for the assigment,
 * doing the conversion ourselves
 */
#if _ATL_VER >= 0x0700
    parent_class_type::operator =(s);
#else /* ? _ATL_VER */
    USES_CONVERSION;
    *this = A2COLE(s);
#endif /* _ATL_VER */

    return *this;
}

inline ccombstr_veneer::class_type const& ccombstr_veneer::operator =(LPCWSTR s)
{
    parent_class_type::operator =(s);

    return *this;
}

inline ccombstr_veneer::const_iterator ccombstr_veneer::begin() const
{
    return *this;
}

inline ccombstr_veneer::const_iterator ccombstr_veneer::end() const
{
    return begin() + Length();
}

#if defined(STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT)
inline ccombstr_veneer::const_reverse_iterator ccombstr_veneer::rbegin() const
{
    return const_reverse_iterator(end());
}

inline ccombstr_veneer::const_reverse_iterator ccombstr_veneer::rend() const
{
    return const_reverse_iterator(begin());
}
#endif /* STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT */

inline ccombstr_veneer::reference ccombstr_veneer::operator [](ccombstr_veneer::size_type index)
{
    ATLSTL_MESSAGE_ASSERT("Index out of range", index < length());

    return const_cast<reference>(data()[index]);
}

inline ccombstr_veneer::const_reference ccombstr_veneer::operator [](ccombstr_veneer::size_type index) const
{
    ATLSTL_MESSAGE_ASSERT("Index out of range", index < length());

    return data()[index];
}

inline CComBSTR &ccombstr_veneer::get_base_type()
{
#if defined(STLSOFT_COMPILER_IS_DMC)
    CComBSTR    *this_  =   stlsoft_ns_qual(sap_cast)<CComBSTR*>(this);
#else /* ? compiler */
    CComBSTR    *this_  =   this;
#endif /* compiler */

    return *this_;
}

inline CComBSTR const& ccombstr_veneer::get_base_type() const
{
#if defined(STLSOFT_COMPILER_IS_DMC)
    CComBSTR const  *this_  =   stlsoft_ns_qual(sap_cast)<CComBSTR const*>(this);
#else /* ? compiler */
    CComBSTR const  *this_  =   this;
#endif /* compiler */

    return *this_;
}

inline ccombstr_veneer::size_type ccombstr_veneer::length() const
{
    return Length();
}

inline ccombstr_veneer::size_type ccombstr_veneer::size() const
{
    return length();
}

inline as_bool_t ccombstr_veneer::empty() const
{
    return length() == 0;
}

inline ccombstr_veneer::const_pointer ccombstr_veneer::c_str() const
{
    return empty() ? L"" : static_cast<const_pointer>(*this);
}

inline ccombstr_veneer::const_pointer ccombstr_veneer::data() const
{
    return empty() ? L"" : static_cast<const_pointer>(*this);
}

#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */

/* ////////////////////////////////////////////////////////////////////// */

#ifndef _ATLSTL_NO_NAMESPACE
# if defined(_STLSOFT_NO_NAMESPACE) || \
     defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
} // namespace atlstl
# else
} // namespace atlstl_project
} // namespace stlsoft
# endif /* _STLSOFT_NO_NAMESPACE */
#endif /* !_ATLSTL_NO_NAMESPACE */

#if defined(STLSOFT_CF_std_NAMESPACE)
namespace stlsoft
{
    inline void swap(atlstl_ns_qual(ccombstr_veneer)& lhs, atlstl_ns_qual(ccombstr_veneer)& rhs)
    {
        lhs.swap(rhs);
    }
} // namespace stlsoft
#endif /* STLSOFT_CF_std_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_data;
using ::atlstl::c_str_data_w;

using ::atlstl::c_str_len;
using ::atlstl::c_str_len_w;

using ::atlstl::c_str_ptr;
using ::atlstl::c_str_ptr_w;

using ::atlstl::c_str_ptr_null;
using ::atlstl::c_str_ptr_null_w;

/* /////////////////////////////////////////////////////////////////////////
 * Traits
 */

STLSOFT_TEMPLATE_SPECIALISATION
struct string_traits< ::atlstl::ccombstr_veneer>
{
    typedef ::atlstl::ccombstr_veneer                       value_type;
    typedef ::atlstl::ccombstr_veneer::value_type           char_type;  // NOTE: Can't use value_type::value_type here, because of BC++ 5.5.1
    typedef value_type::size_type                           size_type;
    typedef char_type const                                 const_char_type;
    typedef value_type                                      string_type;
    typedef string_type::pointer                            pointer;
    typedef string_type::const_pointer                      const_pointer;
    typedef string_type::iterator                           iterator;
    typedef string_type::const_iterator                     const_iterator;
#if defined(STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT)
//    typedef string_type::reverse_iterator                   reverse_iterator;
    typedef string_type::const_reverse_iterator             const_reverse_iterator;
#endif /* STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT */
    enum
    {
            is_pointer          =   false
        ,   is_pointer_to_const =   false
        ,   char_type_size      =   sizeof(char_type)
    };

    static string_type empty_string()
    {
        return string_type();
    }
    static string_type construct(string_type const& src, size_type pos, size_type len)
    {
        return string_type(len, src.data() + pos);
    }
# ifdef STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
    template <ss_typename_param_k I>
    static string_type &assign_inplace(string_type &str, I first, I last)
# else /* ? STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT */
    static string_type &assign_inplace(string_type &str, const_iterator first, const_iterator last)
# endif /* STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT */
    {
        // comstl::bstr cannot assign in-place
        return (str = string_type(last - first, first), str);
    }
};


# 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_STRING_HPP_CCOMBSTR_VENEER */

/* ////////////////////////////////////////////////////////////////////// */

⌨️ 快捷键说明

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