blob: ad08f0bd55a645e991fa7e999a47790ae68911a6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
/*
* TPTSTypes.h
*
* Created on: Feb 4, 2012
* Author: Simon
*/
#ifndef TPTSTYPES_H_
#define TPTSTYPES_H_
#include <string>
#include "interface/Point.h"
enum ValueType { TypeNumber, TypePoint, TypeString, TypeNull, TypeFunction };
class GeneralException
{
protected:
std::string exception;
public:
GeneralException(std::string message){
exception = message;
}
std::string GetExceptionMessage() {
return exception;
}
};
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;
class PointType;
class AnyType
{
protected:
ValueType type;
void * value;
public:
AnyType(ValueType type_, void * value_);
AnyType(const AnyType & v);
operator NumberType();
operator StringType();
operator PointType();
ValueType GetType();
~AnyType();
};
class NumberType: public AnyType
{
public:
NumberType(int number);
int Value();
};
class StringType: public AnyType
{
public:
StringType(std::string string);
std::string Value();
};
class PointType: public AnyType
{
public:
PointType(ui::Point point);
PointType(int pointX, int pointY);
ui::Point Value();
};
#endif /* TPTSTYPES_H_ */
|