_stdexcept_base.h revision 013fff3524b2798e9d45aefcc13236021da234db
1/*
2 * Copyright (c) 1996,1997
3 * Silicon Graphics Computer Systems, Inc.
4 *
5 * Copyright (c) 1999
6 * Boris Fomitchev
7 *
8 * This material is provided "as is", with absolutely no warranty expressed
9 * or implied. Any use is at your own risk.
10 *
11 * Permission to use or copy this software for any purpose is hereby granted
12 * without fee, provided the above notices are retained on all copies.
13 * Permission to modify the code and to distribute modified code is granted,
14 * provided the above notices are retained, and a notice that the code was
15 * modified is included with the above copyright notice.
16 *
17 */
18
19#ifndef _STLP_INTERNAL_STDEXCEPT_BASE
20#define _STLP_INTERNAL_STDEXCEPT_BASE
21
22#if !defined (_STLP_USE_NATIVE_STDEXCEPT) || defined (_STLP_USE_OWN_NAMESPACE)
23
24#  ifndef _STLP_INTERNAL_EXCEPTION
25#    include <stl/_exception.h>
26#  endif
27
28#  if defined(_STLP_USE_EXCEPTIONS)
29
30#    ifndef _STLP_INTERNAL_CSTRING
31#      include <stl/_cstring.h>
32#    endif
33
34#    ifndef _STLP_STRING_FWD_H
35#      include <stl/_string_fwd.h>
36#    endif
37
38#    ifndef _STLP_USE_NO_IOSTREAMS
39#      define _STLP_OWN_STDEXCEPT 1
40#    endif
41
42_STLP_BEGIN_NAMESPACE
43
44/* We disable the 4275 warning for
45 *  - WinCE where there are only static version of the native C++ runtime.
46 *  - The MSVC compilers when the STLport user wants to make an STLport dll linked to
47 *    the static C++ native runtime. In this case the std::exception base class is no more
48 *    exported from native dll but is used as a base class for the exported __Named_exception
49 *    class.
50 */
51#    if defined (_STLP_WCE_NET) || \
52        defined (_STLP_USE_DYNAMIC_LIB) && defined (_STLP_USING_CROSS_NATIVE_RUNTIME_LIB)
53#      define _STLP_DO_WARNING_POP
54#      pragma warning (push)
55#      pragma warning (disable: 4275) // Non dll interface class 'exception' used as base
56                                      // for dll-interface class '__Named_exception'
57#    endif
58
59#    if !defined (_STLP_NO_EXCEPTION_HEADER)
60#      if !defined (_STLP_EXCEPTION_BASE) && !defined (_STLP_BROKEN_EXCEPTION_CLASS) && \
61           defined (_STLP_USE_NAMESPACES) &&  defined (_STLP_USE_OWN_NAMESPACE)
62using _STLP_VENDOR_EXCEPT_STD::exception;
63#      endif
64#    endif
65#    define _STLP_EXCEPTION_BASE exception
66
67class _STLP_CLASS_DECLSPEC __Named_exception : public _STLP_EXCEPTION_BASE {
68public:
69  __Named_exception(const string& __str);
70  __Named_exception(const __Named_exception&);
71  __Named_exception& operator = (const __Named_exception&);
72
73  const char* what() const _STLP_NOTHROW_INHERENTLY;
74  ~__Named_exception() _STLP_NOTHROW_INHERENTLY;
75
76private:
77  enum { _S_bufsize = 256 };
78  char _M_static_name[_S_bufsize];
79  char *_M_name;
80};
81
82#    if defined (_STLP_USE_NO_IOSTREAMS) && !defined (__BUILDING_STLPORT)
83       // if not linking to the lib, expose implementation of members here
84#      include <stl/_stdexcept_base.c>
85#    endif
86
87#    if defined (_STLP_DO_WARNING_POP)
88#      pragma warning (pop)
89#      undef _STLP_DO_WARNING_POP
90#    endif
91
92_STLP_END_NAMESPACE
93
94#  endif /* _STLP_USE_EXCEPTIONS */
95#endif
96
97#endif /* _STLP_INTERNAL_STDEXCEPT_BASE */
98