//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/****
*
*typeinfo - Defines the type_info structure and exceptions used for RTTI
*
*
*Purpose:
*       Defines the type_info structure and exceptions used for
*       Runtime Type Identification.
*
*       [Public]
*
*Revision History:
*       09/16/94  SB    Created
*       10/04/94  SB    Implemented bad_cast() and bad_typeid()
*       10/05/94  JWM   Added __non_rtti_object(), made old modena names 
*                       #ifdef __RTTI_OLDNAMES
*       11/11/94  JWM   Made typeinfo class & exception classes _CRTIMP, 
*                       removed #include <windows.h>
*       11/15/94  JWM   Moved include of stdexcpt.h below the definition of 
*                       class type_info (workaround for compiler bug)
*       02-14-95  CFW   Clean up Mac merge.
*       02/15/95  JWM   Class type_info no longer _CRTIMP, member functions 
*                       are exported instead
*       02/27/95  JWM   Class type_info now defined in ti_core.h
*       03/03/95  CFW   Bring core stuff back in, use _TICORE.
*       07/02/95  JWM   Cleaned up for ANSI compatibility.
*       12-14-95  JWM   Add "#pragma once".
*       02-21-97  GJF   Cleaned out obsolete support for _NTSDK. Also, 
*                       detab-ed and reformatted the header a bit.
*       02/10/01  PT    Created typeinfo from typeinfo.h
*
****/

#if     _MSC_VER > 1000 /*IFSTRIP=IGN*/
#pragma once
#endif

#ifndef __cplusplus
#error This header requires a C++ compiler ...
#endif

#ifndef _INC_TYPEINFO
#define _INC_TYPEINFO

#include <libdefs>
#include <exception>

// Make sure of good packing
#pragma pack(push,8)


// Return type from typeid operator, according to the standard
// this should really be in namespace std, but the compiler
// has built-in knowledge about this class.  Do not modify
// anything here without checking the layout of RTTI information
// generated by the compiler.

class type_info {
public:
    _CRTIMP virtual ~type_info();
    _CRTIMP int operator==(const type_info& rhs) const;
    _CRTIMP int operator!=(const type_info& rhs) const;
    _CRTIMP int before(const type_info& rhs) const;
    _CRTIMP const char* name() const;
    _CRTIMP const char* raw_name() const;
private:
    void* _m_data;
    char _m_d_name[1];
    type_info(const type_info& rhs);
    type_info& operator=(const type_info& rhs);
};

_STDDEFS_BEGIN

class _CRTIMP bad_cast : public exception {
public:
    bad_cast(const char* what_arg = "bad cast") throw() : exception (what_arg) {}
    virtual ~bad_cast() throw() {}
};

class _CRTIMP bad_typeid : public exception {
public:
    bad_typeid(const char* what_arg = "bad typeid") throw() : exception (what_arg) {}
    virtual ~bad_typeid() throw() {}
};

class _CRTIMP __non_rtti_object : public bad_typeid {
public:
    __non_rtti_object(const char* what_arg) : bad_typeid(what_arg) {}
};

_STDDEFS_END

#pragma pack(pop)

#endif  // _INC_TYPEINFO
