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

📄 guid.hpp

📁 新版本TR1的stl
💻 HPP
📖 第 1 页 / 共 2 页
字号:
{
    return stlsoft_ns_qual(c_str_ptr)(g.get());
}

#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION

inline c_str_ptr_GUID_proxy<cs_char_a_t> c_str_ptr_a(comstl_ns_qual(guid) const& g)
{
    return stlsoft_ns_qual(c_str_ptr_a)(g.get());
}

inline c_str_ptr_GUID_proxy<cs_char_w_t> c_str_ptr_w(comstl_ns_qual(guid) const& g)
{
    return stlsoft_ns_qual(c_str_ptr_w)(g.get());
}

inline c_str_ptr_GUID_proxy<cs_char_o_t> c_str_ptr_o(comstl_ns_qual(guid) const& g)
{
    return stlsoft_ns_qual(c_str_ptr_o)(g.get());
}

#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */

/** \brief \ref group__concept__shim__string_access__c_str_ptr_null for comstl::guid
 *
 * \ingroup group__concept__shim__string_access
 */
inline c_str_ptr_GUID_proxy<TCHAR> c_str_ptr_null(comstl_ns_qual(guid) const& g)
{
    return stlsoft_ns_qual(c_str_ptr_null)(g.get());
}

#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION

inline c_str_ptr_GUID_proxy<cs_char_a_t> c_str_ptr_null_a(comstl_ns_qual(guid) const& g)
{
    return stlsoft_ns_qual(c_str_ptr_null_a)(g.get());
}

inline c_str_ptr_GUID_proxy<cs_char_w_t> c_str_ptr_null_w(comstl_ns_qual(guid) const& g)
{
    return stlsoft_ns_qual(c_str_ptr_null_w)(g.get());
}

inline c_str_ptr_GUID_proxy<cs_char_o_t> c_str_ptr_null_o(comstl_ns_qual(guid) const& g)
{
    return stlsoft_ns_qual(c_str_ptr_null_o)(g.get());
}

#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */

/* /////////////////////////////////////////////////////////////////////////
 * Operators
 */

inline cs_bool_t operator ==(guid const& lhs, guid const& rhs)
{
    return lhs.equal(rhs);
}

inline cs_bool_t operator !=(guid const& lhs, guid const& rhs)
{
    return !operator ==(lhs, rhs);
}

inline cs_bool_t operator ==(guid const& lhs, GUID const& rhs)
{
    return lhs.equal(rhs);
}

inline cs_bool_t operator !=(guid const& lhs, GUID const& rhs)
{
    return !operator ==(lhs, rhs);
}

inline cs_bool_t operator ==(GUID const& lhs, guid const& rhs)
{
    return rhs.equal(lhs);
}

inline cs_bool_t operator !=(GUID const& lhs, guid const& rhs)
{
    return !operator ==(lhs, rhs);
}

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

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

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

#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION

inline guid::guid()
{
    HRESULT hr  =   ::CoCreateGuid(&m_guid);

    if(FAILED(hr))
    {
#ifdef STLSOFT_CF_EXCEPTION_SUPPORT
        STLSOFT_THROW_X(com_exception("Could not allocate GUID", hr));
#else /* ? STLSOFT_CF_EXCEPTION_SUPPORT */
        m_guid = GUID_NULL;
#endif /* STLSOFT_CF_EXCEPTION_SUPPORT */
    }
}

inline /* ss_explicit_k */ guid::guid(cs_char_a_t const* s)
{
    OLECHAR     osz[1 + COMSTL_CCH_GUID];
    HRESULT     hr  =   S_OK;

    switch(::MultiByteToWideChar(0, 0, s, -1, &osz[0], 1 + COMSTL_CCH_GUID))
    {
        case    1 + COMSTL_CCH_GUID:
            osz[COMSTL_CCH_GUID] = L'\0';
            hr = ::CLSIDFromString(osz, &m_guid);
            break;
        default:
            if(S_OK == (hr = HRESULT_FROM_WIN32(::GetLastError())))
            {
                hr = E_INVALIDARG;
            }
            break;
    }

    if(FAILED(hr))
    {
#ifdef STLSOFT_CF_EXCEPTION_SUPPORT
        STLSOFT_THROW_X(com_exception("Could not convert string to valid GUID", hr));
#else /* ? STLSOFT_CF_EXCEPTION_SUPPORT */
        m_guid = GUID_NULL;
#endif /* STLSOFT_CF_EXCEPTION_SUPPORT */
    }
}

inline /* ss_explicit_k */ guid::guid(cs_char_w_t const* s)
{
    HRESULT hr  =   ::CLSIDFromString(const_cast<LPOLESTR>(s), &m_guid);

    if(FAILED(hr))
    {
#ifdef STLSOFT_CF_EXCEPTION_SUPPORT
        STLSOFT_THROW_X(com_exception("Could not convert string to valid GUID", hr));
#else /* ? STLSOFT_CF_EXCEPTION_SUPPORT */
        m_guid = GUID_NULL;
#endif /* STLSOFT_CF_EXCEPTION_SUPPORT */
    }
}

inline guid::guid(GUID const& g)
    : m_guid(g)
{}

inline guid::guid(guid const& rhs)
    : m_guid(rhs.m_guid)
{}

inline guid &guid::operator =(guid const& rhs)
{
    m_guid = rhs.m_guid;

    return *this;
}

inline guid &guid::operator =(cs_char_a_t const* s)
{
    guid    t(s);

    t.swap(*this);

    return *this;
}

inline guid &guid::operator =(cs_char_w_t const* s)
{
    guid    t(s);

    t.swap(*this);

    return *this;
}

inline guid &guid::operator =(GUID const& g)
{
    guid    t(g);

    t.swap(*this);

    return *this;
}

inline GUID const& guid::get() const
{
    return m_guid;
}

inline cs_bool_t guid::equal(class_type const& rhs) const
{
    return 0 != IsEqualGUID(m_guid, rhs.m_guid);
}

inline cs_bool_t guid::equal(GUID const& rhs) const
{
    return 0 != IsEqualGUID(m_guid, rhs);
}

inline void guid::swap(guid::class_type& rhs) stlsoft_throw_0()
{
    stlsoft_ns_qual(std_swap)(m_guid, rhs.m_guid);
}

#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */

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

#ifndef _COMSTL_NO_NAMESPACE
# if defined(_STLSOFT_NO_NAMESPACE) || \
     defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
} // namespace comstl
# else
} // namespace stlsoft::comstl_project
} // namespace stlsoft
# endif /* _STLSOFT_NO_NAMESPACE */
#endif /* !_COMSTL_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 _COMSTL_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 ::comstl::c_str_data;
using ::comstl::c_str_data_a;
using ::comstl::c_str_data_w;
using ::comstl::c_str_data_o;

using ::comstl::c_str_len;
using ::comstl::c_str_len_a;
using ::comstl::c_str_len_w;
using ::comstl::c_str_len_o;

using ::comstl::c_str_ptr;
using ::comstl::c_str_ptr_a;
using ::comstl::c_str_ptr_w;
using ::comstl::c_str_ptr_o;

using ::comstl::c_str_ptr_null;
using ::comstl::c_str_ptr_null_a;
using ::comstl::c_str_ptr_null_w;
using ::comstl::c_str_ptr_null_o;

# 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 /* !_COMSTL_NO_NAMESPACE */

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

#endif /* !COMSTL_INCL_COMSTL_UTIL_HPP_COMSTL_GUID */

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

⌨️ 快捷键说明

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