6 #include "boost/spirit/home/classic/core/non_terminal/grammar.hpp" 7 #include "boost/spirit/include/classic.hpp" 38 class Mapper :
public boost::spirit::classic::grammar<Mapper> {
52 namespace boost {
namespace spirit {
namespace classic {} } }
65 = ppair[
self.mapPair()]
66 >> *((
',' >> ppair)[
self.mapPair()])
75 = (alpha_p >> *alnum_p)[
self.mapMakeName()]
79 = (+(anychar_p -
','))[
self.mapMakeDouble()]
86 start()
const {
return mapSet; }
92 map_->do_pair(str, end);
98 map_->do_makeName(str, end);
104 map_->do_makeDouble(str, end);
124 if (tTextToParse.empty())
126 errorOut(
"No std::string to parse!");
130 if (atts.find(
"type") != atts.end() && atts.find(
"type")->second ==
"string")
132 errorOut(
"Map of type std::string is not supported yet.");
142 errorOut(
"Does not conform to name=value, name=value... etc. of ddl Map element.");
149 else if (
parent() ==
"ConstantsSection" ||
parent() ==
"DDDefinition")
152 for (std::map<std::string, double>::const_iterator it =
pMap.begin(); it !=
pMap.end(); ++it)
154 tMap[it->first] = it->second;
161 std::string nEntries = atts.find(
"nEntries")->second;
165 errorOut(
"Number of entries found in Map text does not match number in attribute nEntries.");
194 msg+=
"\n as a Map element (comma separated list of name=value).";
ReadMapType< std::map< std::string, double > > pMapMap
MapMakeName mapMakeName() const
void operator()(char const *str, char const *end) const
DDLElementRegistry * myRegistry_
DDLMap(DDLElementRegistry *myreg)
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a "row" of attributes, i.e. one attribute set.
void throwError(const std::string &keyMessage) const
format std::string for throw an error.
ReadMapType< std::map< std::string, double > > & getMapOfMaps(void)
const std::string & parent(void) const
access to parent element name
void processElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
Processing the element.
Compact representation of the geometrical detector hierarchy.
MapMakeDouble mapMakeDouble() const
a named constant corresponding to the DDL-XML tag <Constant> and <ConstantsVector> ...
std::map< std::string, std::string > DDXMLAttribute
virtual std::vector< DDXMLAttribute >::const_iterator end(void)
MapMakeName(DDLMap *iMap)
ClhepEvaluator & evaluator()
definition(Mapper const &self)
void do_makeName(char const *str, char const *end)
void operator()(char const *str, char const *end) const
void preProcessElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
Called by loadAttributes AFTER attributes are loaded.
MapMakeDouble(DDLMap *iMap)
void do_pair(char const *str, char const *end)
DDLMap handles Map container.
This is a base class for processing XML elements in the DDD.
void errorOut(const char *str)
rule< ScannerT > const & start() const
double eval(const std::string &ns, const std::string &expr)
The main class for processing parsed elements.
virtual void clear(void)
clear this element's contents.
void do_makeDouble(char const *str, char const *end)
virtual const DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
void operator()(char const *str, char const *end) const
const std::string getText(size_t tindex=0) const
retrieve the text blob.