home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / stdexcep.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  5.2 KB  |  186 lines

  1. /* This file is included specially and does not have a normal header guard */
  2. #pragma option push -b -a8 -pc -Vx- -Ve- -w-inl -w-aus -w-sig
  3. // -*- C++ -*-
  4. #ifndef __STD_STDEXCEPT
  5.  
  6. /***************************************************************************
  7.  *
  8.  * stdexcept - declarations for the Standard Library standard exception class
  9.  *
  10.  ***************************************************************************
  11.  *
  12.  * Copyright (c) 1994-1999 Rogue Wave Software, Inc.  All Rights Reserved.
  13.  *
  14.  * This computer software is owned by Rogue Wave Software, Inc. and is
  15.  * protected by U.S. copyright laws and other laws and by international
  16.  * treaties.  This computer software is furnished by Rogue Wave Software,
  17.  * Inc. pursuant to a written license agreement and may be used, copied,
  18.  * transmitted, and stored only in accordance with the terms of such
  19.  * license and with the inclusion of the above copyright notice.  This
  20.  * computer software or any other copies thereof may not be provided or
  21.  * otherwise made available to any other person.
  22.  *
  23.  * U.S. Government Restricted Rights.  This computer software is provided
  24.  * with Restricted Rights.  Use, duplication, or disclosure by the
  25.  * Government is subject to restrictions as set forth in subparagraph (c)
  26.  * (1) (ii) of The Rights in Technical Data and Computer Software clause
  27.  * at DFARS 252.227-7013 or subparagraphs (c) (1) and (2) of the
  28.  * Commercial Computer Software รป Restricted Rights at 48 CFR 52.227-19,
  29.  * as applicable.  Manufacturer is Rogue Wave Software, Inc., 5500
  30.  * Flatiron Parkway, Boulder, Colorado 80301 USA.
  31.  *
  32.  **************************************************************************/
  33.  
  34. #include <stdcomp.h>
  35. #include <string>
  36. #ifndef __RWSTD_EXCEPT_SEEN
  37. #include <exception>
  38.  
  39. #ifndef _RWSTD_NO_NAMESPACE 
  40. namespace std {
  41. #endif
  42.  
  43. // MSVC provides its own exception class and logic_error class.  
  44. // In order to allow the use of MSVC classes derived from these
  45. // We have to use them to, instead of our own.  The drawback is 
  46. // that we don't have a logic_error(const string&) constructor any
  47. // more.  Now we have a logic_error(const char *) constructor.
  48.  
  49. #ifndef _RWSTD_LOGIC_ERROR_DEFINED
  50.   class _RWSTDExport logic_error : public exception
  51.   {
  52.   public:
  53.     logic_error (const string& what_arg)  _RWSTD_THROW_SPEC_NULL       
  54.     : str_(what_arg)
  55.     { ; }
  56.  
  57.     virtual ~logic_error ()  _RWSTD_THROW_SPEC_NULL;
  58.  
  59.     virtual const char * what () const  _RWSTD_THROW_SPEC_NULL
  60.     {
  61.       return str_.data();
  62.     }
  63.  
  64.   private:
  65.     string str_;
  66.   };
  67. #endif
  68.  
  69.   class _RWSTDExport domain_error : public logic_error
  70.   {
  71.   public:
  72.     domain_error (const string& what_arg) _RWSTD_THROW_SPEC_NULL 
  73. #ifndef _RWSTD_LOGIC_ERROR_DEFINED
  74.     : logic_error(what_arg) {;}
  75. #else
  76.     : logic_error(what_arg.c_str()) {;}
  77. #endif
  78.  
  79.     virtual ~domain_error ()  _RWSTD_THROW_SPEC_NULL;
  80.   };
  81.  
  82.   class _RWSTDExport invalid_argument : public logic_error
  83.   {
  84.   public:
  85.     invalid_argument (const string& what_arg) _RWSTD_THROW_SPEC_NULL 
  86. #ifndef  _RWSTD_LOGIC_ERROR_DEFINED
  87.     : logic_error(what_arg) {;}
  88. #else
  89.     : logic_error(what_arg.c_str()) {;}
  90. #endif
  91.  
  92.     virtual ~invalid_argument ()  _RWSTD_THROW_SPEC_NULL;
  93.   };
  94.  
  95.   class _RWSTDExport length_error : public logic_error
  96.   {
  97.   public:
  98.     length_error (const string& what_arg) _RWSTD_THROW_SPEC_NULL 
  99. #ifndef  _RWSTD_LOGIC_ERROR_DEFINED
  100.     : logic_error(what_arg) {;}
  101. #else
  102.     : logic_error(what_arg.c_str()) {;}
  103. #endif
  104.  
  105.     virtual ~length_error ()  _RWSTD_THROW_SPEC_NULL;
  106.   };
  107.  
  108.   class _RWSTDExport out_of_range : public logic_error
  109.   {
  110.   public:
  111.     out_of_range (const string& what_arg) _RWSTD_THROW_SPEC_NULL 
  112. #ifndef  _RWSTD_LOGIC_ERROR_DEFINED
  113.     : logic_error(what_arg) {;}
  114. #else
  115.     : logic_error(what_arg.c_str()) {;}
  116. #endif
  117.  
  118.     virtual ~out_of_range ()  _RWSTD_THROW_SPEC_NULL;
  119.   };
  120.  
  121.   class _RWSTDExport runtime_error : public exception
  122.   {
  123.   public:
  124.     runtime_error (const string& what_arg) _RWSTD_THROW_SPEC_NULL  
  125.     : str_(what_arg)
  126.     { ; }
  127.  
  128.     virtual ~runtime_error ()  _RWSTD_THROW_SPEC_NULL;
  129.  
  130.     virtual const char * what () const  _RWSTD_THROW_SPEC_NULL
  131.     {
  132.       return str_.data();
  133.     }
  134.  
  135.   private:
  136.     string str_;
  137.   };
  138.  
  139.   class _RWSTDExport range_error : public runtime_error
  140.   {
  141.   public:
  142.     range_error (const string& what_arg) _RWSTD_THROW_SPEC_NULL 
  143.     : runtime_error(what_arg) {;}
  144.  
  145.     virtual ~range_error ()  _RWSTD_THROW_SPEC_NULL;
  146.   };
  147.  
  148.   class _RWSTDExport overflow_error : public runtime_error
  149.   {
  150.   public:
  151.     overflow_error (const string& what_arg) _RWSTD_THROW_SPEC_NULL 
  152.     : runtime_error(what_arg) {;}
  153.  
  154.     virtual ~overflow_error ()  _RWSTD_THROW_SPEC_NULL;
  155.   };
  156.  
  157.   class _RWSTDExport underflow_error : public runtime_error
  158.   {
  159.   public:
  160.     underflow_error (const string& what_arg) _RWSTD_THROW_SPEC_NULL 
  161.     : runtime_error(what_arg) {;}
  162.  
  163.     virtual ~underflow_error ()  _RWSTD_THROW_SPEC_NULL;
  164.   };
  165.  
  166. #ifndef _RWSTD_NO_NAMESPACE 
  167. #endif
  168.  
  169. #define __RWSTD_EXCEPT_SEEN
  170.  
  171. #endif //__RWSTD_EXCEPT_SEEN
  172.  
  173. //
  174. // Yes, the complete file has been processed!
  175. //
  176. #define __STD_STDEXCEPT
  177.  
  178. #endif //__STD_STDEXCEPT
  179.  
  180. #pragma option pop
  181.  
  182. #ifndef __USING_STD_NAMES__
  183.   using namespace std;
  184. #endif
  185.