From 2d08d8037d3b7b52fcbd66ef4e65ff432ad2d97d Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sun, 31 Mar 2013 22:41:48 +0200 Subject: Added TypeInfo class. (bzr r11608.1.62) --- src/type-info.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/type-info.cpp (limited to 'src/type-info.cpp') diff --git a/src/type-info.cpp b/src/type-info.cpp new file mode 100644 index 000000000..dac61e786 --- /dev/null +++ b/src/type-info.cpp @@ -0,0 +1,49 @@ +#include "type-info.h" + + +TypeInfo::TypeInfo(const std::type_info& type_info) : type_info(&type_info) { +} + +TypeInfo::TypeInfo(const TypeInfo& tinfo) : type_info(tinfo.type_info) { +} + +TypeInfo& TypeInfo::operator=(const TypeInfo& rhs) { + this->type_info = rhs.type_info; + return *this; +} + +bool TypeInfo::before(const TypeInfo& tinfo) const { + return this->type_info->before(*tinfo.type_info); +} + +const char* TypeInfo::name() const { + return this->type_info->name(); +} + +const std::type_info& TypeInfo::get() const { + return *this->type_info; +} + +bool operator==(const TypeInfo& lhs, const TypeInfo& rhs) { + return lhs.get() == rhs.get(); +} + +bool operator!=(const TypeInfo& lhs, const TypeInfo& rhs) { + return !(lhs == rhs); +} + +bool operator<(const TypeInfo& lhs, const TypeInfo& rhs) { + return lhs.before(rhs); +} + +bool operator<=(const TypeInfo& lhs, const TypeInfo& rhs) { + return !(lhs > rhs); +} + +bool operator>(const TypeInfo& lhs, const TypeInfo& rhs) { + return rhs < lhs; +} + +bool operator>=(const TypeInfo& lhs, const TypeInfo& rhs) { + return !(lhs < rhs); +} -- cgit v1.2.3