/**
 * @file
 * @brief Run-time type information support header
 * @date 13.07.12
 * @author Ilia Vaprol
 */

#ifndef STANDALONE_TYPEINFO_
#define STANDALONE_TYPEINFO_

#if defined(__EXCEPTIONS) && __EXCEPTIONS==1
#error Exceptions must be disabled
#endif

#include <exception>

extern "C++" {

namespace std {

	class type_info {
	public:
		virtual ~type_info() { }
		const char* name() const { return t_name; }
		bool before(const type_info& rhs) const { return name() < rhs.name(); }
		bool operator ==(const type_info& rhs) const { return name() == rhs.name(); }
		bool operator !=(const type_info& rhs) const { return !operator ==(rhs); }
	protected:
		const char *t_name;
		explicit type_info(const char* name) : t_name(name) { }
	private:
		// These are private, preventing type_info values from being copiable
		type_info(const type_info& rhs);
		type_info& operator =(const type_info& rhs);
	};

	class bad_cast : public exception {
	public:
		bad_cast() throw() { }
		virtual ~bad_cast() throw() { }
		virtual const char* what() const throw() { return "std::bad_cast"; }
	};

	class bad_typeid : public exception {
	public:
		bad_typeid() throw() { }
		virtual ~bad_typeid() throw() { }
		virtual const char* what() const throw() { return "std::bad_typeid"; }
	};

} // namespace std

} // extern "C++"

#endif // STANDALONE_TYPEINFO_
