|
|
|
| 1 |
|
// exception standard header for Microsoft |
| 2 |
|
#pragma once |
| 3 |
|
#ifndef _EXCEPTION_ |
| 4 |
|
#define _EXCEPTION_ |
| 5 |
|
#ifndef RC_INVOKED |
| 6 |
|
|
| 7 |
|
#include <xstddef> |
| 8 |
|
|
| 9 |
|
#ifdef _MSC_VER |
| 10 |
|
#pragma pack(push,_CRT_PACKING) |
| 11 |
|
#pragma warning(push,3) |
| 12 |
|
#endif /* _MSC_VER */ |
| 13 |
|
|
| 14 |
|
#ifdef _CRT_EXCEPTION_NO_MALLOC |
| 15 |
|
|
| 16 |
|
#pragma push_macro("malloc") |
| 17 |
|
#pragma push_macro("free") |
| 18 |
|
|
| 19 |
|
#undef malloc |
| 20 |
|
#undef free |
| 21 |
|
#endif /* _CRT_EXCEPTION_NO_MALLOC */ |
| 22 |
|
|
| 23 |
|
_STD_BEGIN |
| 24 |
|
|
| 25 |
|
#define _USE_EXCEPTION \ |
| 26 |
|
using _STDEXT exception; |
| 27 |
|
|
| 28 |
|
#define _USE_BAD_EXCEPTION \ |
| 29 |
|
using _STDEXT bad_alloc; \ |
| 30 |
|
using _STDEXT bad_exception; |
| 31 |
|
|
| 32 |
|
#define _USE_EX \ |
| 33 |
|
using ::set_terminate; using ::terminate_handler; using ::terminate; \ |
| 34 |
|
using ::set_unexpected; using ::unexpected_handler; using ::unexpected; |
| 35 |
|
|
| 36 |
|
_STD_END |
| 37 |
|
|
| 38 |
|
#if _HAS_EXCEPTIONS |
| 39 |
|
|
| 40 |
|
#include <eh.h> |
| 41 |
|
#include <malloc.h> |
| 42 |
|
|
| 43 |
|
#if !defined(_WIN32) |
| 44 |
|
#error ERROR: Only Win32 targets supported! |
| 45 |
|
#endif /* !defined(_WIN32) */ |
| 46 |
|
|
| 47 |
|
#ifndef _CRTIMP |
| 48 |
|
|
| 49 |
|
#ifdef _DLL |
| 50 |
|
#define _CRTIMP __declspec(dllimport) |
| 51 |
|
|
| 52 |
|
#else /* ndef _DLL */ |
| 53 |
|
#define _CRTIMP |
| 54 |
|
#endif /* _DLL */ |
| 55 |
|
|
| 56 |
|
#endif /* _CRTIMP */ |
| 57 |
|
|
| 58 |
|
#ifndef _MCRTIMP |
| 59 |
|
#ifdef _DLL |
| 60 |
|
#define _MCRTIMP __declspec(dllimport) |
| 61 |
|
#else /* ndef _DLL */ |
| 62 |
|
#define _MCRTIMP |
| 63 |
|
#endif /* _DLL */ |
| 64 |
|
#endif /* _CRTIMP */ |
| 65 |
|
|
| 66 |
|
#ifndef _CRTIMP_PURE |
| 67 |
|
#if defined(_M_CEE_PURE) || defined(_STATIC_CPPLIB) |
| 68 |
|
#define _CRTIMP_PURE |
| 69 |
|
#else |
| 70 |
|
#define _CRTIMP_PURE _CRTIMP |
| 71 |
|
#endif |
| 72 |
|
#endif |
| 73 |
|
|
| 74 |
|
#ifndef _ERRCODE_DEFINED |
| 75 |
|
#define _ERRCODE_DEFINED |
| 76 |
|
/* errcode is deprecated in favor or errno_t, which is part of the standard proposal */ |
| 77 |
|
_CRT_OBSOLETE(errno_t) typedef int errcode; |
| 78 |
|
typedef int errno_t; |
| 79 |
|
#endif |
| 80 |
|
|
| 81 |
|
|
| 82 |
|
typedef const char *__exString; |
| 83 |
|
extern "C" _Check_return_ size_t __cdecl strlen(_In_z_ const char *); |
| 84 |
|
#if __STDC_WANT_SECURE_LIB__ |
| 85 |
|
extern "C" _CRTIMP_ALTERNATIVE errno_t __cdecl strcpy_s(_Out_z_cap_(_SizeInBytes) char * _Dst, _In_ size_t _SizeInBytes, _In_z_ const char * _Src); |
| 86 |
|
#define _CRT_SECURE_STRCPY(dest, destsize, source) ::strcpy_s((dest), (destsize), (source)) |
| 87 |
|
#else |
| 88 |
|
extern "C" char * __cdecl strcpy(_Pre_cap_for_(_Source) _Post_z_ char *_Dst, _In_z_ const char *_Source); |
| 89 |
|
#define _CRT_SECURE_STRCPY(dest, destsize, source) ::strcpy((dest), (source)) |
| 90 |
|
#endif |
| 91 |
|
|
| 92 |
|
_STD_BEGIN |
| 93 |
|
|
| 94 |
|
class _CRTIMP_PURE exception |
| 95 |
|
{ // base of all library exceptions |
| 96 |
|
public: |
| 97 |
|
#ifdef _M_CEE_PURE |
| 98 |
|
__CLR_OR_THIS_CALL exception() |
| 99 |
|
: _m_what(NULL), _m_doFree(0) |
| 100 |
|
{ } |
| 101 |
|
__CLR_OR_THIS_CALL exception(const char *const& _What) |
| 102 |
|
{ |
| 103 |
|
if (_What != NULL) |
| 376 |
|
{ // construct from message string with no memory allocation |
| 377 |
|
} |
| 378 |
|
|
| 379 |
|
virtual __CLR_OR_THIS_CALL ~bad_alloc() _THROW0() |
| 380 |
|
{ // destroy the object |
| 381 |
|
} |
| 382 |
|
|
| 383 |
|
#if !_HAS_EXCEPTIONS |
| 384 |
|
protected: |
| 385 |
|
virtual void __CLR_OR_THIS_CALL _Doraise() const |
| 386 |
|
{ // perform class-specific exception handling |
| 387 |
|
_RAISE(*this); |
| 388 |
|
} |
| 389 |
|
#endif /* _HAS_EXCEPTIONS */ |
| 390 |
|
|
| 391 |
|
}; |
| 392 |
|
|
| 393 |
|
#if _HAS_EXCEPTIONS |
| 394 |
|
_STD_END |
| 395 |
|
#else |
| 396 |
|
_STDEXT_END |
| 397 |
|
|
| 398 |
|
_STD_BEGIN |
| 399 |
|
|
| 400 |
|
_USE_BAD_EXCEPTION |
| 401 |
|
|
| 402 |
|
_STD_END |
| 403 |
|
|
| 404 |
|
#endif |
| 405 |
|
|
| 406 |
|
#ifdef _CRT_EXCEPTION_NO_MALLOC |
| 407 |
|
|
| 408 |
|
#pragma pop_macro("free") |
| 409 |
|
#pragma pop_macro("malloc") |
| 410 |
|
|
| 411 |
|
#endif /* _CRT_EXCEPTION_NO_MALLOC */ |
| 412 |
|
#ifdef _MSC_VER |
| 413 |
|
#pragma warning(pop) |
| 414 |
|
#pragma pack(pop) |
| 415 |
|
#endif |
| 416 |
|
|
| 417 |
|
#endif /* RC_INVOKED */ |
| 418 |
|
#endif /* _EXCEPTION_ */ |
| 419 |
|
|
| 420 |
|
/* |
| 421 |
|
* Copyright (c) 1992-2007 by P.J. Plauger. ALL RIGHTS RESERVED. |
| 422 |
|
* Consult your license regarding permissions and restrictions. |
| 423 |
|
V5.03:0009 */ |
| 424 |
|
|
|
|
|