home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / lib / g++-include / exception < prev    next >
Text File  |  1994-12-22  |  2KB  |  75 lines

  1. // Methods for Exception Support for -*- C++ -*-
  2. // Copyright (C) 1994 Free Software Foundation
  3.  
  4. // This file is part of the GNU ANSI C++ Library.  This library is free
  5. // software; you can redistribute it and/or modify it under the
  6. // terms of the GNU General Public License as published by the
  7. // Free Software Foundation; either version 2, or (at your option)
  8. // any later version.
  9.  
  10. // This library is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14.  
  15. // You should have received a copy of the GNU General Public License
  16. // along with GNU CC; see the file COPYING.  If not, write to
  17. // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19. // As a special exception, if you link this library with files
  20. // compiled with a GNU compiler to produce an executable, this does not cause
  21. // the resulting executable to be covered by the GNU General Public License.
  22. // This exception does not however invalidate any other reasons why
  23. // the executable file might be covered by the GNU General Public License.
  24.  
  25. // Written by Mike Stump based upon the specification in the 20 September 1994
  26. // C++ working paper, ANSI document X3J16/94-0158.
  27.  
  28. #ifndef __exception__
  29. #define __exception__
  30. /* #include <string> */
  31.  
  32. typedef char *string;
  33.  
  34. class exception {
  35. public:
  36.   typedef void (*raise_handler)(exception&);
  37.   static raise_handler set_raise_handler(raise_handler handler_arg);
  38.   exception(const string& what_arg);
  39.   virtual ~exception() { }
  40.   void raise();
  41.   virtual string what() const { return "exception"; }
  42. protected:
  43.   exception() { }
  44.   virtual void do_raise() { }
  45. };
  46.  
  47. class logic : public exception {
  48. public:
  49.   logic(const string& what_arg) { }
  50.   virtual ~logic() { }
  51.   /* XXX Remove this sometime. */
  52.   logic() { }
  53. };
  54.  
  55. class runtime : public exception {
  56. public:
  57.   runtime(const string& what_arg) { }
  58.   virtual ~runtime() { }
  59. protected:
  60.   runtime();
  61. };
  62.  
  63. class bad_cast : public logic {
  64. public:
  65.   bad_cast(const string& what_arg);
  66.   virtual ~bad_cast() { }
  67.   virtual string what() const { return "bad_cast"; }
  68.  
  69.   /* XXX Remove this sometime. */
  70.   bad_cast() { }
  71. };
  72.  
  73. extern bad_cast __bad_cast_object;
  74. #endif
  75.