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