author | Peter Hegyi <hegyi@tmit.bme.hu> |
Mon, 07 Jul 2008 08:10:39 -0500 | |
changeset 1 | 67188bd752db |
permissions | -rw-r--r-- |
1 #ifndef MAP_VALUE_H
2 #define MAP_VALUE_H
4 #include <exception>
5 #include <functional>
6 #include <iosfwd>
8 class MapValue
9 {
10 public:
11 friend std::ostream& operator<<(std::ostream &os, const MapValue& v);
12 class IllegalOperation : public std::exception
13 {
14 virtual const char* what() const throw()
15 {
16 return "Illegal operation.";
17 }
18 };
19 typedef enum
20 {
21 NUMERIC = 1 << 0,
22 STRING = 1 << 1
23 } Type;
24 private:
25 bool has_value;
26 void* p_value;
27 MapValue::Type type;
28 void clear();
29 public:
30 MapValue();
31 MapValue(double);
32 MapValue(std::string);
33 MapValue(const char* str);
34 MapValue(const MapValue& v);
35 MapValue& operator=(const MapValue& v);
36 ~MapValue();
37 operator std::string() const;
38 operator double() const;
39 Type getType() const;
40 bool hasValue() const;
41 };
43 #endif