//////////////////////////////////////////////////////////////////////////
//                                                                      //
//               NeuroMatrix(r) STD (C++ Standard Library)              //
//                                                                      //
//  typeinfo                                                            //
//                                                                      //
// Copyright (c) 1998-2008 RC Module                                    //
//  If this code works, it was written by Alex Ruzavin                  //
//  If not, I don't know who wrote it.                                  //
//                                                                      //
// $Revision:: 1     $      $Date:: 7/21/05 5:28p    $                  //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef __IS_STD_TYPEINFO
#define __IS_STD_TYPEINFO

#include <exception>

_NS_STD_BEGIN

#if defined(__NM6403__) || defined(__NM6405__)

class type_info
{
public:
    virtual ~type_info();

    bool operator==(const type_info& rhs) const
    {
        return this == &rhs;
    }

    bool operator!=(const type_info& rhs) const
    {
        return !(*this == rhs);
    }

    bool before(const type_info& rhs) const
    {
        return this < &rhs;
    }

    const char* name() const
    {
        return (const char*)(this + 1);
    }

private:
    type_info(const type_info&);
    type_info& operator=(const type_info&);
};

#elif defined(NM6403) || defined(NM6404) || defined(NM6405)

    class type_info {
    public:
      virtual ~type_info();
      bool operator==(const type_info& rhs) const;
      bool operator!=(const type_info& rhs) const;
      bool before(const type_info& rhs) const;
      const char* name() const;
    private:

      type_info(const type_info&);
      type_info& operator=(const type_info&);

      const char *_name;
    };

#endif

class bad_cast : public exception
{
public:
    bad_cast() throw() { }

    bad_cast(const bad_cast& rhs) throw()
        : exception(rhs)
    {}

    bad_cast& operator=(const bad_cast& rhs) throw()
    {
        exception::operator=(rhs);
        return *this;
    }

    virtual ~bad_cast() throw() { }

    virtual const char* what() const throw()
    {
        return "dynamic_cast<>() form NULL pointer";
    }
};

class bad_typeid : public exception
{
public:
    bad_typeid() throw() { }

    bad_typeid(const bad_typeid& rhs) throw()
        : exception(rhs)
    {}

    bad_typeid& operator=(const bad_typeid& rhs) throw()
    {
        exception::operator=(rhs);
        return *this;
    }

    virtual ~bad_typeid() throw() { }

    virtual const char* what() const throw()
    {
        return "typeid() form NULL pointer";
    }
};

_NS_STD_END

#endif // __IS_STD_TYPEINFO
