hegyi@1: #ifndef MAP_VALUE_H hegyi@1: #define MAP_VALUE_H hegyi@1: hegyi@1: #include hegyi@1: #include hegyi@1: #include hegyi@1: hegyi@1: class MapValue hegyi@1: { hegyi@1: public: hegyi@1: friend std::ostream& operator<<(std::ostream &os, const MapValue& v); hegyi@1: class IllegalOperation : public std::exception hegyi@1: { hegyi@1: virtual const char* what() const throw() hegyi@1: { hegyi@1: return "Illegal operation."; hegyi@1: } hegyi@1: }; hegyi@1: typedef enum hegyi@1: { hegyi@1: NUMERIC = 1 << 0, hegyi@1: STRING = 1 << 1 hegyi@1: } Type; hegyi@1: private: hegyi@1: bool has_value; hegyi@1: void* p_value; hegyi@1: MapValue::Type type; hegyi@1: void clear(); hegyi@1: public: hegyi@1: MapValue(); hegyi@1: MapValue(double); hegyi@1: MapValue(std::string); hegyi@1: MapValue(const char* str); hegyi@1: MapValue(const MapValue& v); hegyi@1: MapValue& operator=(const MapValue& v); hegyi@1: ~MapValue(); hegyi@1: operator std::string() const; hegyi@1: operator double() const; hegyi@1: Type getType() const; hegyi@1: bool hasValue() const; hegyi@1: }; hegyi@1: hegyi@1: #endif