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!") );
An exception for DDD errors.
#define DCOUT_V(M_v_Y, M_v_S)
std::vector< std::vector< double > > tmp
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'