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.

387 lines
16 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: pantheios/pantheios.hpp
  3. *
  4. * Purpose: Primary header file for Pantheios
  5. *
  6. * Created: 21st June 2005
  7. * Updated: 9th January 2011
  8. *
  9. * Home: http://www.pantheios.org/
  10. *
  11. * Copyright (c) 2005-2011, Matthew Wilson and Synesis Software
  12. * Copyright (c) 1999-2005, Synesis Software and Matthew Wilson
  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
  17. * met:
  18. *
  19. * - Redistributions of source code must retain the above copyright notice,
  20. * this list of conditions and the following disclaimer.
  21. * - Redistributions in binary form must reproduce the above copyright
  22. * notice, this list of conditions and the following disclaimer in the
  23. * documentation and/or other materials provided with the distribution.
  24. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the
  25. * names of any contributors may be used to endorse or promote products
  26. * derived from this software without specific prior written permission.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
  29. * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  30. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  31. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  32. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  33. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  34. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  35. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  36. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  37. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  38. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  39. *
  40. * ////////////////////////////////////////////////////////////////////// */
  41. /** \file pantheios/pantheios.hpp
  42. *
  43. * [C++ only] Primary header file for the
  44. * \ref group__application_layer_interface, and included in all
  45. * C++ compilation units.
  46. *
  47. * Users should include this file to ensure that the Pantheios library is
  48. * automatically initialised, and to access
  49. * the \ref group__application_layer_interface.
  50. */
  51. #ifndef PANTHEIOS_INCL_PANTHEIOS_HPP_PANTHEIOS
  52. #define PANTHEIOS_INCL_PANTHEIOS_HPP_PANTHEIOS
  53. /* /////////////////////////////////////////////////////////////////////////
  54. * Version information
  55. */
  56. #ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION
  57. # define PANTHEIOS_VER_PANTHEIOS_HPP_PANTHEIOS_MAJOR 3
  58. # define PANTHEIOS_VER_PANTHEIOS_HPP_PANTHEIOS_MINOR 9
  59. # define PANTHEIOS_VER_PANTHEIOS_HPP_PANTHEIOS_REVISION 2
  60. # define PANTHEIOS_VER_PANTHEIOS_HPP_PANTHEIOS_EDIT 102
  61. #endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION */
  62. /* /////////////////////////////////////////////////////////////////////////
  63. * Includes
  64. */
  65. /* Main Pantheios Header */
  66. #ifndef PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS
  67. # include <pantheios/pantheios.h>
  68. #endif /* !PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS */
  69. #ifndef __cplusplus
  70. # error pantheios/pantheios.hpp is only valid in C++ compilation units
  71. #endif /* !__cplusplus */
  72. /* Required to validate the parameters are not integral types */
  73. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_IS_FUNDAMENTAL_TYPE
  74. # include <stlsoft/meta/is_fundamental_type.hpp>
  75. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_IS_FUNDAMENTAL_TYPE */
  76. /* Now select various headers to bring in string access shims */
  77. #ifndef STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_STRING_H_FWD
  78. # include <stlsoft/shims/access/string/fwd.h>
  79. #endif /* !STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_STRING_H_FWD */
  80. /* Backwards-compatibility */
  81. #ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION
  82. # if defined(PANTHEIOS_NO_INCLUDE_STLSOFT_SHIM_ACCESS_SHIMS) && \
  83. !defined(PANTHEIOS_NO_INCLUDE_STLSOFT_STRING_ACCESS)
  84. # ifdef STLSOFT_CF_PRAGMA_MESSAGE_SUPPORT
  85. # pragma messsage("The symbol PANTHEIOS_NO_INCLUDE_STLSOFT_SHIM_ACCESS_SHIMS is deprecated, and support for it will be removed before 1.0.1. Please use PANTHEIOS_NO_INCLUDE_STLSOFT_STRING_ACCESS instead.")
  86. # endif /* STLSOFT_CF_PRAGMA_MESSAGE_SUPPORT */
  87. # define PANTHEIOS_NO_INCLUDE_STLSOFT_STRING_ACCESS
  88. # endif /* PANTHEIOS_NO_INCLUDE_STLSOFT_SHIM_ACCESS_SHIMS && !PANTHEIOS_NO_INCLUDE_STLSOFT_STRING_ACCESS */
  89. #endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION */
  90. #ifdef PANTHEIOS_CUSTOM_SHIM_INCLUDE
  91. # include PANTHEIOS_CUSTOM_SHIM_INCLUDE
  92. #else /* ? PANTHEIOS_CUSTOM_SHIM_INCLUDE */
  93. # if !defined(PANTHEIOS_NO_INCLUDE_STLSOFT_STRING_ACCESS)
  94. # ifndef STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_HPP_STRING
  95. # include <stlsoft/shims/access/string.hpp>
  96. # endif /* !STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_HPP_STRING */
  97. # ifndef STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_STRING_STD_HPP_TIME
  98. # include <stlsoft/shims/access/string/std/time.hpp>
  99. # endif /* !STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_STRING_STD_HPP_TIME */
  100. # ifdef PANTHEIOS_NO_INCLUDE_OS_AND_3PTYLIB_STRING_ACCESS
  101. # define PANTHEIOS_NO_INCLUDE_ACESTL_STRING_ACCESS
  102. # define PANTHEIOS_NO_INCLUDE_ATLSTL_STRING_ACCESS
  103. # define PANTHEIOS_NO_INCLUDE_COMSTL_STRING_ACCESS
  104. # define PANTHEIOS_NO_INCLUDE_MFCSTL_STRING_ACCESS
  105. # define PANTHEIOS_NO_INCLUDE_PLATFORMSTL_STRING_ACCESS
  106. # define PANTHEIOS_NO_INCLUDE_UNIXSTL_STRING_ACCESS
  107. # define PANTHEIOS_NO_INCLUDE_WINSTL_STRING_ACCESS
  108. # define PANTHEIOS_NO_INCLUDE_WTLSTL_STRING_ACCESS
  109. # endif /* PANTHEIOS_NO_INCLUDE_OS_AND_3PTYLIB_STRING_ACCESS */
  110. /* Include shims for MFC, if
  111. *
  112. * - it's not been proscribed, by PANTHEIOS_NO_INCLUDE_MFCSTL_STRING_ACCESS, and either
  113. * - it's been explicitly requested, by PANTHEIOS_FORCE_INCLUDE_MFCSTL_STRING_ACCESS, or
  114. * - _AFX and _MFC_VER are defined
  115. */
  116. # if !defined(PANTHEIOS_NO_INCLUDE_MFCSTL_STRING_ACCESS) && \
  117. ( defined(PANTHEIOS_FORCE_INCLUDE_MFCSTL_STRING_ACCESS) || \
  118. defined(_AFXDLL) || \
  119. ( defined(_AFX) && \
  120. defined(_MFC_VER)))
  121. # ifndef MFCSTL_INCL_MFCSTL_SHIMS_ACCESS_HPP_STRING
  122. # include <mfcstl/shims/access/string.hpp>
  123. # endif /* !MFCSTL_INCL_MFCSTL_SHIMS_ACCESS_HPP_STRING */
  124. # endif /* MFC */
  125. /* Include shims for ATL, if
  126. *
  127. * - it's not been proscribed, by PANTHEIOS_NO_INCLUDE_ATLSTL_STRING_ACCESS, and either
  128. * - it's been explicitly requested, by PANTHEIOS_FORCE_INCLUDE_ATLSTL_STRING_ACCESS, or
  129. * - _ATL and _ATL_VER are defined
  130. */
  131. # if !defined(PANTHEIOS_NO_INCLUDE_ATLSTL_STRING_ACCESS) && \
  132. ( defined(PANTHEIOS_FORCE_INCLUDE_ATLSTL_STRING_ACCESS) || \
  133. ( defined(_ATL) && \
  134. defined(_ATL_VER)))
  135. # ifndef ATLSTL_INCL_ATLSTL_SHIMS_ACCESS_HPP_STRING
  136. # include <atlstl/shims/access/string.hpp>
  137. # endif /* !ATLSTL_INCL_ATLSTL_SHIMS_ACCESS_HPP_STRING */
  138. # endif /* ATL */
  139. /* Include shims for COM, if
  140. *
  141. * - it's not been proscribed, by PANTHEIOS_NO_INCLUDE_COMSTL_STRING_ACCESS, and either
  142. * - it's been explicitly requested, by PANTHEIOS_FORCE_INCLUDE_COMSTL_STRING_ACCESS, or
  143. * - WIN32/WIN64 is defined
  144. */
  145. # if !defined(PANTHEIOS_NO_INCLUDE_COMSTL_STRING_ACCESS) && \
  146. ( defined(PANTHEIOS_FORCE_INCLUDE_COMSTL_STRING_ACCESS) || \
  147. defined(WIN32) || \
  148. defined(WIN64))
  149. # ifndef COMSTL_INCL_COMSTL_SHIMS_ACCESS_HPP_STRING
  150. # include <comstl/shims/access/string.hpp>
  151. # endif /* !COMSTL_INCL_COMSTL_SHIMS_ACCESS_HPP_STRING */
  152. # endif /* COM */
  153. /* Include shims for UNIX, if
  154. *
  155. * - it's not been proscribed, by PANTHEIOS_NO_INCLUDE_UNIXSTL_STRING_ACCESS, and either
  156. * - it's been explicitly requested, by PANTHEIOS_FORCE_INCLUDE_UNIXSTL_STRING_ACCESS, or
  157. * - unix, __unix, __unix__ or UNIX is defined
  158. */
  159. # if !defined(PANTHEIOS_NO_INCLUDE_UNIXSTL_STRING_ACCESS) && \
  160. ( defined(PANTHEIOS_FORCE_INCLUDE_UNIXSTL_STRING_ACCESS) || \
  161. ( defined(unix) || \
  162. defined(__unix) || \
  163. defined(__unix__) || \
  164. defined(UNIX)))
  165. # ifndef UNIXSTL_INCL_UNIXSTL_SHIMS_ACCESS_HPP_STRING
  166. # include <unixstl/shims/access/string.hpp>
  167. # endif /* !UNIXSTL_INCL_UNIXSTL_SHIMS_ACCESS_HPP_STRING */
  168. # endif /* UNIX */
  169. /* Include shims for Windows, if
  170. *
  171. * - it's not been proscribed, by PANTHEIOS_NO_INCLUDE_WINSTL_STRING_ACCESS, and either
  172. * - it's been explicitly requested, by PANTHEIOS_FORCE_INCLUDE_WINSTL_STRING_ACCESS, or
  173. * - WIN32/WIN64 is defined
  174. */
  175. # if !defined(PANTHEIOS_NO_INCLUDE_WINSTL_STRING_ACCESS) && \
  176. ( defined(PANTHEIOS_FORCE_INCLUDE_WINSTL_STRING_ACCESS) || \
  177. defined(WIN32) || \
  178. defined(WIN64))
  179. # ifndef WINSTL_INCL_WINSTL_SHIMS_ACCESS_HPP_STRING
  180. # include <winstl/shims/access/string.hpp>
  181. # endif /* !WINSTL_INCL_WINSTL_SHIMS_ACCESS_HPP_STRING */
  182. # ifndef WINSTL_INCL_WINSTL_SHIMS_ACCESS_STRING_HPP_TIME
  183. # include <winstl/shims/access/string/time.hpp>
  184. # endif /* !WINSTL_INCL_WINSTL_SHIMS_ACCESS_STRING_HPP_TIME */
  185. # endif /* Win */
  186. # endif /* !PANTHEIOS_NO_INCLUDE_STLSOFT_STRING_ACCESS */
  187. #endif /* PANTHEIOS_CUSTOM_SHIM_INCLUDE */
  188. /* /////////////////////////////////////////////////////////////////////////
  189. * GCC bug
  190. */
  191. /* NOTE: We must include <pantheios/inserters.hpp> here, as GCC is a bit
  192. * thick about its two-phase name lookup when resolving shim functions for
  193. * the Pantheios inserter types integer, pointer and real.
  194. */
  195. #if defined(STLSOFT_COMPILER_IS_GCC) && \
  196. __GNUC__ < 4
  197. //# include <pantheios/inserters.hpp>
  198. #endif /* compiler */
  199. /* /////////////////////////////////////////////////////////////////////////
  200. * Namespace
  201. */
  202. #if !defined(PANTHEIOS_NO_NAMESPACE)
  203. namespace pantheios
  204. {
  205. #endif /* !PANTHEIOS_NO_NAMESPACE */
  206. /* /////////////////////////////////////////////////////////////////////////
  207. * C++ API components
  208. *
  209. * To suppress all generated functions, define the preprocessor symbol
  210. * PANTHEIOS_NO_GENERATED_FUNCTIONS
  211. *
  212. * To suppress all log() generated functions, define the preprocessor
  213. * symbol
  214. * PANTHEIOS_NO_LOG_FUNCTIONS
  215. *
  216. * To suppress all log-specific generated functions (i.e. log_DEBUG(),
  217. * log_CRITICAL(), etc.), define the preprocessor symbol
  218. * <code>PANTHEIOS_NO_LOG_SEV_FUNCTIONS</code>. Note: if the symbol
  219. * <code>PANTHEIOS_NO_STOCK_LEVELS</code> is defined, then
  220. * <code>PANTHEIOS_NO_LOG_SEV_FUNCTIONS</code> will be defined
  221. * automatically.
  222. */
  223. #ifdef PANTHEIOS_NO_STOCK_LEVELS
  224. # ifndef PANTHEIOS_NO_LOG_SEV_FUNCTIONS
  225. # define PANTHEIOS_NO_LOG_SEV_FUNCTIONS
  226. # endif /* !PANTHEIOS_NO_LOG_SEV_FUNCTIONS */
  227. #endif /* PANTHEIOS_NO_STOCK_LEVELS */
  228. #ifdef PANTHEIOS_INVOKE_SHIM_PAIR_
  229. # undef PANTHEIOS_INVOKE_SHIM_PAIR_
  230. #endif /* PANTHEIOS_INVOKE_SHIM_PAIR_ */
  231. #ifdef PANTHEIOS_VALIDATE_TYPE_NOT_FUNDAMENTAL_
  232. # undef PANTHEIOS_VALIDATE_TYPE_NOT_FUNDAMENTAL_
  233. #endif /* PANTHEIOS_VALIDATE_TYPE_NOT_FUNDAMENTAL_ */
  234. /* /////////////////////////////////////////////////////////////////////////
  235. * Compiler compatibility
  236. */
  237. /* The Digital Mars and GCC compilers both exhibit strange behaviour (bugs?)
  238. * with respect to the invocation of shims.
  239. *
  240. * - DMC++ requires explicit qualification, even in the presence of a
  241. * (local) using declaration
  242. * - GCC requires a local using declaration and *must not* have explicit
  243. * qualification.
  244. *
  245. * - all other compilers work fine without any using declaration and with
  246. * explicit qualification.
  247. *
  248. * As currently defined, we follow the GCC way (which works for all other
  249. * compilers, except DMC++), and explicitly qualify for DMC++.
  250. *
  251. */
  252. #ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION
  253. # ifdef PANTHEIOS_INVOKE_c_str_data_
  254. # undef PANTHEIOS_INVOKE_c_str_data_
  255. # endif /* PANTHEIOS_INVOKE_c_str_data_ */
  256. # ifdef PANTHEIOS_INVOKE_c_str_len_
  257. # undef PANTHEIOS_INVOKE_c_str_len_
  258. # endif /* PANTHEIOS_INVOKE_c_str_len_ */
  259. # ifdef PANTHEIOS_INVOKE_c_str_ptr_
  260. # undef PANTHEIOS_INVOKE_c_str_ptr_
  261. # endif /* PANTHEIOS_INVOKE_c_str_ptr_ */
  262. # ifdef PANTHEIOS_INVOKE_SHIM_PAIR_
  263. # undef PANTHEIOS_INVOKE_SHIM_PAIR_
  264. # endif /* PANTHEIOS_INVOKE_SHIM_PAIR_ */
  265. # ifdef PANTHEIOS_c_str_data_name_
  266. # undef PANTHEIOS_c_str_data_name_
  267. # endif /* PANTHEIOS_c_str_data_name_ */
  268. # ifdef PANTHEIOS_USE_WIDE_STRINGS
  269. # define PANTHEIOS_c_str_data_name_ c_str_data_w
  270. # define PANTHEIOS_c_str_len_name_ c_str_len_w
  271. # define PANTHEIOS_c_str_ptr_name_ c_str_ptr_w
  272. # else /* ? PANTHEIOS_USE_WIDE_STRINGS */
  273. # define PANTHEIOS_c_str_data_name_ c_str_data_a
  274. # define PANTHEIOS_c_str_len_name_ c_str_len_a
  275. # define PANTHEIOS_c_str_ptr_name_ c_str_ptr_a
  276. # endif /* PANTHEIOS_USE_WIDE_STRINGS */
  277. # if defined(STLSOFT_COMPILER_IS_DMC)
  278. # define PANTHEIOS_DECLARE_SHIM_PAIR_() ((void)0)
  279. # define PANTHEIOS_INVOKE_SHIM_PAIR_(x) stlsoft::PANTHEIOS_c_str_len_name_(x), stlsoft::PANTHEIOS_c_str_data_name_(x)
  280. # elif defined(STLSOFT_COMPILER_IS_GCC)
  281. # define PANTHEIOS_DECLARE_SHIM_PAIR_() using ::stlsoft::PANTHEIOS_c_str_data_name_; using ::stlsoft::PANTHEIOS_c_str_len_name_
  282. # define PANTHEIOS_INVOKE_SHIM_PAIR_(x) PANTHEIOS_c_str_len_name_(x), PANTHEIOS_c_str_data_name_(x)
  283. # else /* ? compiler */
  284. # define PANTHEIOS_DECLARE_SHIM_PAIR_() using ::stlsoft::PANTHEIOS_c_str_data_name_; using ::stlsoft::PANTHEIOS_c_str_len_name_
  285. # define PANTHEIOS_INVOKE_SHIM_PAIR_(x) PANTHEIOS_c_str_len_name_(x), PANTHEIOS_c_str_data_name_(x)
  286. # endif /* compiler */
  287. # define PANTHEIOS_VALIDATE_TYPE_NOT_FUNDAMENTAL_(t) STLSOFT_STATIC_ASSERT(0 == stlsoft::is_fundamental_type<t>::value)
  288. #endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION */
  289. #ifndef PANTHEIOS_NO_GENERATED_FUNCTIONS
  290. # ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION
  291. namespace internal
  292. {
  293. # include "./internal/generated/log_dispatch_functions.h"
  294. # include "./internal/generated/log_dispatch_functions.hpp"
  295. } /* namespace internal */
  296. # endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION */
  297. # if !defined(PANTHEIOS_NO_LOG_FUNCTIONS)
  298. # include "./internal/generated/log_functions.hpp" // log(s), log(s, s) etc etc
  299. # endif /* !PANTHEIOS_NO_LOG_FUNCTIONS */
  300. # if !defined(PANTHEIOS_NO_LOG_SEV_FUNCTIONS)
  301. # include "./internal/generated/log_sev_functions.hpp" // log_ALERT() overloads, log_ERROR() overloads, etc.
  302. # endif /* !PANTHEIOS_NO_LOG_SEV_FUNCTIONS */
  303. #endif /* !PANTHEIOS_NO_GENERATED_FUNCTIONS */
  304. #undef PANTHEIOS_INVOKE_SHIM_PAIR_
  305. /* /////////////////////////////////////////////////////////////////////////
  306. * Namespace
  307. */
  308. #if !defined(PANTHEIOS_NO_NAMESPACE)
  309. } /* namespace pantheios */
  310. #endif /* !PANTHEIOS_NO_NAMESPACE */
  311. /* /////////////////////////////////////////////////////////////////////////
  312. * Auto-initialisation
  313. *
  314. * Except when making a DLL, this is automatic, unless PANTHEIOS_NO_AUTO_INIT
  315. * is defined.
  316. *
  317. * To force it for a DLL, define PANTHEIOS_FORCE_AUTO_INIT
  318. */
  319. #if defined(__DLL__) /* Borland, with -WD */ || \
  320. defined(_WINDLL) /* VC++, defined by user/wizard */ || \
  321. defined(_USRDLL) /* VC++, defined by user/wizard */
  322. # define PANTHEIOS_NO_AUTO_INIT
  323. #endif /* dynamic library */
  324. #if defined(PANTHEIOS_FORCE_AUTO_INIT) || \
  325. !defined(PANTHEIOS_NO_AUTO_INIT)
  326. # include "./internal/initialiser.hpp" // Schwarz counter initialisation
  327. #endif /* PANTHEIOS_FORCE_AUTO_INIT || !PANTHEIOS_NO_AUTO_INIT */
  328. /* /////////////////////////////////////////////////////////////////////////
  329. * Inclusion
  330. */
  331. #ifdef STLSOFT_PPF_pragma_once_SUPPORT
  332. # pragma once
  333. #endif /* STLSOFT_PPF_pragma_once_SUPPORT */
  334. /* ////////////////////////////////////////////////////////////////////// */
  335. #endif /* !PANTHEIOS_INCL_PANTHEIOS_HPP_PANTHEIOS */
  336. /* ///////////////////////////// end of file //////////////////////////// */