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