You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

837 lines
33 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: comstl/comstl.h
  3. *
  4. * Purpose: Root header for the COMSTL libraries. Performs various compiler
  5. * and platform discriminations, and definitions of types.
  6. *
  7. * Created: 15th January 2002
  8. * Updated: 2nd March 2012
  9. *
  10. * Home: http://stlsoft.org/
  11. *
  12. * Copyright (c) 2002-2012, Matthew Wilson and Synesis Software
  13. * All rights reserved.
  14. *
  15. * Redistribution and use in source and binary forms, with or without
  16. * modification, are permitted provided that the following conditions are met:
  17. *
  18. * - Redistributions of source code must retain the above copyright notice, this
  19. * list of conditions and the following disclaimer.
  20. * - Redistributions in binary form must reproduce the above copyright notice,
  21. * this list of conditions and the following disclaimer in the documentation
  22. * and/or other materials provided with the distribution.
  23. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
  24. * any contributors may be used to endorse or promote products derived from
  25. * this software without specific prior written permission.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  28. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  29. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  30. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  31. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  32. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  33. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  34. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  35. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  36. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  37. * POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. * ////////////////////////////////////////////////////////////////////// */
  40. #ifndef COMSTL_INCL_COMSTL_H_COMSTL
  41. #define COMSTL_INCL_COMSTL_H_COMSTL
  42. /** \brief Defined for backward-compatiblity
  43. *
  44. * This is the old header include guard, from when comstl.h was in the
  45. * STLSoft root include directory
  46. */
  47. #define COMSTL_INCL_H_COMSTL
  48. /* File version */
  49. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  50. # define COMSTL_VER_COMSTL_H_COMSTL_MAJOR 3
  51. # define COMSTL_VER_COMSTL_H_COMSTL_MINOR 9
  52. # define COMSTL_VER_COMSTL_H_COMSTL_REVISION 1
  53. # define COMSTL_VER_COMSTL_H_COMSTL_EDIT 116
  54. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  55. /** \file comstl/comstl.h
  56. *
  57. * \brief [C, C++; requires COM] The root header for the \ref group__project__comstl "COMSTL" project.
  58. */
  59. /* /////////////////////////////////////////////////////////////////////////
  60. * COMSTL version
  61. *
  62. * The libraries version information is comprised of major, minor and revision
  63. * components.
  64. *
  65. * The major version is denoted by the _COMSTL_VER_MAJOR preprocessor symbol.
  66. * A changes to the major version component implies that a dramatic change has
  67. * occurred in the libraries, such that considerable changes to source dependent
  68. * on previous versions would need to be effected.
  69. *
  70. * The minor version is denoted by the _COMSTL_VER_MINOR preprocessor symbol.
  71. * Changes to the minor version component imply that a significant change has
  72. * occurred to the libraries, either in the addition of new functionality or in
  73. * the destructive change to one or more components such that recomplilation and
  74. * code change may be necessitated.
  75. *
  76. * The revision version is denoted by the _COMSTL_VER_REVISION preprocessor
  77. * symbol. Changes to the revision version component imply that a bug has been
  78. * fixed. Dependent code should be recompiled in order to pick up the changes.
  79. *
  80. * In addition to the individual version symbols - _COMSTL_VER_MAJOR,
  81. * _COMSTL_VER_MINOR and _COMSTL_VER_REVISION - a composite symbol _COMSTL_VER
  82. * is defined, where the upper 8 bits are 0, bits 16-23 represent the major
  83. * component, bits 8-15 represent the minor component, and bits 0-7 represent
  84. * the revision component.
  85. *
  86. * Each release of the libraries will bear a different version, and that version
  87. * will also have its own symbol: Version 1.0.1 specifies _COMSTL_VER_1_0_1.
  88. *
  89. * Thus the symbol _COMSTL_VER may be compared meaningfully with a specific
  90. * version symbol, e.g. #if _COMSTL_VER >= _COMSTL_VER_1_0_1
  91. */
  92. /** \def _COMSTL_VER_MAJOR
  93. *
  94. * \brief The major version number of COMSTL
  95. *
  96. * This number is subject to increment when changes to COMSTL are so
  97. * substantial as to require wholesale changes to application code.
  98. */
  99. /** \def _COMSTL_VER_MINOR
  100. *
  101. * \brief The minor version number of COMSTL
  102. *
  103. * This number is subject to increment when changes to COMSTL as so
  104. * substantial as to require wholesale changes to application code.
  105. */
  106. /** \def _COMSTL_VER_REVISION
  107. *
  108. * \brief The revision version number of COMSTL
  109. */
  110. /** \def _COMSTL_VER
  111. *
  112. * \brief The current composite version number of COMSTL
  113. */
  114. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  115. # define _COMSTL_VER_1_0_1 0x00010001 /*!< Version 1.0.1 */
  116. # define _COMSTL_VER_1_1_1 0x00010101 /*!< Version 1.1.1 */
  117. # define _COMSTL_VER_1_2_1 0x00010201 /*!< Version 1.2.1 */
  118. # define _COMSTL_VER_1_2_2 0x00010202 /*!< Version 1.2.2 */
  119. # define _COMSTL_VER_1_2_3 0x00010203 /*!< Version 1.2.3 */
  120. # define _COMSTL_VER_1_2_4 0x00010204 /*!< Version 1.2.4 */
  121. # define _COMSTL_VER_1_2_5 0x00010205 /*!< Version 1.2.5 */
  122. # define _COMSTL_VER_1_3_1 0x00010301 /*!< Version 1.3.1 */
  123. # define _COMSTL_VER_1_4_1 0x00010401 /*!< Version 1.4.1 */
  124. # define _COMSTL_VER_1_5_1 0x00010501 /*!< Version 1.5.1 */
  125. # define _COMSTL_VER_1_5_2 0x00010502 /*!< Version 1.5.2 */
  126. # define _COMSTL_VER_1_5_3 0x00010503 /*!< Version 1.5.3 */
  127. # define _COMSTL_VER_1_5_4 0x00010504 /*!< Version 1.5.4 */
  128. # define _COMSTL_VER_1_6_1 0x00010601 /*!< Version 1.6.1 */
  129. # define _COMSTL_VER_1_6_2 0x00010602 /*!< Version 1.6.2 */
  130. # define _COMSTL_VER_1_7_1 0x00010701 /*!< Version 1.7.1 (with STLSoft 1.9.1) */
  131. # define _COMSTL_VER_1_7_2 0x00010702 /*!< Version 1.7.2 (with STLSoft 1.9.8) */
  132. # define _COMSTL_VER_1_7_3 0x00010703 /*!< Version 1.7.3 (with STLSoft 1.9.25) */
  133. # define _COMSTL_VER_1_7_4 0x010704ff /*!< Version 1.7.4 (with STLSoft 1.9.31) */
  134. # define _COMSTL_VER_1_8_1 0x010801ff /*!< Version 1.8.1 (with STLSoft 1.9.37) */
  135. # define _COMSTL_VER_1_8_2 0x010802ff /*!< Version 1.8.2 (with STLSoft 1.9.57) */
  136. # define _COMSTL_VER_1_8_3 0x010803ff /*!< Version 1.8.3 (with STLSoft 1.9.59) */
  137. # define _COMSTL_VER_1_8_4 0x010804ff /*!< Version 1.8.4 (with STLSoft 1.9.84) */
  138. # define _COMSTL_VER_1_8_5 0x010805ff /*!< Version 1.8.5 (with STLSoft 1.9.88) */
  139. # define _COMSTL_VER_1_8_6 0x010806ff /*!< Version 1.8.6 (with STLSoft 1.9.97) */
  140. # define _COMSTL_VER_1_9_1 0x010901ff /*!< Version 1.9.1 (with STLSoft 1.9.98) */
  141. # define _COMSTL_VER_1_9_2 0x010902ff /*!< Version 1.9.2 (with STLSoft 1.9.113) */
  142. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  143. #define _COMSTL_VER_MAJOR 1
  144. #define _COMSTL_VER_MINOR 9
  145. #define _COMSTL_VER_REVISION 2
  146. #define _COMSTL_VER _COMSTL_VER_1_9_2
  147. /* /////////////////////////////////////////////////////////////////////////
  148. * Includes
  149. */
  150. #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
  151. # include <stlsoft/stlsoft.h>
  152. #endif /* !STLSOFT_INCL_STLSOFT_H_STLSOFT */
  153. #ifndef STLSOFT_INCL_H_OBJBASE
  154. # define STLSOFT_INCL_H_OBJBASE
  155. # include <objbase.h>
  156. #endif /* !STLSOFT_INCL_H_OBJBASE */
  157. #if defined(STLSOFT_COMPILER_IS_GCC) && \
  158. defined(_WIN32) && \
  159. ( defined(WIN32) || \
  160. defined(WIN64))
  161. # ifndef STLSOFT_INCL_H_OLEAUTO
  162. # define STLSOFT_INCL_H_OLEAUTO
  163. # include <oleauto.h>
  164. # endif /* !STLSOFT_INCL_H_OLEAUTO */
  165. # ifndef STLSOFT_INCL_H_OAIDL
  166. # define STLSOFT_INCL_H_OAIDL
  167. # include <oaidl.h>
  168. # endif /* !STLSOFT_INCL_H_OAIDL */
  169. #endif /* compiler */
  170. /* /////////////////////////////////////////////////////////////////////////
  171. * STLSoft version compatibility
  172. */
  173. #if !defined(_STLSOFT_VER) || \
  174. _STLSOFT_VER < 0x010971ff
  175. # error This version of the COMSTL libraries requires STLSoft version 1.9.113, or later
  176. #endif /* _STLSOFT_VER */
  177. /* /////////////////////////////////////////////////////////////////////////
  178. * Compiler compatibility
  179. *
  180. * Currently the only compilers supported by the COMSTL libraries are
  181. *
  182. * Borland C++ 5.5, 5.51, 5.6
  183. * Digital Mars C/C++ 8.26 - 8.32
  184. * Metrowerks 2.4 & 3.0 (CodeWarrior 7.0 & 8.0)
  185. * Intel C/C++ 6.0
  186. * Visual C++ 4.2, 5.0, 6.0, 7.0
  187. */
  188. #if defined(STLSOFT_COMPILER_IS_BORLAND)
  189. /* Borland C++ */
  190. # if __BORLANDC__ < 0x0550
  191. # error Versions of Borland C++ prior to 5.5 are not supported by the COMSTL libraries
  192. # endif /* __BORLANDC__ */
  193. #elif defined(STLSOFT_COMPILER_IS_COMO)
  194. /* Comeau C++ */
  195. #elif defined(STLSOFT_COMPILER_IS_DMC)
  196. /* Digital Mars C/C++ */
  197. # if __DMC__ < 0x0826
  198. # error Versions of Digital Mars C/C++ prior to 8.26 are not supported by the COMSTL libraries
  199. # endif /* __DMC__ */
  200. #elif defined(STLSOFT_COMPILER_IS_GCC)
  201. /* Digital Mars C/C++ */
  202. # if __GNUC__ < 3
  203. # error Versions of GNU C/C++ prior to 3 are not supported by the COMSTL libraries
  204. # endif /* __GNUC__ */
  205. #elif defined(STLSOFT_COMPILER_IS_INTEL)
  206. /* Intel C++ */
  207. # if (__INTEL_COMPILER < 600)
  208. # error Versions of Intel C++ prior to 6.0 are not supported by the COMSTL libraries
  209. # endif /* __INTEL_COMPILER */
  210. #elif defined(STLSOFT_COMPILER_IS_MWERKS)
  211. /* Metrowerks C++ */
  212. # if (__MWERKS__ & 0xFF00) < 0x2400
  213. # error Versions of Metrowerks CodeWarrior C++ prior to 7.0 are not supported by the COMSTL libraries
  214. # endif /* __MWERKS__ */
  215. #elif defined(STLSOFT_COMPILER_IS_WATCOM)
  216. /* Watcom C/C++ */
  217. # if (__WATCOMC__ < 1230)
  218. # error Versions of Watcom C/C++ prior to 12.3 (Open Watcom 1.3) are not supported by the COMSTL libraries
  219. # endif /* __MWERKS__ */
  220. #elif defined(STLSOFT_COMPILER_IS_MSVC)
  221. /* Visual C++ */
  222. # if _MSC_VER < 1020
  223. # error Versions of Visual C++ prior to 4.2 are not supported by the COMSTL libraries
  224. # endif /* _MSC_VER */
  225. #else /* ? compiler */
  226. /* No recognised compiler */
  227. # ifdef _STLSOFT_FORCE_ANY_COMPILER
  228. # define _COMSTL_COMPILER_IS_UNKNOWN
  229. # ifdef STLSOFT_COMPILE_VERBOSE
  230. # pragma message("Compiler is unknown to COMSTL")
  231. # endif /* STLSOFT_COMPILE_VERBOSE */
  232. # else /* ? _STLSOFT_FORCE_ANY_COMPILER */
  233. # error Currently only Borland C++, Comeau, Digital Mars C/C++, Intel C/C++, Metrowerks CodeWarrior C/C++ and Visual C++ compilers are supported by the COMSTL libraries
  234. # endif /* _STLSOFT_FORCE_ANY_COMPILER */
  235. #endif /* compiler tag */
  236. /* /////////////////////////////////////////////////////////////////////////
  237. * Contract Enforcement
  238. *
  239. * The macro comstl_assert provides standard debug-mode assert functionality.
  240. */
  241. /** \brief Defines a runtime assertion
  242. *
  243. * \ingroup group__project__comstl__assertion_macros
  244. *
  245. * \param expr Must be non-zero, or an assertion will be fired
  246. */
  247. #define COMSTL_ASSERT(expr) STLSOFT_ASSERT(expr)
  248. /** \brief Defines a runtime assertion, with message
  249. *
  250. * \ingroup group__project__comstl__assertion_macros
  251. *
  252. * \param expr Must be non-zero, or an assertion will be fired
  253. * \param msg The literal character string message to be included in the assertion
  254. */
  255. #define COMSTL_MESSAGE_ASSERT(msg, expr) STLSOFT_MESSAGE_ASSERT(msg, expr)
  256. /** \brief Defines a compile-time assertion
  257. *
  258. * \ingroup group__project__comstl__assertion_macros
  259. *
  260. * \param expr Must be non-zero, or compilation will fail
  261. */
  262. #define COMSTL_STATIC_ASSERT(expr) STLSOFT_STATIC_ASSERT(expr)
  263. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  264. # define comstl_assert(expr) COMSTL_ASSERT(expr)
  265. # define comstl_message_assert(msg, expr) COMSTL_MESSAGE_ASSERT(msg, expr)
  266. # define comstl_static_assert(expr) COMSTL_STATIC_ASSERT(expr)
  267. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  268. /* /////////////////////////////////////////////////////////////////////////
  269. * Compiler language feature support
  270. */
  271. /* DCOM support
  272. *
  273. * Since some COM APIs are only available, at compile time, when DCOM is
  274. * explicitly discriminated (for Windows this is via _WIN32_WINNT >= 0x0400 or
  275. * presence of _WIN32_DCOM), this must be determined.
  276. *
  277. * Override and always support DCOM by defining _COMSTL_DCOM
  278. *
  279. * Prevent DCOM support by defining _COMSTL_NO_DCOM
  280. *
  281. */
  282. #ifdef __COMSTL_CF_DCOM_SUPPORT
  283. #undef __COMSTL_CF_DCOM_SUPPORT
  284. #endif /* __COMSTL_CF_DCOM_SUPPORT */
  285. #if !defined(_COMSTL_NO_DCOM) && \
  286. ( ( defined(_WIN32_WINNT ) && \
  287. (_WIN32_WINNT >= 0x0400)) || \
  288. defined(_WIN32_DCOM) || \
  289. defined(_COMSTL_DCOM))
  290. # define __COMSTL_CF_DCOM_SUPPORT
  291. #endif /* _WIN32_WINNT >= 0x0400 || _WIN32_DCOM */
  292. /* /////////////////////////////////////////////////////////////////////////
  293. * Namespace
  294. *
  295. * The COMSTL components are contained within the comstl namespace. This is
  296. * usually an alias for stlsoft::comstl_project.
  297. *
  298. * When compilers support namespaces they are defined by default. They can be
  299. * undefined using a cascasing system, as follows:
  300. *
  301. * If _STLSOFT_NO_NAMESPACES is defined, then _COMSTL_NO_NAMESPACES is defined.
  302. *
  303. * If _COMSTL_NO_NAMESPACES is defined, then _COMSTL_NO_NAMESPACE is defined.
  304. *
  305. * If _COMSTL_NO_NAMESPACE is defined, then the COMSTL constructs are defined
  306. * in the global scope.
  307. *
  308. * If _STLSOFT_NO_NAMESPACES, _COMSTL_NO_NAMESPACES and _COMSTL_NO_NAMESPACE are
  309. * all undefined but the symbol _STLSOFT_NO_NAMESPACE is defined (whence the
  310. * namespace stlsoft does not exist), then the COMSTL constructs are defined
  311. * within the comstl namespace. The definition matrix is as follows:
  312. *
  313. * _STLSOFT_NO_NAMESPACE _COMSTL_NO_NAMESPACE comstl definition
  314. * --------------------- -------------------- -----------------
  315. * not defined not defined = stlsoft::comstl_project
  316. * not defined defined not defined
  317. * defined not defined comstl
  318. * defined defined not defined
  319. *
  320. *
  321. *
  322. * The macro comstl_ns_qual() macro can be used to refer to elements in the
  323. * COMSTL libraries irrespective of whether they are in the
  324. * stlsoft::comstl_project (or comstl) namespace or in the global namespace.
  325. *
  326. * Furthermore, some compilers do not support the standard library in the std
  327. * namespace, so the comstl_ns_qual_std() macro can be used to refer to elements
  328. * in the COMSTL libraries irrespective of whether they are in the std namespace
  329. * or in the global namespace.
  330. */
  331. /* No STLSoft namespaces means no COMSTL namespaces */
  332. #ifdef _STLSOFT_NO_NAMESPACES
  333. # define _COMSTL_NO_NAMESPACES
  334. #endif /* _STLSOFT_NO_NAMESPACES */
  335. /* No COMSTL namespaces means no comstl namespace */
  336. #ifdef _COMSTL_NO_NAMESPACES
  337. # define _COMSTL_NO_NAMESPACE
  338. #endif /* _COMSTL_NO_NAMESPACES */
  339. #ifndef _COMSTL_NO_NAMESPACE
  340. # if defined(_STLSOFT_NO_NAMESPACE) || \
  341. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  342. /* There is no stlsoft namespace, so must define ::comstl */
  343. /** \brief The <code class="namespace">comstl</code> namespace contains all components
  344. * in the \ref group__project__comstl "COMSTL" project.
  345. *
  346. * By default, the <code>comstl</code> namespace is actually an alias for
  347. * the namespace <code>stlsoft::comstl_project</code>, which is where all
  348. * the \ref group__project__comstl "COMSTL" components actually reside. This
  349. * measure allows all components within the main the
  350. * \ref group__project__stlsoft "STLSoft" project (which are defined within
  351. * the <code>stlsoft</code> namespace) to be visible to all components
  352. * "within" the <code>comstl</code> namespace. (Otherwise, there would be a
  353. * whole lot of onerous qualification throughout the code of all
  354. * \ref group__projects "sub-projects".)
  355. *
  356. * \note If either/both of the symbols <code>_STLSOFT_NO_NAMESPACES</code>
  357. * and <code>_COMSTL_NO_NAMESPACE</code> are defined, all
  358. * \ref group__project__comstl "COMSTL" components will be defined in the
  359. * global namespace. Conversely, if the <code>_STLSOFT_NO_NAMESPACE</code>
  360. * symbol (not to be confused with the
  361. * <code>_STLSOFT_NO_NAMESPACES</code> symbol!) is defined - meaning that
  362. * all \ref group__project__stlsoft "main project" components are to be
  363. * defined in the global namespace, and <code>_COMSTL_NO_NAMESPACE</code>
  364. * is <b>not</b> defined, then all \ref group__project__comstl "COMSTL"
  365. * components will be defined within a bona fide <code>comstl</code>
  366. * namespace.
  367. *
  368. * \note This is a vestige of compatibility with compilers with
  369. * no (or no sensible) namespace support that is maintained for reasons of
  370. * backwards compatiblity and because it is, in <i>rare circumstances</i>, a
  371. * useful facility.
  372. */
  373. namespace comstl
  374. {
  375. # else
  376. /* Define stlsoft::comstl_project */
  377. namespace stlsoft
  378. {
  379. namespace comstl_project
  380. {
  381. # endif /* _STLSOFT_NO_NAMESPACE */
  382. #else
  383. stlsoft_ns_using(move_lhs_from_rhs)
  384. #endif /* !_COMSTL_NO_NAMESPACE */
  385. /** \def comstl_ns_qual(x)
  386. * Qualifies with <b>comstl::</b> if COMSTL is using namespaces or, if not, does not qualify
  387. */
  388. /** \def comstl_ns_using(x)
  389. * Declares a using directive (with respect to <b>comstl</b>) if COMSTL is using namespaces or, if not, does nothing
  390. */
  391. #ifndef _COMSTL_NO_NAMESPACE
  392. # define comstl_ns_qual(x) ::comstl::x
  393. # define comstl_ns_using(x) using ::comstl::x;
  394. #else /* ? _COMSTL_NO_NAMESPACE */
  395. # define comstl_ns_qual(x) x
  396. # define comstl_ns_using(x)
  397. #endif /* !_COMSTL_NO_NAMESPACE */
  398. /** \def comstl_ns_qual_std(x)
  399. * 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
  400. */
  401. /** \def comstl_ns_using_std(x)
  402. * 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
  403. */
  404. #ifdef STLSOFT_CF_std_NAMESPACE
  405. # define comstl_ns_qual_std(x) ::std::x
  406. # define comstl_ns_using_std(x) using ::std::x;
  407. #else /* ? STLSOFT_CF_std_NAMESPACE */
  408. # define comstl_ns_qual_std(x) x
  409. # define comstl_ns_using_std(x)
  410. #endif /* !STLSOFT_CF_std_NAMESPACE */
  411. /* /////////////////////////////////////////////////////////////////////////
  412. * Language agnostic macros.
  413. */
  414. /** \def COMSTL_ITF_CALL(p)
  415. *
  416. * \ingroup group__project__comstl__language_agnostic_macros
  417. *
  418. * \brief Resolves to <b>p->lpVtbl</b> for C compilation, and to <b>p</b> in C++
  419. *
  420. * \see COMSTL_ITF_THIS, COMSTL_ITF_THIS0, COMSTL_IID_2_REF, COMSTL_REF_2_PTR
  421. */
  422. #if defined(__cplusplus)
  423. # define COMSTL_ITF_CALL(p) (p)
  424. #else /* ? __cplusplus */
  425. # define COMSTL_ITF_CALL(p) (p)->lpVtbl
  426. #endif /* __cplusplus */
  427. /** \def COMSTL_ITF_THIS(p)
  428. *
  429. * \ingroup group__project__comstl__language_agnostic_macros
  430. *
  431. * \brief Resolves to <b>p,</b> for C compilation, and to nothing in C++
  432. *
  433. * \see COMSTL_ITF_CALL, COMSTL_ITF_THIS0, COMSTL_IID_2_REF, COMSTL_REF_2_PTR
  434. */
  435. #if defined(__cplusplus)
  436. # define COMSTL_ITF_THIS(p)
  437. #else /* ? __cplusplus */
  438. # define COMSTL_ITF_THIS(p) (p),
  439. #endif /* __cplusplus */
  440. /** \def COMSTL_ITF_THIS0(p)
  441. *
  442. * \ingroup group__project__comstl__language_agnostic_macros
  443. *
  444. * \brief Resolves to <b>p</b> for C compilation, and to nothing in C++
  445. *
  446. * \see COMSTL_ITF_CALL, COMSTL_ITF_THIS, COMSTL_IID_2_REF, COMSTL_REF_2_PTR
  447. */
  448. #if defined(__cplusplus)
  449. # define COMSTL_ITF_THIS0(p)
  450. #else /* ? __cplusplus */
  451. # define COMSTL_ITF_THIS0(p) (p)
  452. #endif /* __cplusplus */
  453. /** \def COMSTL_IID_2_REF(iid)
  454. *
  455. * \ingroup group__project__comstl__language_agnostic_macros
  456. *
  457. * \brief Resolves to <b>&iid</b> for C compilation, and to <b>iid</b> in C++
  458. *
  459. * \see COMSTL_ITF_CALL, COMSTL_ITF_THIS, COMSTL_ITF_THIS0, COMSTL_REF_2_PTR
  460. */
  461. #if defined(__cplusplus)
  462. # define COMSTL_IID_2_REF(iid) (iid)
  463. #else /* ? __cplusplus */
  464. # define COMSTL_IID_2_REF(iid) (&(iid))
  465. #endif /* __cplusplus */
  466. /** \def COMSTL_REF_2_PTR(iid)
  467. *
  468. * \ingroup group__project__comstl__language_agnostic_macros
  469. *
  470. * \brief Resolves to <b>iid</b> for C compilation, and to <b>&iid</b> in C++
  471. *
  472. * \see COMSTL_ITF_CALL, COMSTL_ITF_THIS, COMSTL_ITF_THIS0, COMSTL_PTR_2_REF
  473. */
  474. #if defined(__cplusplus)
  475. # define COMSTL_REF_2_PTR(iid) (&(iid))
  476. #else /* ? __cplusplus */
  477. # define COMSTL_REF_2_PTR(iid) (iid)
  478. #endif /* __cplusplus */
  479. /** \def COMSTL_PTR_2_REF(iid)
  480. *
  481. * \ingroup group__project__comstl__language_agnostic_macros
  482. *
  483. * \brief Resolves to <b>piid</b> for C compilation, and to <b>*piid</b> in C++
  484. *
  485. * \see COMSTL_ITF_CALL, COMSTL_ITF_THIS, COMSTL_ITF_THIS0, COMSTL_REF_2_PTR
  486. */
  487. #if defined(__cplusplus)
  488. # define COMSTL_PTR_2_REF(piid) (*(piid))
  489. #else /* ? __cplusplus */
  490. # define COMSTL_PTR_2_REF(piid) (piid)
  491. #endif /* __cplusplus */
  492. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  493. # ifdef COMSTL_VARIANT_UNION_ARMS_HAVE_NAMES_
  494. # undef COMSTL_VARIANT_UNION_ARMS_HAVE_NAMES_
  495. # endif /* COMSTL_VARIANT_UNION_ARMS_HAVE_NAMES_ */
  496. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  497. #if !defined(COMSTL_ASSUME_VARIANT_UNION_FORCE_ARMS_HAVE_NAMES) && \
  498. defined(_FORCENAMELESSUNION) && \
  499. !defined(NONAMELESSUNION)
  500. # define COMSTL_ASSUME_VARIANT_UNION_FORCE_ARMS_HAVE_NAMES
  501. #endif /* !COMSTL_ASSUME_VARIANT_UNION_FORCE_ARMS_HAVE_NAMES) && _FORCENAMELESSUNION */
  502. #if defined(COMSTL_ASSUME_VARIANT_UNION_FORCE_ARMS_HAVE_NAMES)
  503. # define COMSTL_VARIANT_UNION_ARMS_HAVE_NAMES_
  504. #elif defined(STLSOFT_COMPILER_IS_GCC)
  505. /* GCC has different definitions to the other compilers, so have to treat
  506. * differently
  507. */
  508. # if defined(NONAMELESSUNION)
  509. # define COMSTL_VARIANT_UNION_ARMS_HAVE_NAMES_
  510. # endif /* NONAMELESSUNION */
  511. #else /* ? compiler */
  512. /* Other compilers use the MS headers, which test against __STDC__,
  513. * _FORCENAMELESSUNION and NONAMELESSUNION
  514. */
  515. # if ( __STDC__ && \
  516. !defined(_FORCENAMELESSUNION)) || \
  517. defined(NONAMELESSUNION)
  518. # define COMSTL_VARIANT_UNION_ARMS_HAVE_NAMES_
  519. # endif /* ( __STDC__ && !_FORCENAMELESSUNION) || NONAMELESSUNION */
  520. #endif /* compiler */
  521. /** \def COMSTL_ACCESS_VARIANT_MEM_BYPTR(pvar, mem)
  522. *
  523. * \ingroup group__project__comstl__language_agnostic_macros
  524. *
  525. * \brief
  526. */
  527. # if defined(STLSOFT_DOCUMENTATION_SKIP_SECTION) || \
  528. !defined(COMSTL_VARIANT_UNION_ARMS_HAVE_NAMES_)
  529. # define COMSTL_ACCESS_VARIANT_MEM_BYPTR(pvar, mem) (pvar)->mem
  530. # else /* ? COMSTL_VARIANT_UNION_ARMS_HAVE_NAMES_ */
  531. # define COMSTL_ACCESS_VARIANT_MEM_BYPTR(pvar, mem) (pvar)->__VARIANT_NAME_1.__VARIANT_NAME_2.__VARIANT_NAME_3.mem
  532. # endif /* COMSTL_VARIANT_UNION_ARMS_HAVE_NAMES_ */
  533. /** \def COMSTL_ACCESS_VARIANT_MEM_BYREF(var, mem)
  534. *
  535. * \ingroup group__project__comstl__language_agnostic_macros
  536. *
  537. * Used to provide access to the \c mem member of a \c VARIANT structure in
  538. * a language-independent manner
  539. *
  540. * Usage:
  541. <pre>
  542. VARIANT v;
  543. COMSTL_ACCESS_VARIANT_MEM_BYREF(v, lVal) = 10;
  544. </pre>
  545. */
  546. #define COMSTL_ACCESS_VARIANT_MEM_BYREF(var, mem) COMSTL_ACCESS_VARIANT_MEM_BYPTR(&(var), mem)
  547. /** \def COMSTL_ACCESS_VARIANT_vt_BYPTR(pvar)
  548. *
  549. * \ingroup group__project__comstl__language_agnostic_macros
  550. *
  551. * \brief
  552. */
  553. # if defined(STLSOFT_DOCUMENTATION_SKIP_SECTION) || \
  554. !defined(COMSTL_VARIANT_UNION_ARMS_HAVE_NAMES_)
  555. # define COMSTL_ACCESS_VARIANT_vt_BYPTR(pvar) (pvar)->vt
  556. # else /* ? COMSTL_VARIANT_UNION_ARMS_HAVE_NAMES_ */
  557. # define COMSTL_ACCESS_VARIANT_vt_BYPTR(pvar) (pvar)->__VARIANT_NAME_1.__VARIANT_NAME_2.vt
  558. # endif /* COMSTL_VARIANT_UNION_ARMS_HAVE_NAMES_ */
  559. /** \def COMSTL_ACCESS_VARIANT_vt_BYREF(var)
  560. *
  561. * \ingroup group__project__comstl__language_agnostic_macros
  562. *
  563. * Used to provide access to the \c vt member of a \c VARIANT structure in
  564. * a language-independent manner
  565. *
  566. * Usage:
  567. <pre>
  568. VARIANT v;
  569. COMSTL_ACCESS_VARIANT_vt_BYREF(v) = VT_I4;
  570. </pre>
  571. */
  572. #define COMSTL_ACCESS_VARIANT_vt_BYREF(var) COMSTL_ACCESS_VARIANT_vt_BYPTR(&(var))
  573. /** \def COMSTL_ACCESS_VARIANT_decVal_BYPTR(pvar)
  574. *
  575. * \ingroup group__project__comstl__language_agnostic_macros
  576. *
  577. * \brief
  578. */
  579. # if defined(STLSOFT_DOCUMENTATION_SKIP_SECTION) || \
  580. !defined(COMSTL_VARIANT_UNION_ARMS_HAVE_NAMES_)
  581. # define COMSTL_ACCESS_VARIANT_decVal_BYPTR(pvar) (pvar)->decVal
  582. # else /* ? COMSTL_VARIANT_UNION_ARMS_HAVE_NAMES_ */
  583. # define COMSTL_ACCESS_VARIANT_decVal_BYPTR(pvar) (pvar)->__VARIANT_NAME_1.decVal
  584. # endif /* COMSTL_VARIANT_UNION_ARMS_HAVE_NAMES_ */
  585. /** \def COMSTL_ACCESS_VARIANT_decVal_BYREF(var, mem)
  586. *
  587. * \ingroup group__project__comstl__language_agnostic_macros
  588. *
  589. * \brief
  590. */
  591. #define COMSTL_ACCESS_VARIANT_decVal_BYREF(var) COMSTL_ACCESS_VARIANT_decVal_BYPTR(&(var))
  592. /* /////////////////////////////////////////////////////////////////////////
  593. * Typedefs
  594. *
  595. * The COMSTL uses a number of typedefs to aid in compiler-independence in the
  596. * libraries' main code.
  597. */
  598. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  599. typedef stlsoft_ns_qual(ss_char_a_t) cs_char_a_t; /*!< Ansi char type */
  600. typedef stlsoft_ns_qual(ss_char_w_t) cs_char_w_t; /*!< Unicode char type */
  601. typedef OLECHAR cs_char_o_t; /*!< COM char type */
  602. typedef stlsoft_ns_qual(ss_sint8_t) cs_sint8_t; /*!< 8-bit signed integer */
  603. typedef stlsoft_ns_qual(ss_uint8_t) cs_uint8_t; /*!< 8-bit unsigned integer */
  604. typedef stlsoft_ns_qual(ss_int16_t) cs_int16_t; /*!< 16-bit integer */
  605. typedef stlsoft_ns_qual(ss_sint16_t) cs_sint16_t; /*!< 16-bit signed integer */
  606. typedef stlsoft_ns_qual(ss_uint16_t) cs_uint16_t; /*!< 16-bit unsigned integer */
  607. typedef stlsoft_ns_qual(ss_int32_t) cs_int32_t; /*!< 32-bit integer */
  608. typedef stlsoft_ns_qual(ss_sint32_t) cs_sint32_t; /*!< 32-bit signed integer */
  609. typedef stlsoft_ns_qual(ss_uint32_t) cs_uint32_t; /*!< 32-bit unsigned integer */
  610. #ifdef STLSOFT_CF_64BIT_INT_SUPPORT
  611. typedef stlsoft_ns_qual(ss_int64_t) cs_int64_t; /*!< 64-bit integer */
  612. typedef stlsoft_ns_qual(ss_sint64_t) cs_sint64_t; /*!< 64-bit signed integer */
  613. typedef stlsoft_ns_qual(ss_uint64_t) cs_uint64_t; /*!< 64-bit unsigned integer */
  614. #endif /* STLSOFT_CF_64BIT_INT_SUPPORT */
  615. typedef stlsoft_ns_qual(ss_int_t) cs_int_t; /*!< integer */
  616. typedef stlsoft_ns_qual(ss_sint_t) cs_sint_t; /*!< signed integer */
  617. typedef stlsoft_ns_qual(ss_uint_t) cs_uint_t; /*!< unsigned integer */
  618. typedef stlsoft_ns_qual(ss_long_t) cs_long_t; /*!< long */
  619. #if defined(__cplusplus)
  620. typedef stlsoft_ns_qual(ss_bool_t) cs_bool_t; /*!< bool */
  621. #endif /* __cplusplus */
  622. typedef DWORD cs_dword_t; /*!< dword */
  623. typedef stlsoft_ns_qual(ss_size_t) cs_size_t; /*!< size */
  624. typedef stlsoft_ns_qual(ss_ptrdiff_t) cs_ptrdiff_t; /*!< ptr diff */
  625. typedef stlsoft_ns_qual(ss_streampos_t) cs_streampos_t; /*!< streampos */
  626. typedef stlsoft_ns_qual(ss_streamoff_t) cs_streamoff_t; /*!< streamoff */
  627. #ifdef _WIN64
  628. typedef stlsoft_ns_qual(ss_sint64_t) cs_sptrint_t;
  629. typedef stlsoft_ns_qual(ss_uint64_t) cs_uptrint_t;
  630. #else /* ? _WIN64 */
  631. typedef stlsoft_ns_qual(ss_sint32_t) cs_sptrint_t;
  632. typedef stlsoft_ns_qual(ss_uint32_t) cs_uptrint_t;
  633. #endif /* _WIN64 */
  634. #ifndef _STLSOFT_NO_NAMESPACE
  635. typedef cs_char_a_t char_a_t; /*!< Ansi char type */
  636. typedef cs_char_w_t char_w_t; /*!< Unicode char type */
  637. typedef cs_char_o_t char_o_t; /*!< COM char type */
  638. typedef cs_sint8_t sint8_t; /*!< 8-bit signed integer */
  639. typedef cs_uint8_t uint8_t; /*!< 8-bit unsigned integer */
  640. typedef cs_int16_t int16_t; /*!< 16-bit integer */
  641. typedef cs_sint16_t sint16_t; /*!< 16-bit signed integer */
  642. typedef cs_uint16_t uint16_t; /*!< 16-bit unsigned integer */
  643. typedef cs_int32_t int32_t; /*!< 32-bit integer */
  644. typedef cs_sint32_t sint32_t; /*!< 32-bit signed integer */
  645. typedef cs_uint32_t uint32_t; /*!< 32-bit unsigned integer */
  646. # ifdef STLSOFT_CF_64BIT_INT_SUPPORT
  647. typedef cs_int64_t int64_t; /*!< 64-bit integer */
  648. typedef cs_sint64_t sint64_t; /*!< 64-bit signed integer */
  649. typedef cs_uint64_t uint64_t; /*!< 64-bit unsigned integer */
  650. # endif /* STLSOFT_CF_64BIT_INT_SUPPORT */
  651. typedef cs_int_t int_t; /*!< integer */
  652. typedef cs_sint_t sint_t; /*!< signed integer */
  653. typedef cs_uint_t uint_t; /*!< unsigned integer */
  654. typedef cs_long_t long_t; /*!< long integer */
  655. #if defined(__cplusplus)
  656. typedef cs_bool_t bool_t; /*!< bool */
  657. #endif /* __cplusplus */
  658. # if !defined(STLSOFT_COMPILER_IS_DMC)
  659. typedef cs_dword_t dword_t; /*!< dword */
  660. typedef cs_streampos_t streampos_t; /*!< streampos */
  661. typedef cs_streamoff_t streamoff_t; /*!< streamoff */
  662. # endif /* compiler */
  663. typedef cs_sptrint_t sptrint_t;
  664. typedef cs_uptrint_t uptrint_t;
  665. #endif /* !_STLSOFT_NO_NAMESPACE */
  666. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  667. /* /////////////////////////////////////////////////////////////////////////
  668. * Values
  669. *
  670. * Since the boolean type may not be supported natively on all compilers, the
  671. * values of true and false may also not be provided. Hence the values of
  672. * cs_true_v and cs_false_v are defined, and are used in all code.
  673. */
  674. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  675. #define cs_true_v ss_true_v
  676. #define cs_false_v ss_false_v
  677. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  678. /* /////////////////////////////////////////////////////////////////////////
  679. * Constants
  680. */
  681. #ifdef __cplusplus
  682. const cs_size_t COMSTL_CCH_GUID = 38;
  683. #else /* ? __cplusplus */
  684. # define COMSTL_CCH_GUID (38u)
  685. #endif /* __cplusplus */
  686. /* /////////////////////////////////////////////////////////////////////////
  687. * Code modification macros
  688. */
  689. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  690. /* Exception signatures. */
  691. #define comstl_throw_0() stlsoft_throw_0()
  692. #define comstl_throw_1(x1) stlsoft_throw_1(x1)
  693. #define comstl_throw_2(x1, x2) stlsoft_throw_2(x1, x2)
  694. #define comstl_throw_3(x1, x2, x3) stlsoft_throw_3(x1, x2, x3)
  695. #define comstl_throw_4(x1, x2, x3, x4) stlsoft_throw_4(x1, x2, x3, x4)
  696. #define comstl_throw_5(x1, x2, x3, x4, x5) stlsoft_throw_5(x1, x2, x3, x4, x5)
  697. #define comstl_throw_6(x1, x2, x3, x4, x5, x6) stlsoft_throw_6(x1, x2, x3, x4, x5, x6)
  698. #define comstl_throw_7(x1, x2, x3, x4, x5, x6, x7) stlsoft_throw_7(x1, x2, x3, x4, x5, x6, x7)
  699. #define comstl_throw_8(x1, x2, x3, x4, x5, x6, x7, x8) stlsoft_throw_8(x1, x2, x3, x4, x5, x6, x7, x8)
  700. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  701. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  702. # define COMSTL_NUM_ELEMENTS(ar) STLSOFT_NUM_ELEMENTS(ar)
  703. # define comstl_num_elements(ar) COMSTL_NUM_ELEMENTS(ar)
  704. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  705. /** \brief [DEPRECATED] Destroys the given instance \c p of the given type (\c t and \c _type)
  706. *
  707. * \deprecated This is <b>heavily</b> deprecated in favour of \ref STLSOFT_DESTROY_INSTANCE().
  708. */
  709. #define comstl_destroy_instance(t, _type, p) STLSOFT_DESTROY_INSTANCE(t, _type, p)
  710. /** \brief [DEPRECATED] Generates an opaque type with the name \c _htype
  711. *
  712. * \deprecated This is <b>heavily</b> deprecated in favour of \ref STLSOFT_GEN_OPAQUE().
  713. */
  714. #define comstl_gen_opaque(_htype) STLSOFT_GEN_OPAQUE(_htype)
  715. /* ////////////////////////////////////////////////////////////////////// */
  716. #ifndef _COMSTL_NO_NAMESPACE
  717. # if defined(_STLSOFT_NO_NAMESPACE) || \
  718. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  719. } /* namespace comstl */
  720. # else
  721. } /* namespace comstl_project */
  722. } /* namespace stlsoft */
  723. namespace comstl = ::stlsoft::comstl_project;
  724. # endif /* _STLSOFT_NO_NAMESPACE */
  725. #endif /* !_COMSTL_NO_NAMESPACE */
  726. /* /////////////////////////////////////////////////////////////////////////
  727. * Inclusion
  728. */
  729. #ifdef STLSOFT_CF_PRAGMA_ONCE_SUPPORT
  730. # pragma once
  731. #endif /* STLSOFT_CF_PRAGMA_ONCE_SUPPORT */
  732. /* ////////////////////////////////////////////////////////////////////// */
  733. #endif /* COMSTL_INCL_COMSTL_H_COMSTL */
  734. /* ///////////////////////////// end of file //////////////////////////// */