/*
 * Copyright (c) 1996,1997
 * Silicon Graphics Computer Systems, Inc.
 *
 * Copyright (c) 1999 
 * Boris Fomitchev
 *
 * This material is provided "as is", with absolutely no warranty expressed
 * or implied. Any use is at your own risk.
 *
 * Permission to use or copy this software for any purpose is hereby granted 
 * without fee, provided the above notices are retained on all copies.
 * Permission to modify the code and to distribute modified code is granted,
 * provided the above notices are retained, and a notice that the code was
 * modified is included with the above copyright notice.
 *
 */

#ifndef __SGI_STDEXCEPT

# ifndef __BORLANDC__
#  define __SGI_STDEXCEPT 1
# endif

#ifndef __STL_CONFIG_H
#include <stl_config.h>
#endif

/* recursive */
# ifdef __SGI_STDEXCEPT_SEEN
#  define __DONT_RESUME_STD_FOR_STDEXCEPT
# endif


# if !defined(__SGI_STDEXCEPT_SEEN) && \
   (!defined (__STL_USE_NATIVE_STDEXCEPT) || defined (__STL_USE_OWN_NAMESPACE))

# ifdef __BORLANDC__
#  define __SGI_STDEXCEPT_SEEN 1
# endif

#if !defined (__STLPORT_DEBUG_H) && (defined  (__STL_DEBUG) || defined (__STL_ASSERTIONS))
# include <stldebug.h>
#endif

#  include <exception>

#if defined(__STL_USE_EXCEPTIONS) || \
    !(defined(_MIPS_SIM) && defined(_ABIO32) && _MIPS_SIM == _ABIO32)


#ifndef __STLPORT_CSTRING
# include <cstring>
#endif

#ifndef __SGI_STL_STRING_FWD_H
# include <stl_string_fwd.h>
#endif

__STL_BEGIN_NAMESPACE

class __Named_exception : public __STL_EXCEPTION_BASE {
public:
  __Named_exception(const string& __str) {
    strncpy(_M_name, __get_c_string(__str), _S_bufsize);
    _M_name[_S_bufsize - 1] = '\0';
  }
  virtual const char* what() const __STL_NOTHROW { return _M_name; }

private:
  enum { _S_bufsize = 256 };
  char _M_name[_S_bufsize];
};

class logic_error : public __Named_exception {
public:
  logic_error(const string& __s) : __Named_exception(__s) {}
};

class runtime_error : public __Named_exception {
public:
  runtime_error(const string& __s) : __Named_exception(__s) {}
};

class domain_error : public logic_error {
public:
  domain_error(const string& __arg) : logic_error(__arg) {}
};

class invalid_argument : public logic_error {
public:
  invalid_argument(const string& __arg) : logic_error(__arg) {}
};

class length_error : public logic_error {
public:
  length_error(const string& __arg) : logic_error(__arg) {}
};

class out_of_range : public logic_error {
public:
  out_of_range(const string& __arg) : logic_error(__arg) {}
};

class range_error : public runtime_error {
public:
  range_error(const string& __arg) : runtime_error(__arg) {}
};

class overflow_error : public runtime_error {
public:
  overflow_error(const string& __arg) : runtime_error(__arg) {}
};

class underflow_error : public runtime_error {
public:
  underflow_error(const string& __arg) : runtime_error(__arg) {}
};

__STL_END_NAMESPACE

#endif /* Not o32, and no exceptions */
#endif /* __STL_USE_NATIVE_STDEXCEPT */

#if defined (__STL_USE_NATIVE_STDEXCEPT)

#  if defined ( __STL_REDEFINE_STD ) && defined (std) 
#    undef std
#    define __STL_RESUME_STD_FOR_STDEXCEPT
#    define __STLPORT_NATIVE_PASS
#  endif

#  include __STL_NATIVE_HEADER(stdexcept)

# if defined ( __STL_RESUME_STD_FOR_STDEXCEPT ) && ! defined (__DONT_RESUME_STD_FOR_STDEXCEPT)
#    undef __STL_RESUME_STD_FOR_STDEXCEPT
#    define std __STLPORT_NAMESPACE
#    undef __STLPORT_NATIVE_PASS
# endif

# endif /* __STL_USE_NATIVE_STDEXCEPT */

# ifdef __BORLANDC__
#  undef  __SGI_STDEXCEPT_SEEN
#  define __SGI_STDEXCEPT 1
#  undef __DONT_RESUME_STD_FOR_STDEXCEPT
# else
// this inclusion is apparently needed for MSVC
# ifndef __SGI_STL_STRING
#  include <string>
# endif
# endif

#endif /* __SGI_STDEXCEPT */

// Local Variables:
// mode:C++
// End:
