home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 May / VPR9705A.ISO / VPR_DATA / PROGRAM / CBTRIAL / SETUP / DATA.Z / STDEXCEP.H < prev    next >
C/C++ Source or Header  |  1997-02-14  |  5KB  |  151 lines

  1. #ifndef __STD_STDEXCEPT
  2.  
  3. /* $Revision:   8.1  $ */
  4. /***************************************************************************
  5.  *
  6.  * stdexcept - declarations for the Standard Library standard exception class
  7.  *
  8.  * $Id: stdexcept,v 1.21 1995/09/29 23:52:59 smithey Exp $
  9.  *
  10.  ***************************************************************************
  11.  *
  12.  * (c) Copyright 1994, 1995 Rogue Wave Software, Inc.
  13.  * ALL RIGHTS RESERVED
  14.  *
  15.  * The software and information contained herein are proprietary to, and
  16.  * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
  17.  * intends to preserve as trade secrets such software and information.
  18.  * This software is furnished pursuant to a written license agreement and
  19.  * may be used, copied, transmitted, and stored only in accordance with
  20.  * the terms of such license and with the inclusion of the above copyright
  21.  * notice.  This software and information or any other copies thereof may
  22.  * not be provided or otherwise made available to any other person.
  23.  *
  24.  * Notwithstanding any other lease or license that may pertain to, or
  25.  * accompany the delivery of, this computer software and information, the
  26.  * rights of the Government regarding its use, reproduction and disclosure
  27.  * are as set forth in Section 52.227-19 of the FARS Computer
  28.  * Software-Restricted Rights clause.
  29.  *
  30.  * Use, duplication, or disclosure by the Government is subject to
  31.  * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
  32.  * Technical Data and Computer Software clause at DFARS 252.227-7013.
  33.  * Contractor/Manufacturer is Rogue Wave Software, Inc.,
  34.  * P.O. Box 2328, Corvallis, Oregon 97339.
  35.  *
  36.  * This computer software and information is distributed with "restricted
  37.  * rights."  Use, duplication or disclosure is subject to restrictions as
  38.  * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
  39.  * Computer Software-Restricted Rights (April 1985)."  If the Clause at
  40.  * 18-52.227-74 "Rights in Data General" is specified in the contract,
  41.  * then the "Alternate III" clause applies.
  42.  *
  43.  **************************************************************************/
  44.  
  45. #include <stdcomp.h>
  46.  
  47. #include <string>
  48.  
  49. //
  50. // Due to the circular dependency of
  51. // exception -> string -> exception, we must add an extra
  52. // level of indirection here.  We really test to see if the exception
  53. // hierarchy has been completely seen or not.  We're not particular
  54. // interested in whether or not the file has only been opened.
  55. //
  56. #ifndef __RWSTD_EXCEPTION_SEEN
  57.  
  58. #ifndef RWSTD_NO_NAMESPACE
  59. namespace std {
  60. #endif
  61.  
  62. extern char RWSTDExport __rw_stdexcept_NoNamedException[];
  63.  
  64. class RWSTDExport exception
  65. {
  66.   public:
  67.     exception () RWSTD_THROW_SPEC_NULL {;}
  68.     exception (const exception& rhs) RWSTD_THROW_SPEC_NULL { str = rhs.str; }
  69.     exception& operator= (const exception& rhs) RWSTD_THROW_SPEC_NULL
  70.     {
  71.         if (!(this == &rhs))
  72.             str = rhs.str;
  73.         return *this;
  74.     }
  75.     virtual ~exception ()  RWSTD_THROW_SPEC_NULL {;}
  76.     virtual const char * what () const RWSTD_THROW_SPEC_NULL
  77.     {
  78.         return str.size() == 0 ? __rw_stdexcept_NoNamedException : str.data();
  79.     }
  80.   protected:
  81.     exception (const string& what_arg) : str(what_arg) {;}
  82.   private:
  83.     string str;
  84. };
  85.  
  86. class RWSTDExport logic_error : public exception
  87. {
  88.   public:
  89.     logic_error (const string& what_arg) : exception(what_arg) {;}
  90. };
  91.  
  92. class RWSTDExport domain_error : public logic_error
  93. {
  94.   public:
  95.     domain_error (const string& what_arg): logic_error(what_arg) {;}
  96. };
  97.  
  98. class RWSTDExport invalid_argument : public logic_error
  99. {
  100.   public:
  101.     invalid_argument (const string& what_arg): logic_error(what_arg) {;}
  102. };
  103.  
  104. class RWSTDExport length_error : public logic_error
  105. {
  106.   public:
  107.     length_error (const string& what_arg): logic_error(what_arg) {;}
  108. };
  109.  
  110. class RWSTDExport out_of_range : public logic_error
  111. {
  112.   public:
  113.     out_of_range (const string& what_arg): logic_error(what_arg) {;}
  114. };
  115.  
  116. class RWSTDExport runtime_error : public exception
  117. {
  118.   public:
  119.     runtime_error (const string& what_arg): exception(what_arg) {;}
  120. };
  121.  
  122. class RWSTDExport range_error : public runtime_error
  123. {
  124.   public:
  125.     range_error (const string& what_arg): runtime_error(what_arg) {;}
  126. };
  127.  
  128. class RWSTDExport overflow_error : public runtime_error
  129. {
  130.   public:
  131.     overflow_error (const string& what_arg): runtime_error(what_arg) {;}
  132. };
  133.  
  134. #define __RWSTD_EXCEPTION_SEEN
  135.  
  136. #ifndef RWSTD_NO_NAMESPACE
  137. }
  138. #endif
  139.  
  140. //
  141. // Yes, the exception hierarchy has been seen!
  142. //
  143. #endif /*__RWSTD_EXCEPTION_SEEN*/
  144.  
  145. //
  146. // Yes, the complete file has been processed!
  147. //
  148. #define __STD_STDEXCEPT
  149.  
  150. #endif /*__STD_STDEXCEPT*/
  151.