7 #include "boost/spirit/include/classic.hpp"
14 namespace boost {
namespace spirit {
namespace classic { } } }
using namespace boost::spirit::classic;
23 std::vector<DDPartSelRegExpLevel>*
p_;
25 std::vector<DDPartSelRegExpLevel>*
path(std::vector<DDPartSelRegExpLevel>*
p=0) {
53 void operator() (
char const*
first,
char const*
last)
const {
55 if (c_.isCopyNoValid_ && c_.isChild_) {
59 if (c_.isCopyNoValid_ && !c_.isChild_) {
63 if (!c_.isCopyNoValid_ && c_.isChild_) {
67 if (!c_.isCopyNoValid_ && !c_.isChild_) {
73 c_.isCopyNoValid_=
false;
85 if ( (last-first) > 1)
87 if ( (last-first) ==1 )
113 sl.
name_.assign(first,last);
137 template <
typename ScannerT>
147 FirstStep = Descendant
151 Part = PartNameCopyNumber
155 PartNameCopyNumber = PartName
163 NavigationalElement = Descendant
167 CopyNumber = ch_p(
'[')
168 >> int_p[copyNoFtor()]
172 PartName = NameSpaceName
176 SimpleName = +( alnum_p | ch_p(
'_') | ch_p(
'.') | ch_p(
'*') )
179 NameSpaceName = SimpleName[nameSpaceFtor()]
181 >> SimpleName[nameFtor()]
184 Descendant = ch_p(
'/')
194 CopyNumber, PartName, PartNameCopyNumber, NameSpaceName,
SimpleName,
257 : lp_(lp), copyno_(c), selectionType_(t)
270 edm::LogError(
"DDPartSelection") <<
"DDTokenize2() error in parsing of " << sel << std::endl;
283 static bool isInit(
false);
284 static std::vector<std::string>
tokens;
287 tokens.push_back(
"/");
288 tokens.push_back(
"//");
289 tokens.push_back(
"[");
290 tokens.push_back(
"]");
295 std::vector<std::string> toksVec;
296 std::vector<std::string> textVec;
297 std::string tkn, txt;
298 bool braceOpen(
false);
312 std::vector<std::string>::iterator tkit = tokens.begin();
313 std::vector<std::string>::iterator
mint = tokens.end();
316 for(;tkit!=tokens.end();++tkit) {
324 if (mint!=tokens.end())
325 tkn = s.substr(st,mint->size());
328 txt = s.substr(cu,st);
329 toksVec.push_back(tkn);
330 textVec.push_back(txt);
333 throw DDException(std::string(
"PartSelector: syntaxerror in ") + sel +
334 std::string(
"\ncheck the braces!") );
340 DCOUT_V(
'C',
"tkn=" << tkn <<
" txt=" << txt);
341 if (mint!=tokens.end())
342 s.erase(cu,st+mint->size());
345 DCOUT_V(
'C', std::endl <<
"s=" << s);
348 DCOUT_V(
'C',
"The original std::string was:" << std::endl);
351 for (i=0; i<toksVec.size();++
i) {
352 DCOUT_V(
'C', toksVec[i] <<
"\t" << textVec[i]);
357 std::string nm =
"blabla" ;
358 if (textVec[0] !=
"")
360 +std::string(
" selection must not start with a LogicalPart-name"));
362 if ((toksVec[0] !=
"//"))
364 +std::string(
" selection must start with '//' !"));
366 if (textVec.size() < 2)
367 throw DDException( nm + std::string(
" internal error [textVec.size()<2]!"));
369 std::vector<std::string>::iterator tk_it = toksVec.begin();
370 std::vector<std::string>::iterator tx_it = textVec.begin(); ++tx_it;
372 while(tk_it != toksVec.end() && tx_it != textVec.end()) {
375 DCOUT_V(
'C',
">- anynode tkn=" << *tk_it <<
" d=" << tk_it-toksVec.begin() <<
" txt=" << *tx_it << std::endl);
376 if ( *tk_it ==
"//" && *tx_it==
"*" ) {
378 DCOUT_V(
'C',
"--anynode: //*" << std::endl);
385 DCOUT_V(
'C',
">- anychild tkn=" << *tk_it <<
" d=" << tk_it-toksVec.begin() <<
" txt=" << *tx_it << std::endl);
386 if ( *tk_it ==
"/" && *tx_it==
"*" ) {
388 DCOUT_V(
'C',
"--anychild: /*" << std::endl);
395 DCOUT_V(
'C',
">- anylogp tkn=" << *tk_it <<
" d=" << tk_it-toksVec.begin() <<
" txt=" << *tx_it << std::endl);
396 if ( *tk_it ==
"//" && tx_it->size()) {
398 if ( tk_it != toksVec.end() && *tk_it !=
"[" && *tk_it !=
"]") {
399 std::pair<std::string,std::string>
p(
DDSplit(*tx_it));
401 DCOUT_V(
'C',
"--anylogp: " << *tx_it << std::endl);
409 DCOUT_V(
'C',
">- childlogp tkn=" << *tk_it <<
" d=" << tk_it-toksVec.begin() <<
" txt=" << *tx_it << std::endl);
410 if ( *tk_it ==
"/" && tx_it->size()) {
412 if ( tk_it == toksVec.end() - 1 ) {
413 DCOUT_V(
'C',
"--childlogp: " << *tx_it << std::endl);
414 std::pair<std::string,std::string>
p(
DDSplit(*tx_it));
419 if ( *tk_it ==
"/" || *tk_it==
"//") {
420 DCOUT_V(
'C',
"--childlogp: " << *tx_it << std::endl);
421 std::pair<std::string,std::string>
p(
DDSplit(*tx_it));
431 DCOUT_V(
'C',
">- anyposp tkn=" << *tk_it <<
" d=" << tk_it-toksVec.begin() <<
" txt=" << *tx_it << std::endl);
432 if ( *tk_it ==
"//" && tx_it->size()) {
434 if ( tk_it != toksVec.end() && *tk_it ==
"[" ) {
436 if ( tk_it == toksVec.end() || (tk_it != toksVec.end() && *tk_it !=
"]")) {
437 DCOUT_V(
'C', *tk_it <<
" " << *tx_it );
442 std::pair<std::string,std::string>
p(
DDSplit(*(tx_it-1)));
444 DCOUT_V(
'C',
"--anyposp: " << *tx_it <<
" " << atoi(tx_it->c_str()) << std::endl);
453 DCOUT_V(
'C',
">- childposp tkn=" << *tk_it <<
" d=" << tk_it-toksVec.begin() <<
" txt=" << *tx_it << std::endl);
454 if ( *tk_it ==
"/" && tx_it->size()) {
456 if ( tk_it != toksVec.end() && *tk_it==
"[" ) {
457 DCOUT_V(
'C',
"--childposp: " << *tx_it <<
" " << *tk_it << *(tx_it+1) << std::endl);
458 std::pair<std::string,std::string>
p(
DDSplit(*tx_it));
465 if (tk_it != toksVec.end() && *tk_it !=
"]")
474 throw DDException( nm + std::string(
" syntax error in:\n") + sel +
475 std::string(
"\n tkn=") + *tk_it + std::string(
" txt=")+ *tx_it);
480 throw DDException(std::string(
"PartSelector: last element in selection std::string in ") + sel +
481 std::string(
"\nmust address a distinct LogicalPart or PosPart!") );
487 DDPartSelection::const_iterator it(p.begin()), ed(p.end());
488 for (; it != ed; ++it) {
504 o <<
"{Syntax ERROR}";
510 std::ostream & operator<<(std::ostream & os, const std::vector<DDPartSelection> &
v)
512 std::vector<DDPartSelection>::const_iterator it(
v.begin()), ed(
v.end());
513 for (; it != (ed-1); ++it) {
514 os << *it << std::endl;
528 #include <DetectorDescription/Base/interface/Singleton.icc>
DDSelLevelFtor * selLevelFtor_
DDPartSelectionLevel(const DDLogicalPart &, int, ddselection_type)
void operator()(char const *first, char const *last) const
Evaluator * parse(const T &text)
rule< ScannerT > SimpleName
An exception for DDD errors.
DDCopyNoFtor & copyNoFtor()
void DDTokenize(const std::string &selectionString, std::vector< DDPartSelRegExpLevel > &result)
std::ostream & operator<<(std::ostream &out, const ALILine &li)
void operator()(int i) const
DDIsChildFtor & isChildFtor()
static value_type & instance()
std::vector< DDPartSelRegExpLevel > * path(std::vector< DDPartSelRegExpLevel > *p=0)
void operator()(char const *first, char const *last) const
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
ddselection_type selectionType_
void noNameSpace(char const *first, char const *last)
rule< ScannerT > const & start() const
#define DCOUT_V(M_v_Y, M_v_S)
void DDTokenize2(const std::string &selectionString, std::vector< DDPartSelRegExpLevel > &result)
Templated helper class to allow a selection on a certain object collection.
std::vector< std::vector< double > > tmp
definition(SpecParParser const &self)
void operator()(char const *first, char const *last) const
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
DDNameSpaceFtor & nameSpaceFtor()
std::vector< DDPartSelRegExpLevel > * p_
DDSelLevelFtor & selLevelFtor()