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.

270 lines
8.1 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: winstl/registry/error/exceptions.hpp
  3. *
  4. * Purpose: Exceptions used by the Registry library.
  5. *
  6. * Created: 8th February 2006
  7. * Updated: 10th August 2009
  8. *
  9. * Home: http://stlsoft.org/
  10. *
  11. * Copyright (c) 2006-2009, 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/error/exceptions.hpp
  40. *
  41. * \brief [C++ only] Exceptions used by
  42. * the \ref group__library__windows_registry "Windows Registry" Library.
  43. */
  44. #ifndef WINSTL_INCL_WINSTL_REGISTRY_ERROR_HPP_EXCEPTIONS
  45. #define WINSTL_INCL_WINSTL_REGISTRY_ERROR_HPP_EXCEPTIONS
  46. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  47. # define WINSTL_VER_WINSTL_REGISTRY_ERROR_HPP_EXCEPTIONS_MAJOR 2
  48. # define WINSTL_VER_WINSTL_REGISTRY_ERROR_HPP_EXCEPTIONS_MINOR 1
  49. # define WINSTL_VER_WINSTL_REGISTRY_ERROR_HPP_EXCEPTIONS_REVISION 1
  50. # define WINSTL_VER_WINSTL_REGISTRY_ERROR_HPP_EXCEPTIONS_EDIT 17
  51. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  52. /* /////////////////////////////////////////////////////////////////////////
  53. * Compatibility
  54. */
  55. /*
  56. [DocumentationStatus:Ready]
  57. */
  58. /* /////////////////////////////////////////////////////////////////////////
  59. * Includes
  60. */
  61. #ifndef WINSTL_INCL_WINSTL_H_WINSTL
  62. # include <winstl/winstl.h>
  63. #endif /* !WINSTL_INCL_WINSTL_H_WINSTL */
  64. #ifndef WINSTL_INCL_WINSTL_ERROR_HPP_WINDOWS_EXCEPTIONS
  65. # include <winstl/error/exceptions.hpp>
  66. #endif /* !WINSTL_INCL_WINSTL_ERROR_HPP_WINDOWS_EXCEPTIONS */
  67. #ifndef STLSOFT_INCL_STLSOFT_UTIL_HPP_SIGN_TRAITS
  68. # include <stlsoft/util/sign_traits.hpp>
  69. #endif /* !STLSOFT_INCL_STLSOFT_UTIL_HPP_SIGN_TRAITS */
  70. /* /////////////////////////////////////////////////////////////////////////
  71. * Namespace
  72. */
  73. #ifndef _WINSTL_NO_NAMESPACE
  74. # if defined(_STLSOFT_NO_NAMESPACE) || \
  75. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  76. /* There is no stlsoft namespace, so must define ::winstl */
  77. namespace winstl
  78. {
  79. # else
  80. /* Define stlsoft::winstl_project */
  81. namespace stlsoft
  82. {
  83. namespace winstl_project
  84. {
  85. # endif /* _STLSOFT_NO_NAMESPACE */
  86. #endif /* !_WINSTL_NO_NAMESPACE */
  87. /* ////////////////////////////////////////////////////////////////////// */
  88. /** \brief Root exception thrown by
  89. * the \ref group__library__windows_registry "Windows Registry" Library.
  90. *
  91. * \ingroup group__library__windows_registry
  92. */
  93. class registry_exception
  94. : public windows_exception
  95. {
  96. /// \name Member Types
  97. /// @{
  98. public:
  99. typedef windows_exception parent_class_type;
  100. typedef registry_exception class_type;
  101. typedef parent_class_type::error_code_type error_code_type;
  102. typedef stlsoft_ns_qual(sign_traits)<error_code_type>::alt_sign_type error_code_alt_type;
  103. /// @}
  104. /// \name Construction
  105. /// @{
  106. public:
  107. /// \brief Constructs an instance from a reason and an error code
  108. registry_exception(char const* reason, error_code_type err)
  109. : windows_exception(reason, err)
  110. {}
  111. /// \brief Constructs an instance from a reason and an error code
  112. ///
  113. /// \note Since the Windows Registry API error code type is LONG
  114. /// this provides a suitable overload that does not incur compiler
  115. /// warnings. The casting to an unsigned type within the body is
  116. /// entirely benign.
  117. registry_exception(char const* reason, error_code_alt_type err)
  118. : windows_exception(reason, static_cast<error_code_type>(err))
  119. {}
  120. /// @}
  121. };
  122. /** \brief Indicates that a registry key could not be duplicated.
  123. *
  124. * \ingroup group__library__windows_registry
  125. */
  126. class key_not_duplicated_exception
  127. : public registry_exception
  128. {
  129. /// \name Member Types
  130. /// @{
  131. public:
  132. typedef registry_exception parent_class_type;
  133. typedef key_not_duplicated_exception class_type;
  134. /// @}
  135. /// \name Construction
  136. /// @{
  137. public:
  138. key_not_duplicated_exception(char const* reason, error_code_type err)
  139. : parent_class_type(reason, err)
  140. {}
  141. key_not_duplicated_exception(char const* reason, error_code_alt_type err)
  142. : parent_class_type(reason, err)
  143. {}
  144. /// @}
  145. /// \name Not to be implemented
  146. /// @{
  147. private:
  148. class_type& operator =(class_type const&);
  149. /// @}
  150. };
  151. /** \brief Indicates a registry value type mismatch.
  152. *
  153. * \ingroup group__library__windows_registry
  154. */
  155. class wrong_value_type_exception
  156. : public registry_exception
  157. {
  158. /// \name Member Types
  159. /// @{
  160. public:
  161. typedef registry_exception parent_class_type;
  162. typedef wrong_value_type_exception class_type;
  163. /// @}
  164. /// \name Construction
  165. /// @{
  166. public:
  167. wrong_value_type_exception(char const* reason, error_code_type err, ws_dword_t type)
  168. : parent_class_type(reason, err)
  169. , m_valueType(type)
  170. {}
  171. wrong_value_type_exception(char const* reason, error_code_alt_type err, ws_dword_t type)
  172. : parent_class_type(reason, err)
  173. , m_valueType(type)
  174. {}
  175. /// @}
  176. /// \name Accessors
  177. /// @{
  178. public:
  179. /// \brief The actual type of the value
  180. ws_dword_t actual_value_type() const
  181. {
  182. return m_valueType;
  183. }
  184. /// @}
  185. /// \name Members
  186. /// @{
  187. private:
  188. const ws_dword_t m_valueType;
  189. /// @}
  190. /// \name Not to be implemented
  191. /// @{
  192. private:
  193. class_type& operator =(class_type const&);
  194. /// @}
  195. };
  196. /** \brief Indicates insufficient rights to access a registry key.
  197. *
  198. * \ingroup group__library__windows_registry
  199. */
  200. class access_denied_exception
  201. : public registry_exception
  202. {
  203. /// \name Member Types
  204. /// @{
  205. public:
  206. typedef registry_exception parent_class_type;
  207. typedef access_denied_exception class_type;
  208. /// @}
  209. /// \name Construction
  210. /// @{
  211. public:
  212. access_denied_exception(char const* reason, error_code_type err)
  213. : parent_class_type(reason, err)
  214. {}
  215. access_denied_exception(char const* reason, error_code_alt_type err)
  216. : parent_class_type(reason, err)
  217. {}
  218. /// @}
  219. /// \name Not to be implemented
  220. /// @{
  221. private:
  222. class_type& operator =(class_type const&);
  223. /// @}
  224. };
  225. /* ////////////////////////////////////////////////////////////////////// */
  226. #ifndef _WINSTL_NO_NAMESPACE
  227. # if defined(_STLSOFT_NO_NAMESPACE) || \
  228. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  229. } // namespace winstl
  230. # else
  231. } // namespace winstl_project
  232. } // namespace stlsoft
  233. # endif /* _STLSOFT_NO_NAMESPACE */
  234. #endif /* !_WINSTL_NO_NAMESPACE */
  235. /* ////////////////////////////////////////////////////////////////////// */
  236. #endif /* WINSTL_INCL_WINSTL_REGISTRY_ERROR_HPP_EXCEPTIONS */
  237. /* ///////////////////////////// end of file //////////////////////////// */