12 #include "boost/spirit/include/classic.hpp"
16 namespace boost {
namespace spirit {
namespace classic { } } }
using namespace boost::spirit::classic;
18 using namespace boost::spirit;
23 void operator() (
char const* str,
char const*
end)
const
25 ddlVector_->do_makeDouble(str, end);
38 void operator() (
char const* str,
char const*
end)
const
40 ddlVector_->do_makeString(str, end);
55 ((+(anychar_p -
','))[makeDouble]
56 >> *(
',' >> (+(anychar_p -
','))[makeDouble]))
66 ((+(anychar_p -
','))[makeString]
67 >> *(
',' >> (+(anychar_p -
','))[makeString]))
88 bool isNumVec((atts.find(
"type") == atts.end()
89 || atts.find(
"type")->second ==
"numeric")
91 bool isStringVec((!isNumVec && atts.find(
"type") != atts.end()
92 && atts.find(
"type")->second ==
"string")
96 if (tTextToParse.size() == 0) {
105 else if (isStringVec) {
111 errorOut(
"Unexpected std::vector type. Only \"numeric\" and \"string\" are allowed.");
124 else if (isStringVec) {
128 size_t expNEntries = 0;
129 if (atts.find(
"nEntries") != atts.end()) {
130 std::string nEntries = atts.find(
"nEntries")->second;
133 if ( (isNumVec &&
pVector.size() != expNEntries)
134 || (isStringVec &&
pStrVector.size() != expNEntries) )
136 std::string msg (
"Number of entries found in Vector text does not match number in attribute nEntries.");
137 msg +=
"\n\tnEntries = " + atts.find(
"nEntries")->second;
138 msg +=
"\n------------------text---------\n";
140 msg +=
"\n------------------text---------\n";
144 else if (
parent() ==
"ConstantsSection" ||
parent() ==
"DDDefinition")
146 if (atts.find(
"type") == atts.end() || atts.find(
"type")->second ==
"numeric") {
188 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)
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::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.
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.