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.

421 lines
17 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: dotnetstl/dotnetstl.hpp
  3. *
  4. * Purpose: Root header for the .netSTL libraries. Performs various compiler
  5. * and platform discriminations, and definitions of types.
  6. *
  7. * Created: 12th May 2003
  8. * Updated: 2nd March 2012
  9. *
  10. * Home: http://stlsoft.org/
  11. *
  12. * Copyright (c) 2003-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 DOTNETSTL_INCL_DOTNETSTL_HPP_DOTNETSTL
  41. #define DOTNETSTL_INCL_DOTNETSTL_HPP_DOTNETSTL
  42. #define DOTNETSTL_INCL_H_DOTNETSTL
  43. /* File version */
  44. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  45. # define DOTNETSTL_VER_DOTNETSTL_HPP_DOTNETSTL_MAJOR 3
  46. # define DOTNETSTL_VER_DOTNETSTL_HPP_DOTNETSTL_MINOR 5
  47. # define DOTNETSTL_VER_DOTNETSTL_HPP_DOTNETSTL_REVISION 1
  48. # define DOTNETSTL_VER_DOTNETSTL_HPP_DOTNETSTL_EDIT 51
  49. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  50. /** \file dotnetstl/dotnetstl.hpp
  51. *
  52. * \brief [C++ only; requires C++.NET compiler] The root header for the \ref group__project__dotnetstl ".netSTL" project.
  53. */
  54. /* /////////////////////////////////////////////////////////////////////////
  55. * .netSTL version
  56. *
  57. * The libraries version information is comprised of major, minor and revision
  58. * components.
  59. *
  60. * The major version is denoted by the DOTNETSTL_VER_MAJOR preprocessor symbol.
  61. * A changes to the major version component implies that a dramatic change has
  62. * occurred in the libraries, such that considerable changes to source dependent
  63. * on previous versions would need to be effected.
  64. *
  65. * The minor version is denoted by the DOTNETSTL_VER_MINOR preprocessor symbol.
  66. * Changes to the minor version component imply that a significant change has
  67. * occurred to the libraries, either in the addition of new functionality or in
  68. * the destructive change to one or more components such that recomplilation and
  69. * code change may be necessitated.
  70. *
  71. * The revision version is denoted by the DOTNETSTL_VER_REVISION preprocessor
  72. * symbol. Changes to the revision version component imply that a bug has been
  73. * fixed. Dependent code should be recompiled in order to pick up the changes.
  74. *
  75. * In addition to the individual version symbols - DOTNETSTL_VER_MAJOR,
  76. * DOTNETSTL_VER_MINOR and DOTNETSTL_VER_REVISION - a composite symbol DOTNETSTL_VER
  77. * is defined, where the upper 8 bits are 0, bits 16-23 represent the major
  78. * component, bits 8-15 represent the minor component, and bits 0-7 represent
  79. * the revision component.
  80. *
  81. * Each release of the libraries will bear a different version, and that version
  82. * will also have its own symbol: Version 1.0.1 specifies DOTNETSTL_VER_1_0_1.
  83. *
  84. * Thus the symbol DOTNETSTL_VER may be compared meaningfully with a specific
  85. * version symbol, e.g. #if DOTNETSTL_VER >= DOTNETSTL_VER_1_0_1
  86. */
  87. /** \def DOTNETSTL_VER_MAJOR
  88. * The major version number of .netSTL
  89. */
  90. /** \def DOTNETSTL_VER_MINOR
  91. * The minor version number of .netSTL
  92. */
  93. /** \def DOTNETSTL_VER_REVISION
  94. * The revision version number of .netSTL
  95. */
  96. /** \def DOTNETSTL_VER
  97. * The current composite version number of .netSTL
  98. */
  99. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  100. # define DOTNETSTL_VER_1_0_1 0x00010001 /*!< Version 1.0.1 */
  101. # define DOTNETSTL_VER_1_1_1 0x00010101 /*!< Version 1.1.1 */
  102. # define DOTNETSTL_VER_1_1_2 0x00010102 /*!< Version 1.1.2 */
  103. # define DOTNETSTL_VER_1_2_1 0x00010201 /*!< Version 1.2.1 */
  104. # define DOTNETSTL_VER_1_2_2 0x00010202 /*!< Version 1.2.2 */
  105. # define DOTNETSTL_VER_1_2_3 0x00010203 /*!< Version 1.2.3 */
  106. # define DOTNETSTL_VER_1_3_1 0x00010301 /*!< Version 1.3.1 (with STLSoft 1.9.1) */
  107. # define DOTNETSTL_VER_1_3_2 0x00010302 /*!< Version 1.3.2 (with STLSoft 1.9.25) */
  108. # define DOTNETSTL_VER_1_3_3 0x010303ff /*!< Version 1.3.3 (with STLSoft 1.9.113) */
  109. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  110. #define DOTNETSTL_VER_MAJOR 1
  111. #define DOTNETSTL_VER_MINOR 3
  112. #define DOTNETSTL_VER_REVISION 3
  113. #define DOTNETSTL_VER DOTNETSTL_VER_1_3_3
  114. /* /////////////////////////////////////////////////////////////////////////
  115. * Includes
  116. */
  117. #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
  118. # include <stlsoft/stlsoft.h>
  119. #endif /* !STLSOFT_INCL_STLSOFT_H_STLSOFT */
  120. /* /////////////////////////////////////////////////////////////////////////
  121. * STLSoft version compatibility
  122. */
  123. #if !defined(_STLSOFT_VER) || \
  124. _STLSOFT_VER < 0x010971ff
  125. # error This version of the .netSTL libraries requires STLSoft version 1.9.113, or later
  126. #endif /* _STLSOFT_VER */
  127. /* /////////////////////////////////////////////////////////////////////////
  128. * Compiler compatibility
  129. *
  130. * Currently the only compilers supported by the .netSTL libraries are
  131. *
  132. * Borland C++ 5.5, 5.51, 5.6
  133. * Digital Mars C/C++ 8.26 - 8.32
  134. * Metrowerks 2.4 & 3.0 (CodeWarrior 7.0 & 8.0)
  135. * Intel C/C++ 6.0
  136. * Visual C++ 5.0, 6.0, 7.0
  137. */
  138. #if defined(STLSOFT_COMPILER_IS_MSVC)
  139. /* Visual C++ */
  140. # if _MSC_VER < 1300
  141. # error Versions of Visual C++ prior to 7.0 are not supported by the .netSTL libraries
  142. # endif /* compiler */
  143. #else /* ? compiler */
  144. /* No recognised compiler */
  145. # ifdef _STLSOFT_FORCE_ANY_COMPILER
  146. # define DOTNETSTL_COMPILER_IS_UNKNOWN
  147. # ifdef STLSOFT_COMPILE_VERBOSE
  148. # pragma message("Compiler is unknown to .netSTL")
  149. # endif /* STLSOFT_COMPILE_VERBOSE */
  150. # else /* ? _STLSOFT_FORCE_ANY_COMPILER */
  151. # error Currently only Visual C++ compilers are supported by the .netSTL libraries
  152. # endif /* _STLSOFT_FORCE_ANY_COMPILER */
  153. #endif /* compiler */
  154. /* /////////////////////////////////////////////////////////////////////////
  155. * More includes
  156. */
  157. //#if _MSC_VER >= 1300
  158. # using <mscorlib.dll>
  159. //#else /* ? _MSC_VER */
  160. //# using <system.dll>
  161. //#endif /* _MSC_VER */
  162. /* /////////////////////////////////////////////////////////////////////////
  163. * Contract Enforcement
  164. *
  165. * The macro dotnetstl_assert provides standard debug-mode assert functionality.
  166. */
  167. /** \brief Defines a runtime assertion
  168. *
  169. * \ingroup group__library__macros__assertion
  170. *
  171. * \param expr Must be non-zero, or an assertion will be fired
  172. */
  173. #define DOTNETSTL_ASSERT(expr) STLSOFT_ASSERT(expr)
  174. /** \brief Defines a runtime assertion, with message
  175. *
  176. * \ingroup group__library__macros__assertion
  177. *
  178. * \param expr Must be non-zero, or an assertion will be fired
  179. * \param msg The literal character string message to be included in the assertion
  180. */
  181. #define DOTNETSTL_MESSAGE_ASSERT(msg, expr) STLSOFT_MESSAGE_ASSERT(msg, expr)
  182. /** \brief Defines a compile-time assertion
  183. *
  184. * \ingroup group__library__macros__assertion
  185. *
  186. * \param expr Must be non-zero, or compilation will fail
  187. */
  188. #define DOTNETSTL_STATIC_ASSERT(expr) STLSOFT_STATIC_ASSERT(expr)
  189. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  190. # define dotnetstl_assert(expr) DOTNETSTL_ASSERT(expr)
  191. # define dotnetstl_message_assert(msg, expr) DOTNETSTL_MESSAGE_ASSERT(msg, expr)
  192. # define dotnetstl_static_assert(expr) DOTNETSTL_STATIC_ASSERT(expr)
  193. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  194. /* /////////////////////////////////////////////////////////////////////////
  195. * Namespace
  196. *
  197. * The .netSTL components are contained within the dotnetstl namespace. This is
  198. * usually an alias for stlsoft::dotnetstl_project,
  199. *
  200. * When compilers support namespaces they are defined by default. They can be
  201. * undefined using a cascasing system, as follows:
  202. *
  203. * DOTNETSTL_NO_NAMESPACES may not be defined.
  204. *
  205. * If _STLSOFT_NO_NAMESPACE is defined (whence the namespace stlsoft does not
  206. * exist), then the .netSTL constructs are defined within the dotnetstl
  207. * namespace. The definition matrix is as follows:
  208. *
  209. * _STLSOFT_NO_NAMESPACE dotnetstl definition
  210. * --------------------- -----------------
  211. * not defined = stlsoft::dotnetstl_project
  212. * defined dotnetstl
  213. *
  214. * The macro dotnetstl_ns_qual() macro can be used to refer to elements in the
  215. * .netSTL libraries irrespective of whether they are in the
  216. * stlsoft::dotnetstl_project or dotnetstl namespaces.
  217. *
  218. * Furthermore, some compilers do not support the standard library in the std
  219. * namespace, so the dotnetstl_ns_qual_std() macro can be used to refer to elements
  220. * in the .netSTL libraries irrespective of whether they are in the std namespace
  221. * or in the global namespace.
  222. */
  223. /* Cannot define .netSTL entities within the global namespace */
  224. #if defined(DOTNETSTL_NO_NAMESPACE)
  225. # error .netSTL constructs cannot be defined to be in the global namespace
  226. #endif /* DOTNETSTL_NO_NAMESPACE */
  227. #ifdef _STLSOFT_NO_NAMESPACE
  228. /* There is no stlsoft namespace, so must define ::dotnetstl */
  229. /** \brief The dotnetstl namespace - \c dotnetstl (aliased to \c stlsoft::dotnetstl_project) - is
  230. * the namespace for the .netSTL project.
  231. */
  232. namespace dotnetstl
  233. {
  234. # else
  235. /* Define stlsoft::dotnetstl_project */
  236. namespace stlsoft
  237. {
  238. namespace dotnetstl_project
  239. {
  240. #endif /* _STLSOFT_NO_NAMESPACE */
  241. /** \def dotnetstl_ns_qual(x)
  242. * Qualifies with <b>dotnetstl::</b> if .netSTL is using namespaces or, if not, does not qualify
  243. */
  244. /** \def dotnetstl_ns_using(x)
  245. * Declares a using directive (with respect to <b>dotnetstl</b>) if .netSTL is using namespaces or, if not, does nothing
  246. */
  247. #define dotnetstl_ns_qual(x) ::dotnetstl::x
  248. #define dotnetstl_ns_using(x) using ::dotnetstl::x;
  249. /** \def dotnetstl_ns_qual_std(x)
  250. * Qualifies with <b>std::</b> if .netSTL is being translated in the context of the standard library being within the <b>std</b> namespace or, if not, does not qualify
  251. */
  252. /** \def dotnetstl_ns_using_std(x)
  253. * Declares a using directive (with respect to <b>std</b>) if .netSTL is being translated in the context of the standard library being within the <b>std</b> namespace or, if not, does nothing
  254. */
  255. #ifdef STLSOFT_CF_std_NAMESPACE
  256. # define dotnetstl_ns_qual_std(x) ::std::x
  257. # define dotnetstl_ns_using_std(x) using ::std::x;
  258. #else /* ? STLSOFT_CF_std_NAMESPACE */
  259. # define dotnetstl_ns_qual_std(x) x
  260. # define dotnetstl_ns_using_std(x)
  261. #endif /* !STLSOFT_CF_std_NAMESPACE */
  262. /* /////////////////////////////////////////////////////////////////////////
  263. * CLR / VC++ versions
  264. */
  265. #if defined(_MSC_VER) && \
  266. _MSC_VER >= 1400
  267. # define DOTNETSTL_HAT_SYNTAX_SUPPORT
  268. #else /* ? _MSC_VER */
  269. #endif /* _MSC_VER */
  270. /* /////////////////////////////////////////////////////////////////////////
  271. * Typedefs
  272. *
  273. * The .netSTL uses a number of typedefs to aid in compiler-independence in the
  274. * libraries' main code.
  275. */
  276. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  277. typedef stlsoft_ns_qual(ss_char_a_t) ds_char_a_t; //!< Ansi char type
  278. typedef stlsoft_ns_qual(ss_char_w_t) ds_char_w_t; //!< Unicode char type
  279. typedef stlsoft_ns_qual(ss_sint8_t) ds_sint8_t; //!< 8-bit signed integer
  280. typedef stlsoft_ns_qual(ss_uint8_t) ds_uint8_t; //!< 8-bit unsigned integer
  281. typedef stlsoft_ns_qual(ss_int16_t) ds_int16_t; //!< 16-bit integer
  282. typedef stlsoft_ns_qual(ss_sint16_t) ds_sint16_t; //!< 16-bit signed integer
  283. typedef stlsoft_ns_qual(ss_uint16_t) ds_uint16_t; //!< 16-bit unsigned integer
  284. typedef stlsoft_ns_qual(ss_int32_t) ds_int32_t; //!< 32-bit integer
  285. typedef stlsoft_ns_qual(ss_sint32_t) ds_sint32_t; //!< 32-bit signed integer
  286. typedef stlsoft_ns_qual(ss_uint32_t) ds_uint32_t; //!< 32-bit unsigned integer
  287. #ifdef STLSOFT_CF_64BIT_INT_SUPPORT
  288. typedef stlsoft_ns_qual(ss_int64_t) ds_int64_t; //!< 64-bit integer
  289. typedef stlsoft_ns_qual(ss_sint64_t) ds_sint64_t; //!< 64-bit signed integer
  290. typedef stlsoft_ns_qual(ss_uint64_t) ds_uint64_t; //!< 64-bit unsigned integer
  291. #endif /* STLSOFT_CF_64BIT_INT_SUPPORT */
  292. typedef stlsoft_ns_qual(ss_int_t) ds_int_t; //!< integer
  293. typedef stlsoft_ns_qual(ss_sint_t) ds_sint_t; //!< signed integer
  294. typedef stlsoft_ns_qual(ss_uint_t) ds_uint_t; //!< unsigned integer
  295. typedef stlsoft_ns_qual(ss_long_t) ds_long_t; //!< long
  296. typedef stlsoft_ns_qual(ss_bool_t) ds_bool_t; //!< bool
  297. typedef stlsoft_ns_qual(ss_size_t) ds_size_t; //!< size
  298. typedef stlsoft_ns_qual(ss_ptrdiff_t) ds_ptrdiff_t; //!< ptr diff
  299. typedef stlsoft_ns_qual(ss_streampos_t) ds_streampos_t; //!< streampos
  300. typedef stlsoft_ns_qual(ss_streamoff_t) ds_streamoff_t; //!< streamoff
  301. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  302. /* /////////////////////////////////////////////////////////////////////////
  303. * Values
  304. *
  305. * Since the boolean type may not be supported natively on all compilers, the
  306. * values of true and false may also not be provided. Hence the values of
  307. * ds_true_v and ds_false_v are defined, and are used in all code.
  308. */
  309. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  310. #define ds_true_v ss_true_v
  311. #define ds_false_v ss_false_v
  312. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  313. /* /////////////////////////////////////////////////////////////////////////
  314. * Code modification macros
  315. */
  316. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  317. /* Exception signatures. */
  318. # define dotnetstl_throw_0() stlsoft_throw_0()
  319. # define dotnetstl_throw_1(x1) stlsoft_throw_1(x1)
  320. # define dotnetstl_throw_2(x1, x2) stlsoft_throw_2(x1, x2)
  321. # define dotnetstl_throw_3(x1, x2, x3) stlsoft_throw_3(x1, x2, x3)
  322. # define dotnetstl_throw_4(x1, x2, x3, x4) stlsoft_throw_4(x1, x2, x3, x4)
  323. # define dotnetstl_throw_5(x1, x2, x3, x4, x5) stlsoft_throw_5(x1, x2, x3, x4, x5)
  324. # define dotnetstl_throw_6(x1, x2, x3, x4, x5, x6) stlsoft_throw_6(x1, x2, x3, x4, x5, x6)
  325. # define dotnetstl_throw_7(x1, x2, x3, x4, x5, x6, x7) stlsoft_throw_7(x1, x2, x3, x4, x5, x6, x7)
  326. # define dotnetstl_throw_8(x1, x2, x3, x4, x5, x6, x7, x8) stlsoft_throw_8(x1, x2, x3, x4, x5, x6, x7, x8)
  327. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  328. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  329. # define DOTNETSTL_NUM_ELEMENTS(ar) STLSOFT_NUM_ELEMENTS(ar)
  330. # define dotnetstl_num_elements(ar) DOTNETSTL_NUM_ELEMENTS(ar)
  331. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  332. /** \brief [DEPRECATED] Destroys the given instance \c p of the given type (\c t and \c _type)
  333. *
  334. * \deprecated This is <b>heavily</b> deprecated in favour of \ref STLSOFT_DESTROY_INSTANCE().
  335. */
  336. #define dotnetstl_destroy_instance(t, _type, p) STLSOFT_DESTROY_INSTANCE(t, _type, p)
  337. /** \brief [DEPRECATED] Generates an opaque type with the name \c _htype
  338. *
  339. * \deprecated This is <b>heavily</b> deprecated in favour of \ref STLSOFT_GEN_OPAQUE().
  340. */
  341. #define dotnetstl_gen_opaque(_htype) STLSOFT_GEN_OPAQUE(_htype)
  342. /* ////////////////////////////////////////////////////////////////////// */
  343. #ifndef DOTNETSTL_NO_NAMESPACE
  344. # if defined(_STLSOFT_NO_NAMESPACE) || \
  345. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  346. } // namespace dotnetstl
  347. # else
  348. } // namespace dotnetstl_project
  349. } // namespace stlsoft
  350. namespace dotnetstl = ::stlsoft::dotnetstl_project;
  351. # endif /* _STLSOFT_NO_NAMESPACE */
  352. #endif /* !DOTNETSTL_NO_NAMESPACE */
  353. /* /////////////////////////////////////////////////////////////////////////
  354. * Inclusion
  355. */
  356. #ifdef STLSOFT_CF_PRAGMA_ONCE_SUPPORT
  357. # pragma once
  358. #endif /* STLSOFT_CF_PRAGMA_ONCE_SUPPORT */
  359. /* ////////////////////////////////////////////////////////////////////// */
  360. #endif /* DOTNETSTL_INCL_DOTNETSTL_HPP_DOTNETSTL */
  361. /* ///////////////////////////// end of file //////////////////////////// */