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.

279 lines
9.4 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: winstl/registry/util/defs.hpp
  3. *
  4. * Purpose: Contains common type and feature discriminations for the Registry Library.
  5. *
  6. * Created: 19th January 2002
  7. * Updated: 3rd February 2012
  8. *
  9. * Home: http://stlsoft.org/
  10. *
  11. * Copyright (c) 2002-2012, Matthew Wilson and Synesis Software
  12. * All rights reserved.
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions are met:
  16. *
  17. * - Redistributions of source code must retain the above copyright notice, this
  18. * list of conditions and the following disclaimer.
  19. * - Redistributions in binary form must reproduce the above copyright notice,
  20. * this list of conditions and the following disclaimer in the documentation
  21. * and/or other materials provided with the distribution.
  22. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
  23. * any contributors may be used to endorse or promote products derived from
  24. * this software without specific prior written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  27. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  30. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  31. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  32. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  33. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  34. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  35. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  36. * POSSIBILITY OF SUCH DAMAGE.
  37. *
  38. * ////////////////////////////////////////////////////////////////////// */
  39. /** \file winstl/registry/util/defs.hpp
  40. *
  41. * \brief [C++ only] Common type and feature discriminations for
  42. * the \ref group__library__windows_registry "Windows Registry" Library.
  43. */
  44. #ifndef WINSTL_INCL_WINSTL_REGISTRY_UTIL_HPP_DEFS
  45. #define WINSTL_INCL_WINSTL_REGISTRY_UTIL_HPP_DEFS
  46. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  47. # define WINSTL_VER_WINSTL_REGISTRY_UTIL_HPP_DEFS_MAJOR 4
  48. # define WINSTL_VER_WINSTL_REGISTRY_UTIL_HPP_DEFS_MINOR 0
  49. # define WINSTL_VER_WINSTL_REGISTRY_UTIL_HPP_DEFS_REVISION 1
  50. # define WINSTL_VER_WINSTL_REGISTRY_UTIL_HPP_DEFS_EDIT 57
  51. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  52. /* /////////////////////////////////////////////////////////////////////////
  53. * Includes
  54. */
  55. #ifndef WINSTL_INCL_WINSTL_H_WINSTL
  56. # include <winstl/winstl.h>
  57. #endif /* !WINSTL_INCL_WINSTL_H_WINSTL */
  58. #ifdef _WINSTL_REG_NO_STD_STRING
  59. # error _WINSTL_REG_NO_STD_STRING no longer supported. You should select _WINSTL_REG_STRING_USE_STD_STRING or _WINSTL_REG_STRING_USE_CUSTOM_STRING, or nothing (to use STLSoft simple_string)
  60. #endif /* _WINSTL_REG_NO_STD_STRING */
  61. /* Digital Mars seems to have trouble with basic_simple_string, so ... */
  62. #if 0 && \
  63. defined(STLSOFT_COMPILER_IS_DMC) && \
  64. !defined(_WINSTL_REG_STRING_USE_CUSTOM_STRING) && \
  65. __DMC__ <= 0x0834
  66. # define _WINSTL_REG_STRING_USE_STD_STRING
  67. #endif /* Digital Mars <= 0x0834 */
  68. /* For some totally inexplicable reason VC 5 gets its namespace knickers in a twist if
  69. * we use simple_strings, so ...
  70. */
  71. #if defined(STLSOFT_COMPILER_IS_MSVC) && \
  72. _MSC_VER < 1200
  73. # define _WINSTL_REG_STRING_USE_STD_STRING
  74. #endif /* compiler */
  75. #if defined(_WINSTL_REG_STRING_USE_STD_STRING)
  76. # include <string>
  77. #elif defined(_WINSTL_REG_STRING_USE_CUSTOM_STRING)
  78. # if !defined(_WINSTL_REG_STRING_CUSTOM_HEADER_FILE)
  79. # error You must define the header file (e.g. "#define _WINSTL_REG_STRING_CUSTOM_HEADER_FILE <mystring.h>") if you specify _WINSTL_REG_STRING_USE_CUSTOM_STRING
  80. # else /* ? !_WINSTL_REG_STRING_CUSTOM_HEADER_FILE */
  81. # include _WINSTL_REG_STRING_CUSTOM_HEADER_FILE // Your string class
  82. # endif /* !_WINSTL_REG_STRING_CUSTOM_HEADER_FILE */
  83. #else /* ? _WINSTL_REG_STRING_USE_CUSTOM_STRING */
  84. # ifndef STLSOFT_INCL_STLSOFT_STRING_HPP_SIMPLE_STRING
  85. # include <stlsoft/string/simple_string.hpp>
  86. # endif /* !STLSOFT_INCL_STLSOFT_STRING_HPP_SIMPLE_STRING */
  87. #endif /* string type */
  88. /* /////////////////////////////////////////////////////////////////////////
  89. * Namespace
  90. */
  91. #ifndef _WINSTL_NO_NAMESPACE
  92. # if defined(_STLSOFT_NO_NAMESPACE) || \
  93. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  94. /* There is no stlsoft namespace, so must define ::winstl */
  95. namespace winstl
  96. {
  97. # else
  98. /* Define stlsoft::winstl_project */
  99. namespace stlsoft
  100. {
  101. namespace winstl_project
  102. {
  103. # endif /* _STLSOFT_NO_NAMESPACE */
  104. #endif /* !_WINSTL_NO_NAMESPACE */
  105. /* /////////////////////////////////////////////////////////////////////////
  106. * Constants
  107. */
  108. /** \brief Number of characters in internal buffer of auto_buffer used throughout
  109. * the Registry library.
  110. *
  111. * \ingroup group__library__windows_registry
  112. */
  113. const ws_size_t CCH_REG_API_AUTO_BUFFER = 512;
  114. /* /////////////////////////////////////////////////////////////////////////
  115. * Typedefs
  116. *
  117. * All the following typedefs may be overriden by use of the preprocessor.
  118. */
  119. /** \def _WINSTL_REG_STRING_STRING_A_DEFINED
  120. *
  121. * \brief If defined, it indicates that the reg_string_a_t string type (for
  122. * ANSI character encoding) has been defined.
  123. */
  124. /** \def _WINSTL_REG_STRING_STRING_W_DEFINED
  125. *
  126. * \brief If defined, it indicates that the reg_string_a_t string type (for
  127. * Unicode character encoding) has been defined.
  128. */
  129. #if defined(_WINSTL_REG_STRING_USE_STD_STRING)
  130. // ANSI
  131. /** \brief For all compilers this is basic_string<ws_char_a_t> except Visual C++ 4.2
  132. * for which it is string
  133. *
  134. * \ingroup group__library__windows_registry
  135. */
  136. # if defined(STLSOFT_COMPILER_IS_MSVC) && \
  137. _MSC_VER < 1100
  138. typedef string reg_string_a_t;
  139. # else /* ? compiler */
  140. typedef winstl_ns_qual_std(basic_string)<ws_char_a_t> reg_string_a_t;
  141. # endif /* compiler */
  142. # define _WINSTL_REG_STRING_STRING_A_DEFINED
  143. // Unicode
  144. /** \brief For all compilers this is basic_string<ws_char_w_t> except Visual C++ 4.2
  145. * for which it is wstring
  146. *
  147. * \ingroup group__library__windows_registry
  148. */
  149. # if defined(STLSOFT_COMPILER_IS_MSVC) && \
  150. _MSC_VER < 1100
  151. typedef wstring reg_string_w_t;
  152. # else /* ? compiler */
  153. typedef winstl_ns_qual_std(basic_string)<ws_char_w_t> reg_string_w_t;
  154. # endif /* compiler */
  155. // TCHAR
  156. /** \brief For all compilers this is basic_string<ws_char_w_t> except Visual C++ 4.2
  157. * for which it is wstring
  158. *
  159. * \ingroup group__library__windows_registry
  160. */
  161. # if defined(STLSOFT_COMPILER_IS_MSVC) && \
  162. _MSC_VER < 1100
  163. # ifdef UNICODE
  164. typedef wstring reg_string_t;
  165. # else /* ? UNICODE */
  166. typedef string reg_string_t;
  167. # endif /* UNICODE */
  168. # else /* ? compiler */
  169. typedef winstl_ns_qual_std(basic_string)<TCHAR> reg_string_t;
  170. # endif /* compiler */
  171. # define _WINSTL_REG_STRING_STRING_W_DEFINED
  172. #elif defined(_WINSTL_REG_STRING_USE_CUSTOM_STRING)
  173. // ANSI
  174. # ifndef _WINSTL_REG_STRING_STRING_A_DEFINED
  175. # error If using custom strings, must provide definition of reg_string_a_t type, and defined _WINSTL_REG_STRING_STRING_A_DEFINED
  176. # endif /* !_WINSTL_REG_STRING_STRING_A_DEFINED */
  177. // Unicode
  178. # ifndef _WINSTL_REG_STRING_STRING_W_DEFINED
  179. # error If using custom strings, must provide definition of reg_string_w_t type, and defined _WINSTL_REG_STRING_STRING_W_DEFINED
  180. # endif /* !_WINSTL_REG_STRING_STRING_W_DEFINED */
  181. #else /* ? _WINSTL_REG_STRING_USE_STD_STRING */
  182. // ANSI
  183. /// \brief String type for ANSI character encoding used by the Registry library.
  184. typedef stlsoft_ns_qual(basic_simple_string)<ws_char_a_t> reg_string_a_t;
  185. # define _WINSTL_REG_STRING_STRING_A_DEFINED
  186. // Unicode
  187. /// \brief String type for Unicode character encoding used by the Registry library.
  188. typedef stlsoft_ns_qual(basic_simple_string)<ws_char_w_t> reg_string_w_t;
  189. // TCHAR
  190. /// \brief String type for TCHAR character encoding used by the Registry library.
  191. typedef stlsoft_ns_qual(basic_simple_string)<TCHAR> reg_string_t;
  192. # define _WINSTL_REG_STRING_STRING_W_DEFINED
  193. #endif /* string type */
  194. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  195. #ifdef _STLSOFT_NO_NAMESPACES
  196. struct registry_util
  197. #else /* ? _STLSOFT_NO_NAMESPACES */
  198. namespace registry_util
  199. #endif /* _STLSOFT_NO_NAMESPACES */
  200. {
  201. typedef reg_string_a_t string_a_t;
  202. typedef reg_string_w_t string_w_t;
  203. typedef reg_string_t string_t;
  204. struct shared_handle;
  205. struct monitored_shared_handle;
  206. #ifdef _STLSOFT_NO_NAMESPACES
  207. }; // struct registry_util
  208. #else /* ? _STLSOFT_NO_NAMESPACES */
  209. } // namespace registry_util
  210. #endif /* _STLSOFT_NO_NAMESPACES */
  211. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  212. /* ////////////////////////////////////////////////////////////////////// */
  213. #ifndef _WINSTL_NO_NAMESPACE
  214. # if defined(_STLSOFT_NO_NAMESPACE) || \
  215. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  216. } // namespace winstl
  217. # else
  218. } // namespace winstl_project
  219. } // namespace stlsoft
  220. # endif /* _STLSOFT_NO_NAMESPACE */
  221. #endif /* !_WINSTL_NO_NAMESPACE */
  222. /* ////////////////////////////////////////////////////////////////////// */
  223. #endif /* WINSTL_INCL_WINSTL_REGISTRY_UTIL_HPP_DEFS */
  224. /* ///////////////////////////// end of file //////////////////////////// */