6 #include "boost/spirit/include/classic.hpp"
13 namespace boost {
namespace spirit {
namespace classic { } } }
using namespace boost::spirit::classic;
22 std::vector<DDPartSelRegExpLevel>*
p_;
24 std::vector<DDPartSelRegExpLevel>*
path(std::vector<DDPartSelRegExpLevel>*
p=0) {
52 void operator() (
char const* ,
char const* )
const {
54 if (c_.isCopyNoValid_ && c_.isChild_) {
58 if (c_.isCopyNoValid_ && !c_.isChild_) {
62 if (!c_.isCopyNoValid_ && c_.isChild_) {
66 if (!c_.isCopyNoValid_ && !c_.isChild_) {
72 c_.isCopyNoValid_=
false;
84 if ( (last-first) > 1)
86 if ( (last-first) ==1 )
112 sl.
name_.assign(first,last);
136 template <
typename ScannerT>
146 FirstStep = Descendant
150 Part = PartNameCopyNumber
154 PartNameCopyNumber = PartName
162 NavigationalElement = Descendant
166 CopyNumber = ch_p(
'[')
167 >> int_p[copyNoFtor()]
171 PartName = NameSpaceName
175 SimpleName = +( alnum_p | ch_p(
'_') | ch_p(
'.') | ch_p(
'*') )
178 NameSpaceName = SimpleName[nameSpaceFtor()]
180 >> SimpleName[nameFtor()]
183 Descendant = ch_p(
'/')
193 CopyNumber, PartName, PartNameCopyNumber, NameSpaceName,
SimpleName,
256 : lp_(lp), copyno_(c), selectionType_(t)
269 edm::LogError(
"DDPartSelection") <<
"DDTokenize2() error in parsing of " << sel << std::endl;
282 static bool isInit(
false);
283 static std::vector<std::string> tokens;
286 tokens.push_back(
"/");
287 tokens.push_back(
"//");
288 tokens.push_back(
"[");
289 tokens.push_back(
"]");
294 std::vector<std::string> toksVec;
295 std::vector<std::string> textVec;
296 std::string tkn, txt;
297 bool braceOpen(
false);
311 std::vector<std::string>::iterator tkit = tokens.begin();
312 std::vector<std::string>::iterator
mint = tokens.end();
315 for(;tkit!=tokens.end();++tkit) {
323 if (mint!=tokens.end())
324 tkn = s.substr(st,mint->size());
327 txt = s.substr(cu,st);
328 toksVec.push_back(tkn);
329 textVec.push_back(txt);
332 throw cms::Exception(
"DDException") <<
"PartSelector: syntaxerror in " << sel
333 <<
"\ncheck the braces!";
339 DCOUT_V(
'C',
"tkn=" << tkn <<
" txt=" << txt);
340 if (mint!=tokens.end())
341 s.erase(cu,st+mint->size());
344 DCOUT_V(
'C', std::endl <<
"s=" << s);
347 DCOUT_V(
'C',
"The original std::string was:" << std::endl);
350 for (i=0; i<toksVec.size();++
i) {
351 DCOUT_V(
'C', toksVec[i] <<
"\t" << textVec[i]);
356 std::string nm =
"blabla" ;
357 if (textVec[0] !=
"")
358 throw cms::Exception(
"DDException") << nm <<
" selection must not start with a LogicalPart-name";
360 if ((toksVec[0] !=
"//"))
361 throw cms::Exception(
"DDException") << nm <<
" selection must start with '//' !";
363 if (textVec.size() < 2)
364 throw cms::Exception(
"DDException") << nm <<
" internal error [textVec.size()<2]!";
366 std::vector<std::string>::iterator tk_it = toksVec.begin();
367 std::vector<std::string>::iterator tx_it = textVec.begin(); ++tx_it;
369 while(tk_it != toksVec.end() && tx_it != textVec.end()) {
372 DCOUT_V(
'C',
">- anynode tkn=" << *tk_it <<
" d=" << tk_it-toksVec.begin() <<
" txt=" << *tx_it << std::endl);
373 if ( *tk_it ==
"//" && *tx_it==
"*" ) {
375 DCOUT_V(
'C',
"--anynode: //*" << std::endl);
382 DCOUT_V(
'C',
">- anychild tkn=" << *tk_it <<
" d=" << tk_it-toksVec.begin() <<
" txt=" << *tx_it << std::endl);
383 if ( *tk_it ==
"/" && *tx_it==
"*" ) {
385 DCOUT_V(
'C',
"--anychild: /*" << std::endl);
392 DCOUT_V(
'C',
">- anylogp tkn=" << *tk_it <<
" d=" << tk_it-toksVec.begin() <<
" txt=" << *tx_it << std::endl);
393 if ( *tk_it ==
"//" && tx_it->size()) {
395 if ( tk_it != toksVec.end() && *tk_it !=
"[" && *tk_it !=
"]") {
396 std::pair<std::string,std::string>
p(
DDSplit(*tx_it));
398 DCOUT_V(
'C',
"--anylogp: " << *tx_it << std::endl);
406 DCOUT_V(
'C',
">- childlogp tkn=" << *tk_it <<
" d=" << tk_it-toksVec.begin() <<
" txt=" << *tx_it << std::endl);
407 if ( *tk_it ==
"/" && tx_it->size()) {
409 if ( tk_it == toksVec.end() - 1 ) {
410 DCOUT_V(
'C',
"--childlogp: " << *tx_it << std::endl);
411 std::pair<std::string,std::string>
p(
DDSplit(*tx_it));
416 if ( *tk_it ==
"/" || *tk_it==
"//") {
417 DCOUT_V(
'C',
"--childlogp: " << *tx_it << std::endl);
418 std::pair<std::string,std::string>
p(
DDSplit(*tx_it));
428 DCOUT_V(
'C',
">- anyposp tkn=" << *tk_it <<
" d=" << tk_it-toksVec.begin() <<
" txt=" << *tx_it << std::endl);
429 if ( *tk_it ==
"//" && tx_it->size()) {
431 if ( tk_it != toksVec.end() && *tk_it ==
"[" ) {
433 if ( tk_it == toksVec.end() || (tk_it != toksVec.end() && *tk_it !=
"]")) {
434 DCOUT_V(
'C', *tk_it <<
" " << *tx_it );
439 std::pair<std::string,std::string>
p(
DDSplit(*(tx_it-1)));
441 DCOUT_V(
'C',
"--anyposp: " << *tx_it <<
" " << atoi(tx_it->c_str()) << std::endl);
450 DCOUT_V(
'C',
">- childposp tkn=" << *tk_it <<
" d=" << tk_it-toksVec.begin() <<
" txt=" << *tx_it << std::endl);
451 if ( *tk_it ==
"/" && tx_it->size()) {
453 if ( tk_it != toksVec.end() && *tk_it==
"[" ) {
454 DCOUT_V(
'C',
"--childposp: " << *tx_it <<
" " << *tk_it << *(tx_it+1) << std::endl);
455 std::pair<std::string,std::string>
p(
DDSplit(*tx_it));
462 if (tk_it != toksVec.end() && *tk_it !=
"]")
471 throw cms::Exception(
"DDException") << nm <<
" syntax error in:\n" << sel
472 <<
"\n tkn=" << *tk_it <<
" txt=" << *tx_it;
477 throw cms::Exception(
"DDException") <<
"PartSelector: last element in selection std::string in " << sel
478 <<
"\nmust address a distinct LogicalPart or PosPart!";
484 DDPartSelection::const_iterator it(p.begin()), ed(p.end());
485 for (; it != ed; ++it) {
501 o <<
"{Syntax ERROR}";
507 std::ostream & operator<<(std::ostream & os, const std::vector<DDPartSelection> &
v)
509 std::vector<DDPartSelection>::const_iterator it(
v.begin()), ed(
v.end());
510 for (; it != (ed-1); ++it) {
511 os << *it << std::endl;
525 #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)
static PFTauRenderPlugin instance
rule< ScannerT > SimpleName
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()
void noNameSpace(char const *, char const *)
std::vector< DDPartSelRegExpLevel > * path(std::vector< DDPartSelRegExpLevel > *p=0)
definition(SpecParParser const &)
void operator()(char const *first, char const *last) const
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
ddselection_type selectionType_
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
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()