From 1e0be161e5de0ef01d708cded72217af6841810f Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Wed, 23 Dec 2015 14:20:05 +0000 Subject: [PATCH] MacroMagic: inline functions to avoid double symbol issues --- lib/serialisation/MacroMagic.h | 12 ++++++------ lib/serialisation/XmlIO.cc | 14 ++++++++++++++ lib/serialisation/XmlIO.h | 1 + 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/serialisation/MacroMagic.h b/lib/serialisation/MacroMagic.h index 34fd893f..c78bba0c 100644 --- a/lib/serialisation/MacroMagic.h +++ b/lib/serialisation/MacroMagic.h @@ -120,7 +120,7 @@ THE SOFTWARE. \ \ template \ - static void write(Writer &WR,const std::string &s, const cname &obj){ \ + static inline void write(Writer &WR,const std::string &s, const cname &obj){ \ push(WR,s);\ GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_WRITE_MEMBER,__VA_ARGS__)) \ pop(WR);\ @@ -128,14 +128,14 @@ THE SOFTWARE. \ \ template \ - static void read(Reader &RD,const std::string &s, cname &obj){ \ + static inline void read(Reader &RD,const std::string &s, cname &obj){ \ push(RD,s);\ GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_READ_MEMBER,__VA_ARGS__)) \ 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<<" {"< {\ public:\ template \ - static void write(Writer &WR,const std::string &s, const name &obj){ \ + static inline void write(Writer &WR,const std::string &s, const name &obj){ \ switch (obj) {\ GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMCASE,__VA_ARGS__))\ default: Grid::write(WR,s,#undefname); break;\ @@ -173,7 +173,7 @@ namespace Grid { }\ \ template \ - static void read(Reader &RD,const std::string &s, name &obj){ \ + static inline void read(Reader &RD,const std::string &s, name &obj){ \ std::string buf;\ Grid::read(RD, s, buf);\ 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) {\ GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMCASEIO,__VA_ARGS__))\ default: os << #undefname; break;\ diff --git a/lib/serialisation/XmlIO.cc b/lib/serialisation/XmlIO.cc index 8dd93de7..ae543880 100644 --- a/lib/serialisation/XmlIO.cc +++ b/lib/serialisation/XmlIO.cc @@ -52,6 +52,20 @@ void XmlReader::pop(void) 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 <> void XmlReader::readDefault(const string &s, string &output) { diff --git a/lib/serialisation/XmlIO.h b/lib/serialisation/XmlIO.h index 15bb0206..697af4a4 100644 --- a/lib/serialisation/XmlIO.h +++ b/lib/serialisation/XmlIO.h @@ -39,6 +39,7 @@ namespace Grid virtual ~XmlReader(void) = default; void push(const std::string &s); void pop(void); + bool nextElement(const std::string &s); template void readDefault(const std::string &s, U &output); template