File indexing completed on 2025-01-18 09:14:30
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef PARSERS_SPIRIT_PARSERSSTANDARDLISTCOMMON_H
0012 #define PARSERS_SPIRIT_PARSERSSTANDARDLISTCOMMON_H 1
0013
0014
0015
0016 #include "Parsers/spirit/ParsersFactory.h"
0017
0018 #ifndef DD4HEP_PARSERS_NO_ROOT
0019
0020 namespace dd4hep {
0021 namespace Parsers {
0022
0023 template<typename T1, typename T2> inline int
0024 parse_(ROOT::Math::PositionVector3D<T1,T2>& result, const std::string& input){
0025 Skipper skipper;
0026 typename Grammar_<IteratorT,ROOT::Math::PositionVector3D<T1,T2>,Skipper>::Grammar g;
0027 IteratorT iter = input.begin(), end = input.end();
0028 if (qi::phrase_parse( iter, end, g, skipper, result)){
0029 return 1;
0030 }
0031 return 0;
0032 }
0033 }
0034 }
0035 #endif
0036
0037 #define IMPLEMENT_STL_PARSER(x,y) \
0038 template <> int parse(x < y > & result, const std::string& input) \
0039 { result.clear(); return parse_(result, input); } \
0040 template <> std::ostream& toStream(const x < y >& o,std::ostream& s) \
0041 { return toStream_(o, s); }
0042
0043 #define IMPLEMENT_STL_MAP_PARSER(x,k,v) \
0044 template <> int parse(x < k, v > & result, const std::string& input) \
0045 { result.clear(); return parse_(result, input); } \
0046 template <> std::ostream& toStream(const x <k,v>& o,std::ostream& s) \
0047 { return toStream_(o, s); }
0048
0049 #define IMPLEMENT_MAPPED_PARSERS(type,X) \
0050 template <> int parse(std::type <int,X>& result,const std::string& input) \
0051 { return parse_(result, input); } \
0052 template <> std::ostream& toStream(const std::type <int,X>& o,std::ostream& s) \
0053 { return toStream_(o, s); } \
0054 template <> int parse(std::type <unsigned long,X>& result,const std::string& input) \
0055 { return parse_(result, input); } \
0056 template <> std::ostream& toStream(const std::type <unsigned long,X>& o,std::ostream& s) \
0057 { return toStream_(o, s); } \
0058 template <> int parse(std::type <std::string,X>& result,const std::string& input) \
0059 { return parse_(result, input); } \
0060 template <> std::ostream& toStream(const std::type <std::string,X>& o,std::ostream& s) \
0061 { return toStream_(o, s); }
0062
0063 #if defined(DD4HEP_HAVE_ALL_PARSERS)
0064
0065 #define IMPLEMENT_STL_PARSERS(x) \
0066 IMPLEMENT_STL_PARSER(std::vector,x) \
0067 IMPLEMENT_STL_PARSER(std::list,x) \
0068 IMPLEMENT_STL_PARSER(std::set,x) \
0069 IMPLEMENT_STL_PARSER(std::deque,x) \
0070 IMPLEMENT_STL_MAP_PARSER(std::map,int,x) \
0071 IMPLEMENT_STL_MAP_PARSER(std::map,unsigned long,x) \
0072 IMPLEMENT_STL_MAP_PARSER(std::map,std::string,x)
0073
0074 #else
0075
0076 #define IMPLEMENT_STL_PARSERS(x) \
0077 IMPLEMENT_STL_PARSER(std::vector,x) \
0078 IMPLEMENT_STL_PARSER(std::list,x) \
0079 IMPLEMENT_STL_PARSER(std::set,x) \
0080 IMPLEMENT_STL_MAP_PARSER(std::map,int,x) \
0081 IMPLEMENT_STL_MAP_PARSER(std::map,std::string,x)
0082
0083 #endif
0084
0085
0086 #define PARSERS_DEF_FOR_LIST(InnerType) \
0087 namespace DD4hep{ namespace Parsers{ \
0088 IMPLEMENT_STL_PARSERS(InnerType) \
0089 IMPLEMENT_MAPPED_PARSERS(pair,InnerType) }}
0090
0091
0092 #endif