1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-09-20 09:15:38 +01:00

Merge branch 'master' into hadrons

This commit is contained in:
Antonin Portelli 2015-12-23 14:20:22 +00:00
commit 379580cd89
3 changed files with 21 additions and 6 deletions

View File

@ -120,7 +120,7 @@ THE SOFTWARE.
\ \
\ \
template <typename T>\ template <typename T>\
static void write(Writer<T> &WR,const std::string &s, const cname &obj){ \ static inline void write(Writer<T> &WR,const std::string &s, const cname &obj){ \
push(WR,s);\ push(WR,s);\
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_WRITE_MEMBER,__VA_ARGS__)) \ GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_WRITE_MEMBER,__VA_ARGS__)) \
pop(WR);\ pop(WR);\
@ -128,14 +128,14 @@ THE SOFTWARE.
\ \
\ \
template <typename T>\ template <typename T>\
static void read(Reader<T> &RD,const std::string &s, cname &obj){ \ static inline void read(Reader<T> &RD,const std::string &s, cname &obj){ \
push(RD,s);\ push(RD,s);\
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_READ_MEMBER,__VA_ARGS__)) \ GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_READ_MEMBER,__VA_ARGS__)) \
pop(RD);\ pop(RD);\
} \ } \
\ \
\ \
friend std::ostream & operator << (std::ostream &os, const cname &obj ) { \ friend inline std::ostream & operator << (std::ostream &os, const cname &obj ) { \
os<<"class "<<#cname<<" {"<<std::endl;\ os<<"class "<<#cname<<" {"<<std::endl;\
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_OS_WRITE_MEMBER,__VA_ARGS__)) \ GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_OS_WRITE_MEMBER,__VA_ARGS__)) \
os<<"}"; \ os<<"}"; \
@ -165,7 +165,7 @@ namespace Grid {
class EnumIO<name> {\ class EnumIO<name> {\
public:\ public:\
template <typename T>\ template <typename T>\
static 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){ \
switch (obj) {\ switch (obj) {\
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMCASE,__VA_ARGS__))\ GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMCASE,__VA_ARGS__))\
default: Grid::write(WR,s,#undefname); break;\ default: Grid::write(WR,s,#undefname); break;\
@ -173,7 +173,7 @@ namespace Grid {
}\ }\
\ \
template <typename T>\ template <typename T>\
static void read(Reader<T> &RD,const std::string &s, name &obj){ \ static inline void read(Reader<T> &RD,const std::string &s, name &obj){ \
std::string buf;\ std::string buf;\
Grid::read(RD, s, buf);\ Grid::read(RD, s, buf);\
if (buf == #undefname) {obj = name::undefname;}\ if (buf == #undefname) {obj = name::undefname;}\
@ -182,7 +182,7 @@ namespace Grid {
}\ }\
};\ };\
\ \
std::ostream & operator << (std::ostream &os, const name &obj ) { \ inline std::ostream & operator << (std::ostream &os, const name &obj ) { \
switch (obj) {\ switch (obj) {\
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMCASEIO,__VA_ARGS__))\ GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMCASEIO,__VA_ARGS__))\
default: os << #undefname; break;\ default: os << #undefname; break;\

View File

@ -52,6 +52,20 @@ void XmlReader::pop(void)
node_ = node_.parent(); node_ = node_.parent();
} }
bool XmlReader::nextElement(const std::string &s)
{
if (node_.next_sibling(s.c_str()))
{
node_ = node_.next_sibling(s.c_str());
return true;
}
else
{
return false;
}
}
template <> template <>
void XmlReader::readDefault(const string &s, string &output) void XmlReader::readDefault(const string &s, string &output)
{ {

View File

@ -39,6 +39,7 @@ namespace Grid
virtual ~XmlReader(void) = default; virtual ~XmlReader(void) = default;
void push(const std::string &s); void push(const std::string &s);
void pop(void); void pop(void);
bool nextElement(const std::string &s);
template <typename U> template <typename U>
void readDefault(const std::string &s, U &output); void readDefault(const std::string &s, U &output);
template <typename U> template <typename U>