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

📄 guid.hpp

📁 新版本TR1的stl
💻 HPP
📖 第 1 页 / 共 2 页
字号:
/* /////////////////////////////////////////////////////////////////////////
 * File:        comstl/util/guid.hpp (originally MOGuidGn.h/.cpp, ::SynesisCom)
 *
 * Purpose:     guid class.
 *
 * Created:     10th May 2000
 * Updated:     7th April 2007
 *
 * Home:        http://stlsoft.org/
 *
 * Copyright (c) 2000-2007, Matthew Wilson and Synesis Software
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * - Redistributions of source code must retain the above copyright notice, this
 *   list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright notice,
 *   this list of conditions and the following disclaimer in the documentation
 *   and/or other materials provided with the distribution.
 * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
 *   any contributors may be used to endorse or promote products derived from
 *   this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 * ////////////////////////////////////////////////////////////////////// */


/** \file comstl/util/guid.hpp
 *
 * \brief [C++ only; requires COM] Definition of the comstl::guid class
 *   (\ref group__library__utility__com "COM Utility" Library).
 */

#ifndef COMSTL_INCL_COMSTL_UTIL_HPP_COMSTL_GUID
#define COMSTL_INCL_COMSTL_UTIL_HPP_COMSTL_GUID

#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
# define _COMSTL_VER_COMSTL_UTIL_HPP_COMSTL_GUID_MAJOR      4
# define _COMSTL_VER_COMSTL_UTIL_HPP_COMSTL_GUID_MINOR      3
# define _COMSTL_VER_COMSTL_UTIL_HPP_COMSTL_GUID_REVISION   1
# define _COMSTL_VER_COMSTL_UTIL_HPP_COMSTL_GUID_EDIT       44
#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */

/* /////////////////////////////////////////////////////////////////////////
 * Includes
 */

#ifndef COMSTL_INCL_COMSTL_H_COMSTL
# include <comstl/comstl.h>
#endif /* !COMSTL_INCL_COMSTL_H_COMSTL */
#ifndef COMSTL_INCL_COMSTL_SHIMS_ACCESS_HPP_STRING
# include <comstl/shims/access/string.hpp>
#endif /* !COMSTL_INCL_COMSTL_SHIMS_ACCESS_HPP_STRING */
#ifdef STLSOFT_CF_EXCEPTION_SUPPORT
# ifndef COMSTL_INCL_COMSTL_ERROR_HPP_EXCEPTIONS
#  include <comstl/error/exceptions.hpp>
# endif /* !COMSTL_INCL_COMSTL_ERROR_HPP_EXCEPTIONS */
#endif /* !STLSOFT_CF_EXCEPTION_SUPPORT */

/* /////////////////////////////////////////////////////////////////////////
 * Namespace
 */

#ifndef _COMSTL_NO_NAMESPACE
# if defined(_STLSOFT_NO_NAMESPACE) || \
     defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
/* There is no stlsoft namespace, so must define ::comstl */
namespace comstl
{
# else
/* Define stlsoft::comstl_project */

namespace stlsoft
{

namespace comstl_project
{

# endif /* _STLSOFT_NO_NAMESPACE */
#endif /* !_COMSTL_NO_NAMESPACE */

/* /////////////////////////////////////////////////////////////////////////
 * Classes
 */

/** \brief Facade for the COM GUID type
 *
 * \ingroup group__library__utility__com
 */
class guid
{
/// \name Types
/// @{
public:
    typedef guid            class_type;

    typedef GUID const&     resource_type;
/// @}

/// \name Construction
/// @{
public:
    /// \brief Constructs with a new, unique, GUID value
    ///
    /// \note If a new value cannot be aquired, then an instance of
    ///   com_exception is thrown if compiled under conditions where exceptions
    ///   are supported (STLSOFT_CF_EXCEPTION_SUPPORT is defined), or the
    ///   instance GUID is set to GUID_NULL otherwise.
    guid();
    /// \brief Constructs with a GUID value equivalent to the given ANSI string
    ///
    /// \param s The string form of the desired GUID
    ///
    /// Example: \code
    ///  guid  g("{00000303-0000-0000-C000-000000000046}");
    /// \endcode
    ///
    /// \note If a new value cannot be determined, then an instance of
    ///   com_exception is thrown if compiled under conditions where exceptions
    ///   are supported (STLSOFT_CF_EXCEPTION_SUPPORT is defined), or the
    ///   instance GUID is set to GUID_NULL otherwise.
    ss_explicit_k guid(cs_char_a_t const* s);
    /// \brief Constructs with a GUID value equivalent to the given Unicode string
    ///
    /// \param s The string form of the desired GUID
    ///
    /// Example: \code
    ///  guid  g(L"{00000303-0000-0000-C000-000000000046}");
    /// \endcode
    ///
    /// \note If a new value cannot be determined, then an instance of
    ///   com_exception is thrown if compiled under conditions where exceptions
    ///   are supported (STLSOFT_CF_EXCEPTION_SUPPORT is defined), or the
    ///   instance GUID is set to GUID_NULL otherwise.
    ss_explicit_k guid(cs_char_w_t const* s);
    /// \brief Copy constructs from the given GUID
    ss_explicit_k guid(GUID const& g);
    /// \brief Copy constructor
    guid(class_type const& rhs);

    /// \brief Copies the given instance
    guid& operator =(class_type const& rhs);
    /// \brief Assigns to a GUID value equivalent to the given string
    ///
    /// \param s The string form of the desired GUID
    ///
    /// Example: \code
    ///  guid  g;
    ///
    ///  g = "{00000303-0000-0000-C000-000000000046}";
    /// \endcode
    ///
    /// \note If a new value cannot be determined, then an instance of
    ///   com_exception is thrown if compiled under conditions where exceptions
    ///   are supported (STLSOFT_CF_EXCEPTION_SUPPORT is defined), or the
    ///   instance GUID is set to GUID_NULL otherwise.
    guid& operator =(cs_char_a_t const* s);
    /// \brief Assigns to a GUID value equivalent to the given string
    ///
    /// \param s The string form of the desired GUID
    ///
    /// Example: \code
    ///  guid  g;
    ///
    ///  g = L"{00000303-0000-0000-C000-000000000046}";
    /// \endcode
    ///
    /// \note If a new value cannot be determined, then an instance of
    ///   com_exception is thrown if compiled under conditions where exceptions
    ///   are supported (STLSOFT_CF_EXCEPTION_SUPPORT is defined), or the
    ///   instance GUID is set to GUID_NULL otherwise.
    guid& operator =(cs_char_w_t const* s);
    /// \brief Copies the given GUID value
    guid& operator =(GUID const& g);
/// @}

/// \name Accessors
/// @{
public:
    GUID const& get() const;
/// @}

/// \name Comparison
/// @{
public:
    /// \brief Evaluates whether the value is equivalent to the given argument
    cs_bool_t equal(class_type const& rhs) const;
    /// \brief Evaluates whether the value is equivalent to the given argument
    cs_bool_t equal(GUID const& rhs) const;
/// @}

/// \name Operations
/// @{
public:
    /// \brief Swaps the contents with the given instance
    void swap(class_type& rhs) stlsoft_throw_0();
/// @}

/// \name Members
/// @{
private:
    GUID    m_guid;
/// @}
};

/* /////////////////////////////////////////////////////////////////////////
 * String access shims
 */

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

#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION

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

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

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

#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */

/** \brief \ref group__concept__shim__string_access__c_str_len for comstl::guid
 *
 * \ingroup group__concept__shim__string_access
 */
inline cs_size_t c_str_len(comstl_ns_qual(guid) const& g)
{
    return stlsoft_ns_qual(c_str_len)(g.get());
}

#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION

inline cs_size_t c_str_len_a(comstl_ns_qual(guid) const& g)
{
    return stlsoft_ns_qual(c_str_len_a)(g.get());
}

inline cs_size_t c_str_len_w(comstl_ns_qual(guid) const& g)
{
    return stlsoft_ns_qual(c_str_len_w)(g.get());
}

inline cs_size_t c_str_len_o(comstl_ns_qual(guid) const& g)
{
    return stlsoft_ns_qual(c_str_len_o)(g.get());
}

#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */

/** \brief \ref group__concept__shim__string_access__c_str_ptr for comstl::guid
 *
 * \ingroup group__concept__shim__string_access
 */
inline c_str_ptr_GUID_proxy<TCHAR> c_str_ptr(comstl_ns_qual(guid) const& g)

⌨️ 快捷键说明

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