diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-08-03 20:48:45 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-08-03 20:48:45 (GMT) |
| commit | 61739018759847c4d356a7596926652856030306 (patch) | |
| tree | 59dd50893ecb47bfab709d778b8a8a02dfc83331 /src/cat/TPTSTypes.h | |
| parent | f586a5585f3838e78cf6880b84d4c369040b5f67 (diff) | |
| download | powder-61739018759847c4d356a7596926652856030306.zip powder-61739018759847c4d356a7596926652856030306.tar.gz | |
Old TPT console commands with "!" prefix
Diffstat (limited to 'src/cat/TPTSTypes.h')
| -rw-r--r-- | src/cat/TPTSTypes.h | 57 |
1 files changed, 48 insertions, 9 deletions
diff --git a/src/cat/TPTSTypes.h b/src/cat/TPTSTypes.h index ad08f0b..dfea425 100644 --- a/src/cat/TPTSTypes.h +++ b/src/cat/TPTSTypes.h @@ -9,6 +9,7 @@ #define TPTSTYPES_H_ #include <string> +#include <typeinfo> #include "interface/Point.h" enum ValueType { TypeNumber, TypePoint, TypeString, TypeNull, TypeFunction }; @@ -26,15 +27,6 @@ public: } }; -class InvalidConversionException: public GeneralException -{ -private: - ValueType from; - ValueType to; -public: - InvalidConversionException(ValueType from_, ValueType to_): GeneralException("Invalid conversion"), from(from_), to(to_) { - } -}; class NumberType; class StringType; @@ -52,9 +44,56 @@ public: operator StringType(); operator PointType(); ValueType GetType(); + std::string TypeName() + { + switch(type) + { + case TypeNumber: + return "Number"; + case TypePoint: + return "Point"; + case TypeString: + return "String"; + case TypeNull: + return "Null"; + case TypeFunction: + return "Function"; + default: + return "Unknown"; + } + } + static std::string TypeName(ValueType type) + { + switch(type) + { + case TypeNumber: + return "Number"; + case TypePoint: + return "Point"; + case TypeString: + return "String"; + case TypeNull: + return "Null"; + case TypeFunction: + return "Function"; + default: + return "Unknown"; + } + } ~AnyType(); }; +class InvalidConversionException: public GeneralException +{ +private: + ValueType from; + ValueType to; +public: + InvalidConversionException(ValueType from_, ValueType to_): + GeneralException("Invalid conversion from " + AnyType::TypeName(from_) + " to " + AnyType::TypeName(to_)), from(from_), to(to_) { + } +}; + class NumberType: public AnyType { public: |
