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.

195 lines
5.9 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: stlsoft/error/iteration_interruption.hpp
  3. *
  4. * Purpose: An exception thrown when an active end iterator is exhausted.
  5. *
  6. * Created: 30th November 2005
  7. * Updated: 10th August 2009
  8. *
  9. * Home: http://stlsoft.org/
  10. *
  11. * Copyright (c) 2005-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 stlsoft/error/iteration_interruption.hpp
  40. *
  41. * \brief [C++ only] Definition of the stlsoft::iteration_interruption
  42. * exception class
  43. * (\ref group__library__error "Error" Library).
  44. */
  45. #ifndef STLSOFT_INCL_STLSOFT_ERROR_HPP_ITERATION_INTERRUPTION
  46. #define STLSOFT_INCL_STLSOFT_ERROR_HPP_ITERATION_INTERRUPTION
  47. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  48. # define STLSOFT_VER_STLSOFT_ERROR_HPP_ITERATION_INTERRUPTION_MAJOR 2
  49. # define STLSOFT_VER_STLSOFT_ERROR_HPP_ITERATION_INTERRUPTION_MINOR 0
  50. # define STLSOFT_VER_STLSOFT_ERROR_HPP_ITERATION_INTERRUPTION_REVISION 3
  51. # define STLSOFT_VER_STLSOFT_ERROR_HPP_ITERATION_INTERRUPTION_EDIT 15
  52. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  53. /* /////////////////////////////////////////////////////////////////////////
  54. * Auto-generation and compatibility
  55. */
  56. /* /////////////////////////////////////////////////////////////////////////
  57. * Includes
  58. */
  59. #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
  60. # include <stlsoft/stlsoft.h>
  61. #endif /* !STLSOFT_INCL_STLSOFT_H_STLSOFT */
  62. #ifndef STLSOFT_INCL_STDEXCEPT
  63. # define STLSOFT_INCL_STDEXCEPT
  64. # include <stdexcept>
  65. #endif /* !STLSOFT_INCL_STDEXCEPT */
  66. /* /////////////////////////////////////////////////////////////////////////
  67. * Namespace
  68. */
  69. #ifndef _STLSOFT_NO_NAMESPACE
  70. namespace stlsoft
  71. {
  72. #endif /* _STLSOFT_NO_NAMESPACE */
  73. /* /////////////////////////////////////////////////////////////////////////
  74. * Classes
  75. */
  76. /** \brief An exception thrown when an active iterator is interrupted, by the underlying range
  77. * changing outside direct control by the current thread of execution
  78. *
  79. * \ingroup group__library__error
  80. */
  81. class iteration_interruption
  82. : public stlsoft_ns_qual_std(runtime_error)
  83. {
  84. /// \name Member Types
  85. /// @{
  86. public:
  87. typedef stlsoft_ns_qual_std(runtime_error) parent_class_type;
  88. typedef iteration_interruption class_type;
  89. /// @}
  90. /// \name Construction
  91. /// @{
  92. public:
  93. iteration_interruption()
  94. : parent_class_type("")
  95. , m_errorCode(0)
  96. {}
  97. ss_explicit_k iteration_interruption(char const* message)
  98. : parent_class_type(message)
  99. , m_errorCode(0)
  100. {}
  101. iteration_interruption(char const* message, long errorCode)
  102. : parent_class_type(message)
  103. , m_errorCode(errorCode)
  104. {}
  105. virtual ~iteration_interruption() throw()
  106. {}
  107. /// @}
  108. /// \name Accessors
  109. /// @{
  110. public:
  111. virtual char const* what() const throw()
  112. {
  113. char const* message = parent_class_type::what();
  114. #if 0
  115. if( NULL == message ||
  116. '\0' == *message)
  117. #endif /* 0 */
  118. {
  119. message = this->real_what_();
  120. }
  121. return message;
  122. }
  123. /// The error code associated with the exception
  124. virtual long get_error_code() const throw()
  125. {
  126. return m_errorCode;
  127. }
  128. /// [DEPRECATED] The error code associated with the exception
  129. ///
  130. /// \deprecated Use get_error_code() instead.
  131. virtual long errorCode() const throw()
  132. {
  133. return get_error_code();
  134. }
  135. /// @}
  136. /// \name Implementation
  137. /// @{
  138. private:
  139. virtual char const* real_what_() const throw()
  140. {
  141. return "iteration interruption";
  142. }
  143. /// @}
  144. /// \name Members
  145. /// @{
  146. private:
  147. const long m_errorCode;
  148. /// @}
  149. /// \name Not to be implemented
  150. /// @{
  151. private:
  152. class_type& operator =(class_type const&);
  153. /// @}
  154. };
  155. ////////////////////////////////////////////////////////////////////////////
  156. // Unit-testing
  157. #ifdef STLSOFT_UNITTEST
  158. # include "./unittest/iteration_interruption_unittest_.h"
  159. #endif /* STLSOFT_UNITTEST */
  160. /* ////////////////////////////////////////////////////////////////////// */
  161. #ifndef _STLSOFT_NO_NAMESPACE
  162. } // namespace stlsoft
  163. #endif /* _STLSOFT_NO_NAMESPACE */
  164. /* ////////////////////////////////////////////////////////////////////// */
  165. #endif /* !STLSOFT_INCL_STLSOFT_ERROR_HPP_ITERATION_INTERRUPTION */
  166. /* ///////////////////////////// end of file //////////////////////////// */