comstl.h

来自「用STL的方式封装了WindowsAPI、COM调用、ACE、ATL、MFC、W」· C头文件 代码 · 共 605 行 · 第 1/2 页

H
605
字号
 * COMSTL libraries irrespective of whether they are in the
 * stlsoft::comstl_project (or comstl) namespace or in the global namespace.
 *
 * Furthermore, some compilers do not support the standard library in the std
 * namespace, so the comstl_ns_qual_std() macro can be used to refer to elements
 * in the COMSTL libraries irrespective of whether they are in the std namespace
 * or in the global namespace.
 */

/* No STLSoft namespaces means no COMSTL namespaces */
#ifdef _STLSOFT_NO_NAMESPACES
# define _COMSTL_NO_NAMESPACES
#endif /* _STLSOFT_NO_NAMESPACES */

/* No COMSTL namespaces means no comstl namespace */
#ifdef _COMSTL_NO_NAMESPACES
# define _COMSTL_NO_NAMESPACE
#endif /* _COMSTL_NO_NAMESPACES */

#ifndef _COMSTL_NO_NAMESPACE
# if defined(_STLSOFT_NO_NAMESPACE) || \
     defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
/* There is no stlsoft namespace, so must define ::comstl */
/** \brief The <code class="namespace">comstl</code> namespace contains all components
 *   in the \ref group__project__comstl "COMSTL" project.
 *
 * By default, the <code>comstl</code> namespace is actually an alias for
 * the namespace <code>stlsoft::comstl_project</code>, which is where all
 * the \ref group__project__comstl "COMSTL" components actually reside. This
 * measure allows all components within the main the
 * \ref group__project__stlsoft "STLSoft" project (which are defined within
 * the <code>stlsoft</code> namespace) to be visible to all components
 * "within" the <code>comstl</code> namespace. (Otherwise, there would be a
 * whole lot of onerous qualification throughout the code of all
 * \ref group__projects "sub-projects".)
 *
 * \note If either/both of the symbols <code>_STLSOFT_NO_NAMESPACES</code>
 * and <code>_COMSTL_NO_NAMESPACE</code> are defined, all 
 * \ref group__project__comstl "COMSTL" components will be defined in the
 * global namespace. Conversely, if the <code>_STLSOFT_NO_NAMESPACE</code>
 * symbol (not to be confused with the 
 * <code>_STLSOFT_NO_NAMESPACES</code> symbol!) is defined - meaning that
 * all \ref group__project__stlsoft "main project" components are to be
 * defined in the global namespace, and <code>_COMSTL_NO_NAMESPACE</code>
 * is <b>not</b> defined, then all \ref group__project__comstl "COMSTL"
 * components will be defined within a bona fide <code>comstl</code>
 * namespace.
 *
 * \note This is a vestige of compatibility with compilers with
 * no (or no sensible) namespace support that is maintained for reasons of
 * backwards compatiblity and because it is, in <i>rare circumstances</i>, a
 * useful facility.
 */
namespace comstl
{
# else
/* Define stlsoft::comstl_project */

namespace stlsoft
{

namespace comstl_project
{

# endif /* _STLSOFT_NO_NAMESPACE */
#else
stlsoft_ns_using(move_lhs_from_rhs)
#endif /* !_COMSTL_NO_NAMESPACE */

/** \def comstl_ns_qual(x)
 * Qualifies with <b>comstl::</b> if COMSTL is using namespaces or, if not, does not qualify
 */

/** \def comstl_ns_using(x)
 * Declares a using directive (with respect to <b>comstl</b>) if COMSTL is using namespaces or, if not, does nothing
 */

#ifndef _COMSTL_NO_NAMESPACE
# define comstl_ns_qual(x)          ::comstl::x
# define comstl_ns_using(x)         using ::comstl::x;
#else /* ? _COMSTL_NO_NAMESPACE */
# define comstl_ns_qual(x)          x
# define comstl_ns_using(x)
#endif /* !_COMSTL_NO_NAMESPACE */

/** \def comstl_ns_qual_std(x)
 * Qualifies with <b>std::</b> if COMSTL is being translated in the context of the standard library being within the <b>std</b> namespace or, if not, does not qualify
 */

/** \def comstl_ns_using_std(x)
 * Declares a using directive (with respect to <b>std</b>) if COMSTL is being translated in the context of the standard library being within the <b>std</b> namespace or, if not, does nothing
 */

#ifdef STLSOFT_CF_std_NAMESPACE
# define comstl_ns_qual_std(x)      ::std::x
# define comstl_ns_using_std(x)     using ::std::x;
#else /* ? STLSOFT_CF_std_NAMESPACE */
# define comstl_ns_qual_std(x)      x
# define comstl_ns_using_std(x)
#endif /* !STLSOFT_CF_std_NAMESPACE */

/** \def COMSTL_ITF_CALL(p)
 * Resolves to <b>p->lpVtbl</b> for C compilation, and to <b>p</b> in C++
 */

#if defined(__cplusplus)
# define COMSTL_ITF_CALL(p)         (p)
#else /* ? __cplusplus */
# define COMSTL_ITF_CALL(p)         (p)->lpVtbl
#endif /* __cplusplus */

/** \def COMSTL_ITF_THIS(p)
 * Resolves to <b>p,</b> for C compilation, and to nothing in C++
 */

#if defined(__cplusplus)
# define COMSTL_ITF_THIS(p)
#else /* ? __cplusplus */
# define COMSTL_ITF_THIS(p)         (p),
#endif /* __cplusplus */

/** \def COMSTL_ITF_THIS0(p)
 * Resolves to <b>p</b> for C compilation, and to nothing in C++
 */

#if defined(__cplusplus)
# define COMSTL_ITF_THIS0(p)
#else /* ? __cplusplus */
# define COMSTL_ITF_THIS0(p)        (p)
#endif /* __cplusplus */

/** \def COMSTL_IID_2_REF(iid)
 * Resolves to <b>&iid</b> for C compilation, and to <b>iid</b> in C++
 */

#if defined(__cplusplus)
# define COMSTL_IID_2_REF(iid)        (iid)
#else /* ? __cplusplus */
# define COMSTL_IID_2_REF(iid)        (&(iid))
#endif /* __cplusplus */

/** \def COMSTL_REF_2_PTR(iid)
 * Resolves to <b>iid</b> for C compilation, and to <b>&iid</b> in C++
 */

#if defined(__cplusplus)
# define COMSTL_REF_2_PTR(iid)        (&(iid))
#else /* ? __cplusplus */
# define COMSTL_REF_2_PTR(iid)        (iid)
#endif /* __cplusplus */

/* /////////////////////////////////////////////////////////////////////////
 * Typedefs
 *
 * The COMSTL uses a number of typedefs to aid in compiler-independence in the
 * libraries' main code.
 */

#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION

typedef stlsoft_ns_qual(ss_char_a_t)        cs_char_a_t;    //!< Ansi char type
typedef stlsoft_ns_qual(ss_char_w_t)        cs_char_w_t;    //!< Unicode char type
typedef OLECHAR                             cs_char_o_t;    //!< COM char type
typedef stlsoft_ns_qual(ss_sint8_t)         cs_sint8_t;     //!< 8-bit signed integer
typedef stlsoft_ns_qual(ss_uint8_t)         cs_uint8_t;     //!< 8-bit unsigned integer
typedef stlsoft_ns_qual(ss_int16_t)         cs_int16_t;     //!< 16-bit integer
typedef stlsoft_ns_qual(ss_sint16_t)        cs_sint16_t;    //!< 16-bit signed integer
typedef stlsoft_ns_qual(ss_uint16_t)        cs_uint16_t;    //!< 16-bit unsigned integer
typedef stlsoft_ns_qual(ss_int32_t)         cs_int32_t;     //!< 32-bit integer
typedef stlsoft_ns_qual(ss_sint32_t)        cs_sint32_t;    //!< 32-bit signed integer
typedef stlsoft_ns_qual(ss_uint32_t)        cs_uint32_t;    //!< 32-bit unsigned integer
#ifdef STLSOFT_CF_64BIT_INT_SUPPORT
typedef stlsoft_ns_qual(ss_int64_t)         cs_int64_t;     //!< 64-bit integer
typedef stlsoft_ns_qual(ss_sint64_t)        cs_sint64_t;    //!< 64-bit signed integer
typedef stlsoft_ns_qual(ss_uint64_t)        cs_uint64_t;    //!< 64-bit unsigned integer
#endif /* STLSOFT_CF_64BIT_INT_SUPPORT */
typedef stlsoft_ns_qual(ss_int_t)           cs_int_t;       //!< integer
typedef stlsoft_ns_qual(ss_sint_t)          cs_sint_t;      //!< signed integer
typedef stlsoft_ns_qual(ss_uint_t)          cs_uint_t;      //!< unsigned integer
typedef stlsoft_ns_qual(ss_long_t)          cs_long_t;      //!< long
#if defined(__cplusplus)
typedef stlsoft_ns_qual(ss_bool_t)          cs_bool_t;      //!< bool
#endif /* __cplusplus */
typedef DWORD                               cs_dword_t;     //!< dword
typedef stlsoft_ns_qual(ss_size_t)          cs_size_t;      //!< size
typedef stlsoft_ns_qual(ss_ptrdiff_t)       cs_ptrdiff_t;   //!< ptr diff
typedef stlsoft_ns_qual(ss_streampos_t)     cs_streampos_t; //!< streampos
typedef stlsoft_ns_qual(ss_streamoff_t)     cs_streamoff_t; //!< streamoff

#ifndef _STLSOFT_NO_NAMESPACE
typedef cs_char_a_t         char_a_t;           /*!< Ansi char type             */
typedef cs_char_w_t         char_w_t;           /*!< Unicode char type          */
typedef cs_char_o_t         char_o_t;           /*!< COM char type              */
typedef cs_sint8_t          sint8_t;            /*!< 8-bit signed integer       */
typedef cs_uint8_t          uint8_t;            /*!< 8-bit unsigned integer     */
typedef cs_int16_t          int16_t;            /*!< 16-bit integer             */
typedef cs_sint16_t         sint16_t;           /*!< 16-bit signed integer      */
typedef cs_uint16_t         uint16_t;           /*!< 16-bit unsigned integer    */
typedef cs_int32_t          int32_t;            /*!< 32-bit integer             */
typedef cs_sint32_t         sint32_t;           /*!< 32-bit signed integer      */
typedef cs_uint32_t         uint32_t;           /*!< 32-bit unsigned integer    */
# ifdef STLSOFT_CF_64BIT_INT_SUPPORT
typedef cs_int64_t          int64_t;            /*!< 64-bit integer             */
typedef cs_sint64_t         sint64_t;           /*!< 64-bit signed integer      */
typedef cs_uint64_t         uint64_t;           /*!< 64-bit unsigned integer    */
# endif /* STLSOFT_CF_64BIT_INT_SUPPORT */
typedef cs_int_t            int_t;              /*!< integer                    */
typedef cs_sint_t           sint_t;             /*!< signed integer             */
typedef cs_uint_t           uint_t;             /*!< unsigned integer           */
typedef cs_long_t           long_t;             /*!< long integer               */
#if defined(__cplusplus)
typedef cs_bool_t           bool_t;             /*!< bool                       */
#endif /* __cplusplus */
# if !defined(STLSOFT_COMPILER_IS_DMC)
typedef cs_size_t           size_t;             /*!< size                       */
typedef cs_dword_t          dword_t;            /*!< dword                      */
typedef cs_ptrdiff_t        ptrdiff_t;          /*!< ptr diff                   */
typedef cs_streampos_t      streampos_t;        /*!< streampos                  */
typedef cs_streamoff_t      streamoff_t;        /*!< streamoff                  */
# endif /* compiler */
#endif /* !_STLSOFT_NO_NAMESPACE */

#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */

/* /////////////////////////////////////////////////////////////////////////
 * Values
 *
 * Since the boolean type may not be supported natively on all compilers, the
 * values of true and false may also not be provided. Hence the values of
 * cs_true_v and cs_false_v are defined, and are used in all code.
 */

#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION

#define cs_true_v       ss_true_v
#define cs_false_v      ss_false_v

#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
/* /////////////////////////////////////////////////////////////////////////
 * Code modification macros
 */

#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
/* Exception signatures. */
#define comstl_throw_0()                                stlsoft_throw_0()
#define comstl_throw_1(x1)                              stlsoft_throw_1(x1)
#define comstl_throw_2(x1, x2)                          stlsoft_throw_2(x1, x2)
#define comstl_throw_3(x1, x2, x3)                      stlsoft_throw_3(x1, x2, x3)
#define comstl_throw_4(x1, x2, x3, x4)                  stlsoft_throw_4(x1, x2, x3, x4)
#define comstl_throw_5(x1, x2, x3, x4, x5)              stlsoft_throw_5(x1, x2, x3, x4, x5)
#define comstl_throw_6(x1, x2, x3, x4, x5, x6)          stlsoft_throw_6(x1, x2, x3, x4, x5, x6)
#define comstl_throw_7(x1, x2, x3, x4, x5, x6, x7)      stlsoft_throw_7(x1, x2, x3, x4, x5, x6, x7)
#define comstl_throw_8(x1, x2, x3, x4, x5, x6, x7, x8)  stlsoft_throw_8(x1, x2, x3, x4, x5, x6, x7, x8)
#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */

/// Evaluates, at compile time, to the number of elements within the given vector entity
///
/// \param ar An array whose dimension is to be evaluated
#define COMSTL_NUM_ELEMENTS(ar)                         STLSOFT_NUM_ELEMENTS(ar)
#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
# define comstl_num_elements(ar)                        COMSTL_NUM_ELEMENTS(ar)
#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */

/** \brief [DEPRECATED] Destroys the given instance \c p of the given type (\c t and \c _type)
 *
 * \deprecated This is <b>heavily</b> deprecated in favour of \ref STLSOFT_DESTROY_INSTANCE().
 */
#define comstl_destroy_instance(t, _type, p)            STLSOFT_DESTROY_INSTANCE(t, _type, p)

/** \brief [DEPRECATED] Generates an opaque type with the name \c _htype
 *
 * \deprecated This is <b>heavily</b> deprecated in favour of \ref STLSOFT_GEN_OPAQUE().
 */
#define comstl_gen_opaque(_htype)                       STLSOFT_GEN_OPAQUE(_htype)

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

#ifndef _COMSTL_NO_NAMESPACE
# if defined(_STLSOFT_NO_NAMESPACE) || \
     defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
} /* namespace comstl */
# else
} /* namespace comstl_project */
} /* namespace stlsoft */
namespace comstl = ::stlsoft::comstl_project;
# endif /* _STLSOFT_NO_NAMESPACE */
#endif /* !_COMSTL_NO_NAMESPACE */

/* /////////////////////////////////////////////////////////////////////////
 * Inclusion
 */

#ifdef STLSOFT_CF_PRAGMA_ONCE_SUPPORT
# pragma once
#endif /* STLSOFT_CF_PRAGMA_ONCE_SUPPORT */

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

#endif /* COMSTL_INCL_COMSTL_H_COMSTL */

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

⌨️ 快捷键说明

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