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.

703 lines
28 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: unixstl/unixstl.h
  3. *
  4. * Purpose: Root header for the UNIXSTL 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 UNIXSTL_INCL_UNIXSTL_H_UNIXSTL
  41. #define UNIXSTL_INCL_UNIXSTL_H_UNIXSTL
  42. #define UNIXSTL_INCL_H_UNIXSTL
  43. /* File version */
  44. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  45. # define UNIXSTL_VER_UNIXSTL_H_UNIXSTL_MAJOR 3
  46. # define UNIXSTL_VER_UNIXSTL_H_UNIXSTL_MINOR 8
  47. # define UNIXSTL_VER_UNIXSTL_H_UNIXSTL_REVISION 1
  48. # define UNIXSTL_VER_UNIXSTL_H_UNIXSTL_EDIT 91
  49. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  50. /** \file unixstl/unixstl.h \brief [C, C++] The root header for the \ref group__project__unixstl "UNIXSTL" project. */
  51. /* /////////////////////////////////////////////////////////////////////////
  52. * UNIXSTL version
  53. *
  54. * The libraries version information is comprised of major, minor and revision
  55. * components.
  56. *
  57. * The major version is denoted by the _UNIXSTL_VER_MAJOR preprocessor symbol.
  58. * A changes to the major version component implies that a dramatic change has
  59. * occurred in the libraries, such that considerable changes to source dependent
  60. * on previous versions would need to be effected.
  61. *
  62. * The minor version is denoted by the _UNIXSTL_VER_MINOR preprocessor symbol.
  63. * Changes to the minor version component imply that a significant change has
  64. * occurred to the libraries, either in the addition of new functionality or in
  65. * the destructive change to one or more components such that recomplilation and
  66. * code change may be necessitated.
  67. *
  68. * The revision version is denoted by the _UNIXSTL_VER_REVISION preprocessor
  69. * symbol. Changes to the revision version component imply that a bug has been
  70. * fixed. Dependent code should be recompiled in order to pick up the changes.
  71. *
  72. * In addition to the individual version symbols - _UNIXSTL_VER_MAJOR,
  73. * _UNIXSTL_VER_MINOR and _UNIXSTL_VER_REVISION - a composite symbol _UNIXSTL_VER
  74. * is defined, where the upper 8 bits are 0, bits 16-23 represent the major
  75. * component, bits 8-15 represent the minor component, and bits 0-7 represent
  76. * the revision component.
  77. *
  78. * Each release of the libraries will bear a different version, and that version
  79. * will also have its own symbol: Version 1.0.1 specifies _UNIXSTL_VER_1_0_1.
  80. *
  81. * Thus the symbol _UNIXSTL_VER may be compared meaningfully with a specific
  82. * version symbol, e.g.# if _UNIXSTL_VER >= _UNIXSTL_VER_1_0_1
  83. */
  84. /** \def _UNIXSTL_VER_MAJOR
  85. * The major version number of UNIXSTL
  86. */
  87. /** \def _UNIXSTL_VER_MINOR
  88. * The minor version number of UNIXSTL
  89. */
  90. /** \def _UNIXSTL_VER_REVISION
  91. * The revision version number of UNIXSTL
  92. */
  93. /** \def _UNIXSTL_VER
  94. * The current composite version number of UNIXSTL
  95. */
  96. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  97. # define _UNIXSTL_VER_0_9_1 0x00000901 /*!< Version 0.9.1 */
  98. # define _UNIXSTL_VER_0_9_2 0x00000902 /*!< Version 0.9.2 */
  99. # define _UNIXSTL_VER_1_0_1 0x00010001 /*!< Version 1.0.1 */
  100. # define _UNIXSTL_VER_1_0_2 0x00010002 /*!< Version 1.0.2 */
  101. # define _UNIXSTL_VER_1_0_3 0x00010003 /*!< Version 1.0.3 */
  102. # define _UNIXSTL_VER_1_1_1 0x00010101 /*!< Version 1.1.1 */
  103. # define _UNIXSTL_VER_1_2_1 0x00010201 /*!< Version 1.2.1 */
  104. # define _UNIXSTL_VER_1_3_1 0x00010301 /*!< Version 1.3.1 */
  105. # define _UNIXSTL_VER_1_4_1 0x00010401 /*!< Version 1.4.1 */
  106. # define _UNIXSTL_VER_1_5_1 0x00010501 /*!< Version 1.5.1 */
  107. # define _UNIXSTL_VER_1_6_1 0x00010601 /*!< Version 1.6.1 (with STLSoft 1.9.1) */
  108. # define _UNIXSTL_VER_1_6_2 0x00010602 /*!< Version 1.6.2 (with STLSoft 1.9.7) */
  109. # define _UNIXSTL_VER_1_6_3 0x00010603 /*!< Version 1.6.3 (with STLSoft 1.9.9) */
  110. # define _UNIXSTL_VER_1_6_4 0x00010604 /*!< Version 1.6.4 (with STLSoft 1.9.17) */
  111. # define _UNIXSTL_VER_1_6_5 0x00010605 /*!< Version 1.6.5 (with STLSoft 1.9.25) */
  112. # define _UNIXSTL_VER_1_6_6 0x00010606 /*!< Version 1.6.6 (with STLSoft 1.9.29) */
  113. # define _UNIXSTL_VER_1_6_7 0x010607ff /*!< Version 1.6.7 (with STLSoft 1.9.31) */
  114. # define _UNIXSTL_VER_1_6_8 0x010608ff /*!< Version 1.6.8 (with STLSoft 1.9.32) */
  115. # define _UNIXSTL_VER_1_7_1 0x010701ff /*!< Version 1.7.1 (with STLSoft 1.9.33) */
  116. # define _UNIXSTL_VER_1_7_2 0x010702ff /*!< Version 1.7.2 (with STLSoft 1.9.37) */
  117. # define _UNIXSTL_VER_1_7_3 0x010703ff /*!< Version 1.7.3 (with STLSoft 1.9.92) */
  118. # define _UNIXSTL_VER_1_7_4 0x010704ff /*!< Version 1.7.4 (with STLSoft 1.9.108) */
  119. # define _UNIXSTL_VER_1_7_5 0x010705ff /*!< Version 1.7.5 (with STLSoft 1.9.113) */
  120. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  121. #define _UNIXSTL_VER_MAJOR 1
  122. #define _UNIXSTL_VER_MINOR 7
  123. #define _UNIXSTL_VER_REVISION 5
  124. #define _UNIXSTL_VER _UNIXSTL_VER_1_7_5
  125. /* /////////////////////////////////////////////////////////////////////////
  126. * Includes
  127. */
  128. #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
  129. # include <stlsoft/stlsoft.h>
  130. #endif /* !STLSOFT_INCL_STLSOFT_H_STLSOFT */
  131. /* /////////////////////////////////////////////////////////////////////////
  132. * STLSoft version compatibility
  133. */
  134. #if !defined(_STLSOFT_VER) || \
  135. _STLSOFT_VER < 0x010971ff
  136. # error This version of the UNIXSTL libraries requires STLSoft version 1.9.113, or later
  137. #endif /* _STLSOFT_VER */
  138. /* /////////////////////////////////////////////////////////////////////////
  139. * Compiler compatibility
  140. *
  141. * Currently the only compilers supported by the UNIXSTL libraries are
  142. *
  143. * GCC version 2.95 or later
  144. * Intel C/C++ 6.0 or later
  145. * Sun Pro C & Sun Pro C++ versions 5.9.x or later
  146. */
  147. #if defined(STLSOFT_COMPILER_IS_COMO)
  148. /* ******************************* Comeau ****************************** */
  149. # if __COMO_VERSION__ < 4300
  150. # error Versions of Comeau C++ prior to 4.3.0.1 are not supported by the UNIXSTL libraries
  151. # endif /* __COMO_VERSION__ */
  152. #elif defined(STLSOFT_COMPILER_IS_GCC)
  153. /* ******************************** GCC ******************************** */
  154. # if __GNUC__ < 2 || \
  155. ( __GNUC__ == 2 && \
  156. __GNUC_MINOR__ < 95)
  157. # error Versions of GNU C/C++ prior to 2.95 are not supported by the UNIXSTL libraries
  158. # endif /* __GNUC__ */
  159. #elif defined(STLSOFT_COMPILER_IS_INTEL)
  160. /* ******************************* Intel ******************************* */
  161. # if (__INTEL_COMPILER < 700)
  162. # error Versions of Intel C++ prior to 7.0 are not supported by the UNIXSTL libraries
  163. # endif /* __INTEL_COMPILER */
  164. #elif defined(STLSOFT_COMPILER_IS_SUNPRO)
  165. /* ******************************* Sun Pro ***************************** */
  166. # ifdef __cplusplus
  167. # if ((__SUNPRO_CC & 0xFFF0) < 0x0590)
  168. # error Versions of Sun Pro C++ prior to 5.9 are not supported by the UNIXSTL libraries
  169. # endif /* __SUNPRO_CC */
  170. # else /* ? __cplusplus */
  171. # if ((__SUNPRO_C & 0xFFF0) < 0x0590)
  172. # error Versions of Sun Pro C prior to 5.9 are not supported by the UNIXSTL libraries
  173. # endif /* __SUNPRO_CC */
  174. # endif /* __cplusplus */
  175. #else
  176. /* No recognised compiler */
  177. # ifdef _STLSOFT_FORCE_ANY_COMPILER
  178. # define _UNIXSTL_COMPILER_IS_UNKNOWN
  179. # ifdef STLSOFT_COMPILE_VERBOSE
  180. # pragma message("Compiler is unknown to UNIXSTL")
  181. # endif /* STLSOFT_COMPILE_VERBOSE */
  182. # else
  183. # error Currently only the Comeau, GCC, Intel and Sun Pro C/C++ compilers are supported by the UNIXSTL libraries. To use other, possibly untested, compilers, define _STLSOFT_FORCE_ANY_COMPILER
  184. # endif /* _STLSOFT_FORCE_ANY_COMPILER */
  185. #endif /* compiler */
  186. /* /////////////////////////////////////////////////////////////////////////
  187. * Architecture
  188. *
  189. * The UNIX architecture.
  190. */
  191. #ifdef UNIXSTL_ARCH_IS_X86
  192. # undef UNIXSTL_ARCH_IS_X86
  193. #endif /* UNIXSTL_ARCH_IS_X86 */
  194. #ifdef UNIXSTL_ARCH_IS_IA64
  195. # undef UNIXSTL_ARCH_IS_IA64
  196. #endif /* UNIXSTL_ARCH_IS_IA64 */
  197. #ifdef UNIXSTL_ARCH_IS_X64
  198. # undef UNIXSTL_ARCH_IS_X64
  199. #endif /* UNIXSTL_ARCH_IS_X64 */
  200. #ifdef UNIXSTL_ARCH_IS_INTEL
  201. # undef UNIXSTL_ARCH_IS_INTEL
  202. #endif /* UNIXSTL_ARCH_IS_INTEL */
  203. #ifdef UNIXSTL_ARCH_IS_POWERPC
  204. # undef UNIXSTL_ARCH_IS_POWERPC
  205. #endif /* UNIXSTL_ARCH_IS_POWERPC */
  206. #ifdef UNIXSTL_ARCH_IS_ALPHA
  207. # undef UNIXSTL_ARCH_IS_ALPHA
  208. #endif /* UNIXSTL_ARCH_IS_ALPHA */
  209. #ifdef UNIXSTL_ARCH_IS_HPPA
  210. # undef UNIXSTL_ARCH_IS_HPPA
  211. #endif /* UNIXSTL_ARCH_IS_HPPA */
  212. #ifdef UNIXSTL_ARCH_IS_SPARC
  213. # undef UNIXSTL_ARCH_IS_SPARC
  214. #endif /* UNIXSTL_ARCH_IS_SPARC */
  215. #ifdef UNIXSTL_ARCH_IS_UNKNOWN
  216. # undef UNIXSTL_ARCH_IS_UNKNOWN
  217. #endif /* UNIXSTL_ARCH_IS_UNKNOWN */
  218. #if defined(__amd64__) || \
  219. defined(__amd64) || \
  220. defined(_AMD64_) || \
  221. defined(_M_AMD64) || \
  222. defined(_M_X64)
  223. # define UNIXSTL_ARCH_IS_INTEL
  224. # define UNIXSTL_ARCH_IS_X64
  225. #elif defined(__ia64__) || \
  226. defined(__ia64) || \
  227. defined(_IA64_) || \
  228. defined(_M_IA64)
  229. # define UNIXSTL_ARCH_IS_INTEL
  230. # define UNIXSTL_ARCH_IS_IA64
  231. #elif defined(__i386__) || \
  232. defined(__i386) || \
  233. defined(_X86_) || \
  234. defined(_M_IX86)
  235. # define UNIXSTL_ARCH_IS_INTEL
  236. # define UNIXSTL_ARCH_IS_X86
  237. #elif defined(__alpha__) || \
  238. defined(__alpha) || \
  239. defined(_M_ALPHA)
  240. # define UNIXSTL_ARCH_IS_ALPHA
  241. #elif defined(__hppa__) || \
  242. defined(__hppa)
  243. # define UNIXSTL_ARCH_IS_HPPA
  244. #elif defined(__ppc__) || \
  245. defined(__ppc) || \
  246. defined(__POWERPC__) || \
  247. defined(_POWER) || \
  248. defined(_M_PPC)
  249. # define UNIXSTL_ARCH_IS_POWERPC
  250. #elif defined(__sparc__) || \
  251. defined(__sparc)
  252. /* TODO: Separate out arch-family and archs (incl. Sparc32 and Sparc64) */
  253. # define UNIXSTL_ARCH_IS_SPARC
  254. #else /* ? arch */
  255. # define UNIXSTL_ARCH_IS_UNKNOWN
  256. #endif /* ? arch */
  257. /* /////////////////////////////////////////////////////////////////////////
  258. * Operating system family
  259. *
  260. * In some circumstances more than one of these may be defined.
  261. *
  262. * Some of this os-discrimination is provided by SourceForge (http://predef.sourceforge.net/preos.html)
  263. */
  264. #ifdef UNIXSTL_OSFAMILY_IS_BSD
  265. # undef UNIXSTL_OSFAMILY_IS_BSD
  266. #endif /* UNIXSTL_OSFAMILY_IS_BSD */
  267. #ifdef UNIXSTL_OSFAMILY_IS_SVR4
  268. # undef UNIXSTL_OSFAMILY_IS_SVR4
  269. #endif /* UNIXSTL_OSFAMILY_IS_SVR4 */
  270. #if defined(__FreeBSD__) || \
  271. defined(__NetBSD__) || \
  272. defined(__OpenBSD__) || \
  273. defined(__bsdi__) || \
  274. defined(_SYSTYPE_BSD)
  275. # define UNIXSTL_OSFAMILY_IS_BSD
  276. #endif /* bsd */
  277. #if defined(__sysv__) || \
  278. defined(__SVR4) || \
  279. defined(__svr4__) || \
  280. defined(_SYSTYPE_SVR4)
  281. # define UNIXSTL_OSFAMILY_IS_SVR4
  282. #endif /* SVR4 */
  283. /* /////////////////////////////////////////////////////////////////////////
  284. * Operating system
  285. *
  286. * The UNIX operating system.
  287. *
  288. * Some of this os-discrimination is provided by SourceForge (http://predef.sourceforge.net/preos.html)
  289. */
  290. #ifdef UNIXSTL_OS_IS_APPLE
  291. # undef UNIXSTL_OS_IS_APPLE
  292. #endif /* UNIXSTL_OS_IS_APPLE */
  293. #ifdef UNIXSTL_OS_IS_AIX
  294. # undef UNIXSTL_OS_IS_AIX
  295. #endif /* UNIXSTL_OS_IS_AIX */
  296. #ifdef UNIXSTL_OS_IS_FREEBSD
  297. # undef UNIXSTL_OS_IS_FREEBSD
  298. #endif /* UNIXSTL_OS_IS_FREEBSD */
  299. #ifdef UNIXSTL_OS_IS_HPUX
  300. # undef UNIXSTL_OS_IS_HPUX
  301. #endif /* UNIXSTL_OS_IS_HPUX */
  302. #ifdef UNIXSTL_OS_IS_LINUX
  303. # undef UNIXSTL_OS_IS_LINUX
  304. #endif /* UNIXSTL_OS_IS_LINUX */
  305. #ifdef UNIXSTL_OS_IS_MACOSX
  306. # undef UNIXSTL_OS_IS_MACOSX
  307. #endif /* UNIXSTL_OS_IS_MACOSX */
  308. #ifdef UNIXSTL_OS_IS_NETBSD
  309. # undef UNIXSTL_OS_IS_NETBSD
  310. #endif /* UNIXSTL_OS_IS_NETBSD */
  311. #ifdef UNIXSTL_OS_IS_OPENBSD
  312. # undef UNIXSTL_OS_IS_OPENBSD
  313. #endif /* UNIXSTL_OS_IS_OPENBSD */
  314. #ifdef UNIXSTL_OS_IS_SOLARIS
  315. # undef UNIXSTL_OS_IS_SOLARIS
  316. #endif /* UNIXSTL_OS_IS_SOLARIS */
  317. #ifdef UNIXSTL_OS_IS_FREEBSD
  318. # undef UNIXSTL_OS_IS_FREEBSD
  319. #endif /* UNIXSTL_OS_IS_FREEBSD */
  320. #ifdef UNIXSTL_OS_IS_UNKNOWN
  321. # undef UNIXSTL_OS_IS_UNKNOWN
  322. #endif /* UNIXSTL_OS_IS_UNKNOWN */
  323. #if defined(__APPLE__) || \
  324. defined(__MACOSX__)
  325. # define UNIXSTL_OS_IS_APPLE
  326. # define UNIXSTL_OS_IS_MACOSX
  327. #elif defined(_AIX)
  328. # define UNIXSTL_OS_IS_AIX
  329. #elif defined(__FreeBSD__)
  330. # define UNIXSTL_OS_IS_FREEBSD
  331. #elif defined(hpux) || \
  332. defined(_hpux)
  333. # define UNIXSTL_OS_IS_HPUX
  334. #elif defined(__linux__) || \
  335. defined(__linux) || \
  336. defined(linux)
  337. # define UNIXSTL_OS_IS_LINUX
  338. #elif defined(__NetBSD__)
  339. # define UNIXSTL_OS_IS_NETBSD
  340. #elif defined(__OpenBSD__)
  341. # define UNIXSTL_OS_IS_OPENBSD
  342. #elif defined(sun) || \
  343. defined(__sun)
  344. # if defined(UNIXSTL_OSFAMILY_IS_SVR4)
  345. # define UNIXSTL_OS_IS_SOLARIS
  346. # else /* ? UNIXSTL_OSFAMILY_IS_SVR4 */
  347. # define UNIXSTL_OS_IS_SUNOS
  348. # endif /* UNIXSTL_OSFAMILY_IS_SVR4 */
  349. #else /* ? operating system */
  350. # define UNIXSTL_OS_IS_UNKNOWN
  351. #endif /* ? operating system */
  352. /* /////////////////////////////////////////////////////////////////////////
  353. * Contract Enforcement
  354. *
  355. * The macro unixstl_assert provides standard debug-mode assert functionality.
  356. */
  357. /** \brief Defines a runtime assertion
  358. *
  359. * \ingroup group__library__macros__assertion
  360. *
  361. * \param expr Must be non-zero, or an assertion will be fired
  362. */
  363. #if defined(UNIXSTL_OS_IS_MACOSX) && \
  364. defined(__assert)
  365. # define UNIXSTL_ASSERT(expr) ((void)((expr) ? 0 : (__assert(#expr, __FILE__, __LINE__), 0)))
  366. #else /* ? UNIXSTL_OS_IS_MACOSX */
  367. # define UNIXSTL_ASSERT(expr) STLSOFT_ASSERT(expr)
  368. #endif /* UNIXSTL_OS_IS_MACOSX */
  369. /** \brief Defines a runtime assertion, with message
  370. *
  371. * \ingroup group__library__macros__assertion
  372. *
  373. * \param expr Must be non-zero, or an assertion will be fired
  374. * \param msg The literal character string message to be included in the assertion
  375. */
  376. #define UNIXSTL_MESSAGE_ASSERT(msg, expr) STLSOFT_MESSAGE_ASSERT(msg, expr)
  377. /** \brief Defines a compile-time assertion
  378. *
  379. * \ingroup group__library__macros__assertion
  380. *
  381. * \param expr Must be non-zero, or compilation will fail
  382. */
  383. #define UNIXSTL_STATIC_ASSERT(expr) STLSOFT_STATIC_ASSERT(expr)
  384. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  385. # define unixstl_assert(expr) UNIXSTL_ASSERT(expr)
  386. # define unixstl_message_assert(msg, expr) UNIXSTL_MESSAGE_ASSERT(msg, expr)
  387. # define unixstl_static_assert(expr) UNIXSTL_STATIC_ASSERT(expr)
  388. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  389. /* /////////////////////////////////////////////////////////////////////////
  390. * Namespace
  391. *
  392. * The UNIXSTL components are contained within the unixstl namespace. This is
  393. * usually an alias for stlsoft::unixstl_project,
  394. *
  395. * When compilers support namespaces they are defined by default. They can be
  396. * undefined using a cascasing system, as follows:
  397. *
  398. * If _STLSOFT_NO_NAMESPACES is defined, then _UNIXSTL_NO_NAMESPACES is defined.
  399. *
  400. * If _UNIXSTL_NO_NAMESPACES is defined, then _UNIXSTL_NO_NAMESPACE is defined.
  401. *
  402. * If _UNIXSTL_NO_NAMESPACE is defined, then the UNIXSTL constructs are defined
  403. * in the global scope.
  404. *
  405. * If _STLSOFT_NO_NAMESPACES, _UNIXSTL_NO_NAMESPACES and _UNIXSTL_NO_NAMESPACE are
  406. * all undefined but the symbol _STLSOFT_NO_NAMESPACE is defined (whence the
  407. * namespace stlsoft does not exist), then the UNIXSTL constructs are defined
  408. * within the unixstl namespace. The definition matrix is as follows:
  409. *
  410. * _STLSOFT_NO_NAMESPACE _UNIXSTL_NO_NAMESPACE unixstl definition
  411. * --------------------- -------------------- -----------------
  412. * not defined not defined = stlsoft::unixstl_project
  413. * not defined defined not defined
  414. * defined not defined unixstl
  415. * defined defined not defined
  416. *
  417. *
  418. *
  419. * The macro unixstl_ns_qual() macro can be used to refer to elements in the
  420. * UNIXSTL libraries irrespective of whether they are in the
  421. * stlsoft::unixstl_project (or unixstl) namespace or in the global namespace.
  422. *
  423. * Furthermore, some compilers do not support the standard library in the std
  424. * namespace, so the unixstl_ns_qual_std() macro can be used to refer to elements
  425. * in the UNIXSTL libraries irrespective of whether they are in the std namespace
  426. * or in the global namespace.
  427. */
  428. /* No STLSoft namespaces means no UNIXSTL namespaces */
  429. #ifdef _STLSOFT_NO_NAMESPACES
  430. # define _UNIXSTL_NO_NAMESPACES
  431. #endif /* _STLSOFT_NO_NAMESPACES */
  432. /* No UNIXSTL namespaces means no unixstl namespace */
  433. #ifdef _UNIXSTL_NO_NAMESPACES
  434. # define _UNIXSTL_NO_NAMESPACE
  435. #endif /* _UNIXSTL_NO_NAMESPACES */
  436. #ifndef _UNIXSTL_NO_NAMESPACE
  437. # if defined(_STLSOFT_NO_NAMESPACE) || \
  438. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  439. /* There is no stlsoft namespace, so must define ::unixstl */
  440. /** \brief The <code class="namespace">unixstl</code> namespace contains all components
  441. * in the \ref group__project__unixstl "UNIXSTL" project.
  442. *
  443. * By default, the <code>unixstl</code> namespace is actually an alias for
  444. * the namespace <code>stlsoft::unixstl_project</code>, which is where all
  445. * the \ref group__project__unixstl "UNIXSTL" components actually reside. This
  446. * measure allows all components within the main the
  447. * \ref group__project__stlsoft "STLSoft" project (which are defined within
  448. * the <code>stlsoft</code> namespace) to be visible to all components
  449. * "within" the <code>unixstl</code> namespace. (Otherwise, there would be a
  450. * whole lot of onerous qualification throughout the code of all
  451. * \ref group__projects "sub-projects".)
  452. *
  453. * \note If either/both of the symbols <code>_STLSOFT_NO_NAMESPACES</code>
  454. * and <code>_UNIXSTL_NO_NAMESPACE</code> are defined, all
  455. * \ref group__project__unixstl "UNIXSTL" components will be defined in the
  456. * global namespace. Conversely, if the <code>_STLSOFT_NO_NAMESPACE</code>
  457. * symbol (not to be confused with the
  458. * <code>_STLSOFT_NO_NAMESPACES</code> symbol!) is defined - meaning that
  459. * all \ref group__project__stlsoft "main project" components are to be
  460. * defined in the global namespace, and <code>_UNIXSTL_NO_NAMESPACE</code>
  461. * is <b>not</b> defined, then all \ref group__project__unixstl "UNIXSTL"
  462. * components will be defined within a bona fide <code>unixstl</code>
  463. * namespace.
  464. *
  465. * \note This is a vestige of compatibility with compilers with
  466. * no (or no sensible) namespace support that is maintained for reasons of
  467. * backwards compatiblity and because it is, in <i>rare circumstances</i>, a
  468. * useful facility.
  469. */
  470. namespace unixstl
  471. {
  472. # else
  473. /* Define stlsoft::unixstl_project */
  474. namespace stlsoft
  475. {
  476. namespace unixstl_project
  477. {
  478. # endif /* _STLSOFT_NO_NAMESPACE */
  479. #else
  480. stlsoft_ns_using(move_lhs_from_rhs)
  481. #endif /* !_UNIXSTL_NO_NAMESPACE */
  482. /** \def unixstl_ns_qual(x)
  483. * Qualifies with <b>unixstl::</b> if UNIXSTL is using namespaces or, if not, does not qualify
  484. */
  485. /** \def unixstl_ns_using(x)
  486. * Declares a using directive (with respect to <b>unixstl</b>) if UNIXSTL is using namespaces or, if not, does nothing
  487. */
  488. #ifndef _UNIXSTL_NO_NAMESPACE
  489. # define unixstl_ns_qual(x) ::unixstl::x
  490. # define unixstl_ns_using(x) using ::unixstl::x;
  491. #else
  492. # define unixstl_ns_qual(x) x
  493. # define unixstl_ns_using(x)
  494. #endif /* !_UNIXSTL_NO_NAMESPACE */
  495. /** \def unixstl_ns_qual_std(x)
  496. * 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
  497. */
  498. /** \def unixstl_ns_using_std(x)
  499. * 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
  500. */
  501. #ifdef STLSOFT_CF_std_NAMESPACE
  502. # define unixstl_ns_qual_std(x) ::std::x
  503. # define unixstl_ns_using_std(x) using ::std::x;
  504. #else /* ? STLSOFT_CF_std_NAMESPACE */
  505. # define unixstl_ns_qual_std(x) x
  506. # define unixstl_ns_using_std(x)
  507. #endif /* !STLSOFT_CF_std_NAMESPACE */
  508. /* /////////////////////////////////////////////////////////////////////////
  509. * Typedefs
  510. *
  511. * The UNIXSTL uses a number of typedefs to aid in compiler-independence in the
  512. * libraries' main code.
  513. */
  514. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  515. typedef stlsoft_ns_qual(ss_char_a_t) us_char_a_t; /*!< Ansi char type */
  516. typedef stlsoft_ns_qual(ss_char_w_t) us_char_w_t; /*!< Unicode char type */
  517. typedef stlsoft_ns_qual(ss_sint8_t) us_sint8_t; /*!< 8-bit signed integer */
  518. typedef stlsoft_ns_qual(ss_uint8_t) us_uint8_t; /*!< 8-bit unsigned integer */
  519. typedef stlsoft_ns_qual(ss_int16_t) us_int16_t; /*!< 16-bit integer */
  520. typedef stlsoft_ns_qual(ss_sint16_t) us_sint16_t; /*!< 16-bit signed integer */
  521. typedef stlsoft_ns_qual(ss_uint16_t) us_uint16_t; /*!< 16-bit unsigned integer */
  522. typedef stlsoft_ns_qual(ss_int32_t) us_int32_t; /*!< 32-bit integer */
  523. typedef stlsoft_ns_qual(ss_sint32_t) us_sint32_t; /*!< 32-bit signed integer */
  524. typedef stlsoft_ns_qual(ss_uint32_t) us_uint32_t; /*!< 32-bit unsigned integer */
  525. #ifdef STLSOFT_CF_64BIT_INT_SUPPORT
  526. typedef stlsoft_ns_qual(ss_int64_t) us_int64_t; /*!< 64-bit integer */
  527. typedef stlsoft_ns_qual(ss_sint64_t) us_sint64_t; /*!< 64-bit signed integer */
  528. typedef stlsoft_ns_qual(ss_uint64_t) us_uint64_t; /*!< 64-bit unsigned integer */
  529. #endif /* STLSOFT_CF_64BIT_INT_SUPPORT */
  530. typedef stlsoft_ns_qual(ss_int_t) us_int_t; /*!< integer */
  531. typedef stlsoft_ns_qual(ss_sint_t) us_sint_t; /*!< signed integer */
  532. typedef stlsoft_ns_qual(ss_uint_t) us_uint_t; /*!< unsigned integer */
  533. typedef stlsoft_ns_qual(ss_long_t) us_long_t; /*!< long */
  534. #if defined(__cplusplus)
  535. typedef stlsoft_ns_qual(ss_bool_t) us_bool_t; /*!< bool */
  536. #endif /* __cplusplus */
  537. typedef stlsoft_ns_qual(ss_size_t) us_size_t; /*!< size */
  538. typedef stlsoft_ns_qual(ss_ptrdiff_t) us_ptrdiff_t; /*!< ptr diff */
  539. typedef stlsoft_ns_qual(ss_streampos_t) us_streampos_t; /*!< streampos */
  540. typedef stlsoft_ns_qual(ss_streamoff_t) us_streamoff_t; /*!< streamoff */
  541. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  542. #ifndef _UNIXSTL_NO_NAMESPACE
  543. typedef us_char_a_t char_a_t; /*!< Ansi char type */
  544. typedef us_char_w_t char_w_t; /*!< Unicode char type */
  545. /* typedef us_int8_t int8_t; */ /*!< 8-bit integer */
  546. typedef us_sint8_t sint8_t; /*!< 8-bit signed integer */
  547. typedef us_uint8_t uint8_t; /*!< 8-bit unsigned integer */
  548. typedef us_int16_t int16_t; /*!< 16-bit integer */
  549. typedef us_sint16_t sint16_t; /*!< 16-bit signed integer */
  550. typedef us_uint16_t uint16_t; /*!< 16-bit unsigned integer */
  551. typedef us_int32_t int32_t; /*!< 32-bit integer */
  552. typedef us_sint32_t sint32_t; /*!< 32-bit signed integer */
  553. typedef us_uint32_t uint32_t; /*!< 32-bit unsigned integer */
  554. # ifdef STLSOFT_CF_64BIT_INT_SUPPORT
  555. typedef us_int64_t int64_t; /*!< 64-bit integer */
  556. typedef us_sint64_t sint64_t; /*!< 64-bit signed integer */
  557. typedef us_uint64_t uint64_t; /*!< 64-bit unsigned integer */
  558. # endif /* STLSOFT_CF_64BIT_INT_SUPPORT */
  559. /* typedef us_short_t short_t; */ /*!< short integer */
  560. typedef us_int_t int_t; /*!< integer */
  561. typedef us_sint_t sint_t; /*!< signed integer */
  562. typedef us_uint_t uint_t; /*!< unsigned integer */
  563. typedef us_long_t long_t; /*!< long integer */
  564. /* typedef us_byte_t byte_t; */ /*!< Byte */
  565. typedef us_bool_t bool_t; /*!< bool */
  566. # if !defined(STLSOFT_COMPILER_IS_DMC)
  567. typedef us_streampos_t streampos_t; /*!< streampos */
  568. typedef us_streamoff_t streamoff_t; /*!< streamoff */
  569. # endif /* compiler */
  570. #endif /* !_UNIXSTL_NO_NAMESPACE */
  571. /* /////////////////////////////////////////////////////////////////////////
  572. * Values
  573. *
  574. * Since the boolean type may not be supported natively on all compilers, the
  575. * values of true and false may also not be provided. Hence the values of
  576. * us_true_v and us_false_v are defined, and are used in all code.
  577. */
  578. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  579. #define us_true_v ss_true_v
  580. #define us_false_v ss_false_v
  581. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  582. /* /////////////////////////////////////////////////////////////////////////
  583. * Code modification macros
  584. */
  585. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  586. /* Exception signatures. */
  587. #define unixstl_throw_0() stlsoft_throw_0()
  588. #define unixstl_throw_1(x1) stlsoft_throw_1(x1)
  589. #define unixstl_throw_2(x1, x2) stlsoft_throw_2(x1, x2)
  590. #define unixstl_throw_3(x1, x2, x3) stlsoft_throw_3(x1, x2, x3)
  591. #define unixstl_throw_4(x1, x2, x3, x4) stlsoft_throw_4(x1, x2, x3, x4)
  592. #define unixstl_throw_5(x1, x2, x3, x4, x5) stlsoft_throw_5(x1, x2, x3, x4, x5)
  593. #define unixstl_throw_6(x1, x2, x3, x4, x5, x6) stlsoft_throw_6(x1, x2, x3, x4, x5, x6)
  594. #define unixstl_throw_7(x1, x2, x3, x4, x5, x6, x7) stlsoft_throw_7(x1, x2, x3, x4, x5, x6, x7)
  595. #define unixstl_throw_8(x1, x2, x3, x4, x5, x6, x7, x8) stlsoft_throw_8(x1, x2, x3, x4, x5, x6, x7, x8)
  596. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  597. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  598. # define UNIXSTL_NUM_ELEMENTS(ar) STLSOFT_NUM_ELEMENTS(ar)
  599. # define unixstl_num_elements(ar) UNIXSTL_NUM_ELEMENTS(ar)
  600. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  601. /** \brief [DEPRECATED] Destroys the given instance \c p of the given type (\c t and \c _type)
  602. *
  603. * \deprecated This is <b>heavily</b> deprecated in favour of \ref STLSOFT_DESTROY_INSTANCE().
  604. */
  605. #define unixstl_destroy_instance(t, _type, p) STLSOFT_DESTROY_INSTANCE(t, _type, p)
  606. /** \brief [DEPRECATED] Generates an opaque type with the name \c _htype
  607. *
  608. * \deprecated This is <b>heavily</b> deprecated in favour of \ref STLSOFT_GEN_OPAQUE().
  609. */
  610. #define unixstl_gen_opaque(_htype) STLSOFT_GEN_OPAQUE(_htype)
  611. /* ////////////////////////////////////////////////////////////////////// */
  612. #ifndef _UNIXSTL_NO_NAMESPACE
  613. # if defined(_STLSOFT_NO_NAMESPACE) || \
  614. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  615. } /* namespace unixstl */
  616. # else
  617. } /* namespace unixstl_project */
  618. } /* namespace stlsoft */
  619. namespace unixstl = ::stlsoft::unixstl_project;
  620. # endif /* _STLSOFT_NO_NAMESPACE */
  621. #endif /* !_UNIXSTL_NO_NAMESPACE */
  622. /* /////////////////////////////////////////////////////////////////////////
  623. * Inclusion
  624. */
  625. #ifdef STLSOFT_CF_PRAGMA_ONCE_SUPPORT
  626. # pragma once
  627. #endif /* STLSOFT_CF_PRAGMA_ONCE_SUPPORT */
  628. /* ////////////////////////////////////////////////////////////////////// */
  629. #endif /* !UNIXSTL_INCL_UNIXSTL_H_UNIXSTL */
  630. /* ///////////////////////////// end of file //////////////////////////// */