mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-09 21:50:45 +01:00
Serialisable enums can be converted to int
This commit is contained in:
parent
a37e71f362
commit
f7db342f49
@ -152,14 +152,14 @@ friend inline std::ostream & operator << (std::ostream &os, const cname &obj ) {
|
|||||||
class name: public Serializable\
|
class name: public Serializable\
|
||||||
{\
|
{\
|
||||||
public:\
|
public:\
|
||||||
enum EnumType\
|
enum\
|
||||||
{\
|
{\
|
||||||
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMVAL,__VA_ARGS__))\
|
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMVAL,__VA_ARGS__))\
|
||||||
undefname = -1\
|
undefname = -1\
|
||||||
};\
|
};\
|
||||||
public:\
|
public:\
|
||||||
name(void): value_(undefname) {};\
|
name(void): value_(undefname) {};\
|
||||||
name(EnumType value): value_(value) {};\
|
name(int value): value_(value) {};\
|
||||||
template <typename T>\
|
template <typename T>\
|
||||||
static inline void write(Writer<T> &WR,const std::string &s, const name &obj)\
|
static inline void write(Writer<T> &WR,const std::string &s, const name &obj)\
|
||||||
{\
|
{\
|
||||||
@ -179,7 +179,7 @@ public:\
|
|||||||
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMTEST,__VA_ARGS__))\
|
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMTEST,__VA_ARGS__))\
|
||||||
else {obj = name::undefname;}\
|
else {obj = name::undefname;}\
|
||||||
}\
|
}\
|
||||||
inline operator EnumType(void) const\
|
inline operator int(void) const\
|
||||||
{\
|
{\
|
||||||
return value_;\
|
return value_;\
|
||||||
}\
|
}\
|
||||||
@ -192,7 +192,7 @@ public:\
|
|||||||
return os;\
|
return os;\
|
||||||
}\
|
}\
|
||||||
private:\
|
private:\
|
||||||
EnumType value_;\
|
int value_;\
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user