Go to the documentation of this file.
33 #include <boost/config.hpp>
44 BOOST_STATIC_CONSTANT(
long int, BAD_VALUE = -5000000);
50 virtual const std::string&
FromEnum(
long int i)
const = 0;
54 virtual long int FromString (
const std::string& str)
const = 0;
65 virtual const std::string&
FromEnum(
long int)
const
66 {
static std::string empty;
return empty; }
67 virtual long int FromString (
const std::string&)
const {
return 0;}
88 #define GG_ENUM_MAP_BEGIN( name ) \
89 template <> struct EnumMap< name > : EnumMapBase \
91 typedef name EnumType; \
92 typedef std::map<EnumType, std::string> MapType; \
98 #define GG_ENUM_MAP_INSERT( value ) m_map[ value ] = #value ;
102 #define GG_ENUM_MAP_END \
104 virtual const std::string& FromEnum(long int i) const \
106 static const std::string ERROR_STR; \
107 std::map<EnumType, std::string>::const_iterator it = \
108 m_map.find(EnumType(i)); \
109 return it == m_map.end() ? ERROR_STR : it->second; \
111 long int FromString (const std::string &str) const \
113 for (MapType::const_iterator it = m_map.begin(); \
116 if (it->second == str) \
126 #define GG_ENUM_STREAM_IN( name ) \
127 inline std::istream& operator>>(std::istream& is, name& v) \
131 v = name (GG::GetEnumMap< name >().FromString(str)); \
137 #define GG_ENUM_STREAM_OUT( name ) \
138 inline std::ostream& operator<<(std::ostream& os, name v) \
140 os << GG::GetEnumMap< name >().FromEnum(v); \