📄 unixstl.h
字号:
*
* The macro unixstl_assert provides standard debug-mode assert functionality.
*/
/// Defines a runtime assertion
///
/// \param expr Must be non-zero, or an assertion will be fired
#if defined(UNIXSTL_OS_IS_MACOSX) && \
defined(__assert)
# define UNIXSTL_ASSERT(expr) ((void)((expr) ? 0 : __assert(#expr, __FILE__, __LINE__)))
#else /* ? UNIXSTL_OS_IS_MACOSX */
# define UNIXSTL_ASSERT(expr) STLSOFT_ASSERT(expr)
#endif /* UNIXSTL_OS_IS_MACOSX */
/// Defines a runtime assertion, with message
///
/// \param expr Must be non-zero, or an assertion will be fired
/// \param msg The literal character string message to be included in the assertion
#define UNIXSTL_MESSAGE_ASSERT(msg, expr) STLSOFT_MESSAGE_ASSERT(msg, expr)
/// Defines a compile-time assertion
///
/// \param expr Must be non-zero, or compilation will fail
#define UNIXSTL_STATIC_ASSERT(expr) STLSOFT_STATIC_ASSERT(expr)
#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
# define unixstl_assert(expr) UNIXSTL_ASSERT(expr)
# define unixstl_message_assert(msg, expr) UNIXSTL_MESSAGE_ASSERT(msg, expr)
# define unixstl_static_assert(expr) UNIXSTL_STATIC_ASSERT(expr)
#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
/* /////////////////////////////////////////////////////////////////////////
* Namespace
*
* The UNIXSTL components are contained within the unixstl namespace. This is
* usually an alias for stlsoft::unixstl_project,
*
* When compilers support namespaces they are defined by default. They can be
* undefined using a cascasing system, as follows:
*
* If _STLSOFT_NO_NAMESPACES is defined, then _UNIXSTL_NO_NAMESPACES is defined.
*
* If _UNIXSTL_NO_NAMESPACES is defined, then _UNIXSTL_NO_NAMESPACE is defined.
*
* If _UNIXSTL_NO_NAMESPACE is defined, then the UNIXSTL constructs are defined
* in the global scope.
*
* If _STLSOFT_NO_NAMESPACES, _UNIXSTL_NO_NAMESPACES and _UNIXSTL_NO_NAMESPACE are
* all undefined but the symbol _STLSOFT_NO_NAMESPACE is defined (whence the
* namespace stlsoft does not exist), then the UNIXSTL constructs are defined
* within the unixstl namespace. The definition matrix is as follows:
*
* _STLSOFT_NO_NAMESPACE _UNIXSTL_NO_NAMESPACE unixstl definition
* --------------------- -------------------- -----------------
* not defined not defined = stlsoft::unixstl_project
* not defined defined not defined
* defined not defined unixstl
* defined defined not defined
*
*
*
* The macro unixstl_ns_qual() macro can be used to refer to elements in the
* UNIXSTL libraries irrespective of whether they are in the
* stlsoft::unixstl_project (or unixstl) namespace or in the global namespace.
*
* Furthermore, some compilers do not support the standard library in the std
* namespace, so the unixstl_ns_qual_std() macro can be used to refer to elements
* in the UNIXSTL libraries irrespective of whether they are in the std namespace
* or in the global namespace.
*/
/* No STLSoft namespaces means no UNIXSTL namespaces */
#ifdef _STLSOFT_NO_NAMESPACES
# define _UNIXSTL_NO_NAMESPACES
#endif /* _STLSOFT_NO_NAMESPACES */
/* No UNIXSTL namespaces means no unixstl namespace */
#ifdef _UNIXSTL_NO_NAMESPACES
# define _UNIXSTL_NO_NAMESPACE
#endif /* _UNIXSTL_NO_NAMESPACES */
#ifndef _UNIXSTL_NO_NAMESPACE
# if defined(_STLSOFT_NO_NAMESPACE) || \
defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
/* There is no stlsoft namespace, so must define ::unixstl */
/** \brief The <code class="namespace">unixstl</code> namespace contains all components
* in the \ref group__project__unixstl "UNIXSTL" project.
*
* By default, the <code>unixstl</code> namespace is actually an alias for
* the namespace <code>stlsoft::unixstl_project</code>, which is where all
* the \ref group__project__unixstl "UNIXSTL" 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>unixstl</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>_UNIXSTL_NO_NAMESPACE</code> are defined, all
* \ref group__project__unixstl "UNIXSTL" 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>_UNIXSTL_NO_NAMESPACE</code>
* is <b>not</b> defined, then all \ref group__project__unixstl "UNIXSTL"
* components will be defined within a bona fide <code>unixstl</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 unixstl
{
# else
/* Define stlsoft::unixstl_project */
namespace stlsoft
{
namespace unixstl_project
{
# endif /* _STLSOFT_NO_NAMESPACE */
#else
stlsoft_ns_using(move_lhs_from_rhs)
#endif /* !_UNIXSTL_NO_NAMESPACE */
/** \def unixstl_ns_qual(x)
* Qualifies with <b>unixstl::</b> if UNIXSTL is using namespaces or, if not, does not qualify
*/
/** \def unixstl_ns_using(x)
* Declares a using directive (with respect to <b>unixstl</b>) if UNIXSTL is using namespaces or, if not, does nothing
*/
#ifndef _UNIXSTL_NO_NAMESPACE
# define unixstl_ns_qual(x) ::unixstl::x
# define unixstl_ns_using(x) using ::unixstl::x;
#else
# define unixstl_ns_qual(x) x
# define unixstl_ns_using(x)
#endif /* !_UNIXSTL_NO_NAMESPACE */
/** \def unixstl_ns_qual_std(x)
* Qualifies with <b>std::</b> if UNIXSTL is being translated in the context of the standard library being within the <b>std</b> namespace or, if not, does not qualify
*/
/** \def unixstl_ns_using_std(x)
* Declares a using directive (with respect to <b>std</b>) if UNIXSTL 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 unixstl_ns_qual_std(x) ::std::x
# define unixstl_ns_using_std(x) using ::std::x;
#else /* ? STLSOFT_CF_std_NAMESPACE */
# define unixstl_ns_qual_std(x) x
# define unixstl_ns_using_std(x)
#endif /* !STLSOFT_CF_std_NAMESPACE */
/* /////////////////////////////////////////////////////////////////////////
* Typedefs
*
* The UNIXSTL 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) us_char_a_t; //!< Ansi char type
typedef stlsoft_ns_qual(ss_char_w_t) us_char_w_t; //!< Unicode char type
typedef stlsoft_ns_qual(ss_sint8_t) us_sint8_t; //!< 8-bit signed integer
typedef stlsoft_ns_qual(ss_uint8_t) us_uint8_t; //!< 8-bit unsigned integer
typedef stlsoft_ns_qual(ss_int16_t) us_int16_t; //!< 16-bit integer
typedef stlsoft_ns_qual(ss_sint16_t) us_sint16_t; //!< 16-bit signed integer
typedef stlsoft_ns_qual(ss_uint16_t) us_uint16_t; //!< 16-bit unsigned integer
typedef stlsoft_ns_qual(ss_int32_t) us_int32_t; //!< 32-bit integer
typedef stlsoft_ns_qual(ss_sint32_t) us_sint32_t; //!< 32-bit signed integer
typedef stlsoft_ns_qual(ss_uint32_t) us_uint32_t; //!< 32-bit unsigned integer
#ifdef STLSOFT_CF_64BIT_INT_SUPPORT
typedef stlsoft_ns_qual(ss_int64_t) us_int64_t; //!< 64-bit integer
typedef stlsoft_ns_qual(ss_sint64_t) us_sint64_t; //!< 64-bit signed integer
typedef stlsoft_ns_qual(ss_uint64_t) us_uint64_t; //!< 64-bit unsigned integer
#endif /* STLSOFT_CF_64BIT_INT_SUPPORT */
typedef stlsoft_ns_qual(ss_int_t) us_int_t; //!< integer
typedef stlsoft_ns_qual(ss_sint_t) us_sint_t; //!< signed integer
typedef stlsoft_ns_qual(ss_uint_t) us_uint_t; //!< unsigned integer
typedef stlsoft_ns_qual(ss_long_t) us_long_t; //!< long
#if defined(__cplusplus)
typedef stlsoft_ns_qual(ss_bool_t) us_bool_t; //!< bool
#endif /* __cplusplus */
typedef stlsoft_ns_qual(ss_size_t) us_size_t; //!< size
typedef stlsoft_ns_qual(ss_ptrdiff_t) us_ptrdiff_t; //!< ptr diff
typedef stlsoft_ns_qual(ss_streampos_t) us_streampos_t; //!< streampos
typedef stlsoft_ns_qual(ss_streamoff_t) us_streamoff_t; //!< streamoff
#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
#ifndef _UNIXSTL_NO_NAMESPACE
typedef us_char_a_t char_a_t; //!< Ansi char type
typedef us_char_w_t char_w_t; //!< Unicode char type
//typedef us_int8_t int8_t; //!< 8-bit integer
typedef us_sint8_t sint8_t; //!< 8-bit signed integer
typedef us_uint8_t uint8_t; //!< 8-bit unsigned integer
typedef us_int16_t int16_t; //!< 16-bit integer
typedef us_sint16_t sint16_t; //!< 16-bit signed integer
typedef us_uint16_t uint16_t; //!< 16-bit unsigned integer
typedef us_int32_t int32_t; //!< 32-bit integer
typedef us_sint32_t sint32_t; //!< 32-bit signed integer
typedef us_uint32_t uint32_t; //!< 32-bit unsigned integer
# ifdef STLSOFT_CF_64BIT_INT_SUPPORT
typedef us_int64_t int64_t; //!< 64-bit integer
typedef us_sint64_t sint64_t; //!< 64-bit signed integer
typedef us_uint64_t uint64_t; //!< 64-bit unsigned integer
# endif /* STLSOFT_CF_64BIT_INT_SUPPORT */
//typedef us_short_t short_t; //!< short integer
typedef us_int_t int_t; //!< integer
typedef us_sint_t sint_t; //!< signed integer
typedef us_uint_t uint_t; //!< unsigned integer
typedef us_long_t long_t; //!< long integer
//typedef us_byte_t byte_t; //!< Byte
typedef us_bool_t bool_t; //!< bool
# if !defined(STLSOFT_COMPILER_IS_DMC)
typedef us_size_t size_t; //!< size
typedef us_ptrdiff_t ptrdiff_t; //!< ptr diff
typedef us_streampos_t streampos_t; //!< streampos
typedef us_streamoff_t streamoff_t; //!< streamoff
# endif /* compiler */
#endif /* !_UNIXSTL_NO_NAMESPACE */
/* /////////////////////////////////////////////////////////////////////////
* 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
* us_true_v and us_false_v are defined, and are used in all code.
*/
#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
#define us_true_v ss_true_v
#define us_false_v ss_false_v
#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
/* /////////////////////////////////////////////////////////////////////////
* Code modification macros
*/
#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
/* Exception signatures. */
#define unixstl_throw_0() stlsoft_throw_0()
#define unixstl_throw_1(x1) stlsoft_throw_1(x1)
#define unixstl_throw_2(x1, x2) stlsoft_throw_2(x1, x2)
#define unixstl_throw_3(x1, x2, x3) stlsoft_throw_3(x1, x2, x3)
#define unixstl_throw_4(x1, x2, x3, x4) stlsoft_throw_4(x1, x2, x3, x4)
#define unixstl_throw_5(x1, x2, x3, x4, x5) stlsoft_throw_5(x1, x2, x3, x4, x5)
#define unixstl_throw_6(x1, x2, x3, x4, x5, x6) stlsoft_throw_6(x1, x2, x3, x4, x5, x6)
#define unixstl_throw_7(x1, x2, x3, x4, x5, x6, x7) stlsoft_throw_7(x1, x2, x3, x4, x5, x6, x7)
#define unixstl_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 UNIXSTL_NUM_ELEMENTS(ar) STLSOFT_NUM_ELEMENTS(ar)
#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
# define unixstl_num_elements(ar) UNIXSTL_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 unixstl_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 unixstl_gen_opaque(_htype) STLSOFT_GEN_OPAQUE(_htype)
/* ////////////////////////////////////////////////////////////////////// */
#ifndef _UNIXSTL_NO_NAMESPACE
# if defined(_STLSOFT_NO_NAMESPACE) || \
defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
} /* namespace unixstl */
# else
} /* namespace unixstl_project */
} /* namespace stlsoft */
namespace unixstl = ::stlsoft::unixstl_project;
# endif /* _STLSOFT_NO_NAMESPACE */
#endif /* !_UNIXSTL_NO_NAMESPACE */
/* /////////////////////////////////////////////////////////////////////////
* Inclusion
*/
#ifdef STLSOFT_CF_PRAGMA_ONCE_SUPPORT
# pragma once
#endif /* STLSOFT_CF_PRAGMA_ONCE_SUPPORT */
/* ////////////////////////////////////////////////////////////////////// */
#endif /* !UNIXSTL_INCL_UNIXSTL_H_UNIXSTL */
/* ////////////////////////////////////////////////////////////////////// */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -