13 #include "boost/spirit/include/classic.hpp" 24 void operator() (
char const*
str,
char const*
end)
const 26 ddlVector_->do_makeDouble(str, end);
39 void operator() (
char const*
str,
char const*
end)
const 41 ddlVector_->do_makeString(str, end);
56 ((+(anychar_p -
','))[makeDouble]
57 >> *(
',' >> (+(anychar_p -
','))[makeDouble]))
67 ((+(anychar_p -
','))[makeString]
68 >> *(
',' >> (+(anychar_p -
','))[makeString]))
89 bool isNumVec((atts.find(
"type") == atts.end()
90 || atts.find(
"type")->second ==
"numeric")
92 bool isStringVec((!isNumVec && atts.find(
"type") != atts.end()
93 && atts.find(
"type")->second ==
"string")
97 if (tTextToParse.size() == 0) {
106 else if (isStringVec) {
112 errorOut(
"Unexpected std::vector type. Only \"numeric\" and \"string\" are allowed.");
120 else if (isStringVec) {
123 size_t expNEntries = 0;
124 if (atts.find(
"nEntries") != atts.end()) {
125 std::string nEntries = atts.find(
"nEntries")->second;
128 if ( (isNumVec &&
pVector.size() != expNEntries)
129 || (isStringVec &&
pStrVector.size() != expNEntries) )
131 std::string msg (
"Number of entries found in Vector text does not match number in attribute nEntries.");
132 msg +=
"\n\tnEntries = " + atts.find(
"nEntries")->second;
133 msg +=
"\n------------------text---------\n";
135 msg +=
"\n------------------text---------\n";
139 else if (
parent() ==
"ConstantsSection" ||
parent() ==
"DDDefinition")
141 if (atts.find(
"type") == atts.end() || atts.find(
"type")->second ==
"numeric") {
183 e+=
"\n as a Vector element (comma separated list).";
DDLElementRegistry * myRegistry_
std::vector< double > pVector
void preProcessElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
Called by loadAttributes AFTER attributes are loaded.
DDLVector handles Rotation and ReflectionRotation elements.
DDLVector(DDLElementRegistry *myreg)
ReadMapType< std::vector< std::string > > & getMapOfStrVectors()
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.
const std::string & parent(void) const
access to parent element name
a named constant corresponding to the DDL-XML tag <Constant> and <ConstantsStrVector> ...
type of data representation of DDCompactView
void do_makeDouble(char const *str, char const *end)
std::map< std::string, std::string > DDXMLAttribute
ReadMapType< std::vector< double > > & getMapOfVectors()
void do_makeString(char const *str, char const *end)
virtual std::vector< DDXMLAttribute >::const_iterator end(void)
void errorOut(const char *str) const
static value_type & instance()
bool parse_strings(char const *str) const
a std::map<std::string,YourType> that offers a const operator[key]; if key is not stored in the std::...
ClhepEvaluator & evaluator()
a named constant corresponding to the DDL-XML tag <Constant> and <ConstantsVector> ...
std::shared_ptr< DDLVector > ddlVector_
std::vector< std::string > pStrVector
ReadMapType< std::vector< double > > pVecMap
bool parse_numbers(char const *str) const
This is a base class for processing XML elements in the DDD.
ReadMapType< std::vector< std::string > > pStrVecMap
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 processElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
Processing the element.
std::shared_ptr< DDLVector > ddlVector_
virtual const DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
const std::string getText(size_t tindex=0) const
retrieve the text blob.