#include
Static Public Methods |
|
| void? | expand (const cmt_string &input_text) |
| void? | strict_expand (const cmt_string &input_text) |
| ? |
Display what is left after extracting the last pattern. |
| void? | test_regexp (const cmt_string &pattern, const cmt_string &input_text) |
| ? |
We start by decoding all [variable=value] pairs from the arguments A vector of Variables is filled from them. |
Static Private Methods |
|
| void? | filter (cmt_string &text) |
| ? |
Filters out all predefined XML constructs. |
| void? | display (cmt_string &text) |
| void? | expand (const CmtSystem::cmt_string_vector &arguments) |
| ? |
Expands a model file Arguments are : model-name : name of a model file var=value : variable value to be expanded (will take the form ${var} ). |
|
| ? |
Definition at line 21 of file cmt_model.cxx. References Symbol::expand(), and cmt_string::replace_all(). Referenced by expand(), and strict_expand(). 00022 {
00023 text.replace_all ("<", "<");
00024 text.replace_all (">", ">");
00025 text.replace_all ("\\\"", "\"");
00026 text.replace_all ("\\\'", "\'");
00027 text.replace_all ("
|
|
| ? |
Expands a model file Arguments are : model-name : name of a model file var=value : variable value to be expanded (will take the form ${var} ). Definition at line 416 of file cmt_model.cxx. References cmt_vector< Variable >::add(), FragmentHandle::copy(), display(), cmt_string::erase(), expand(), filter(), Variable::find(), cmt_string::find(), cmt_string::npos, Variable::set(), cmt_vector< cmt_string >::size(), CmtSystem::split(), and cmt_string::substr(). 00417 {
00418 int i;
00419
00420 Variable::VariableVector variables;
00421
00426 for (i = 0; i < arguments.size (); i++)
00427 {
00428 const cmt_string& arg = arguments[i];
00429
00430 if (arg.find ("=") != cmt_string::npos)
00431 {
00432 cmt_string name;
00433 cmt_string value;
00434 int pos = arg.find ("=");
00435
00436 arg.substr (0, pos, name);
00437 arg.substr (pos + 1, value);
00438
00439 Variable* v = Variable::find (variables, name);
00440 if (v == 0)
00441 {
00442 v = &(variables.add ());
00443 v->set (name);
00444 }
00445
00446 (*v) = value;
00447 }
00448 }
00449
00461 cmt_string text;
00462
00463 for (i = 0; i < arguments.size (); i++)
00464 {
00465 const cmt_string& arg = arguments[i];
00466
00467 if (arg.find ("=") == cmt_string::npos)
00468 {
00469 FragmentHandle fragment (arg);
00470 fragment.copy (text, variables, 0);
00471
00472 filter (text);
00473
00474 int openmarker;
00475 int closemarker;
00476
00477 CmtSystem::cmt_string_vector subargs;
00478
00479 cmt_string remaining;
00480
00481 for (;;)
00482 {
00488 openmarker = text.find ("<");
00489 if (openmarker == cmt_string::npos) break;
00490
00491 closemarker = text.find (openmarker, "/>");
00492 if (closemarker == cmt_string::npos)
00493 {
00501 text.substr (openmarker + 1, remaining);
00502 text.erase (openmarker + 1);
00503
00507 display (text);
00508 }
00509 else
00510 {
00514 cmt_string command;
00515 text.substr (openmarker + 1, closemarker - openmarker - 1, command);
00516
00520 text.substr (closemarker + 2, remaining);
00521 text.erase (openmarker);
00522
00526 display (text);
00527
00531 CmtSystem::split (command, " ", subargs);
00532
00536 expand (subargs);
00537 }
00538
00542 text = remaining;
00543 }
00544
00548 display (text);
00549 }
00550 }
00551 }
|
|
| ? |
Definition at line 32 of file cmt_model.cxx. References display(), cmt_string::erase(), filter(), cmt_string::find(), cmt_string::npos, CmtSystem::split(), cmt_string::substr(), and CmtSystem::testenv(). Referenced by Cmt::do_expand_model(), and expand(). 00033 {
00034 int openmarker;
00035 int closemarker;
00036
00037 CmtSystem::cmt_string_vector subargs;
00038
00039 cmt_string text = input_text;
00040 cmt_string remaining;
00041
00042 filter (text);
00043
00044 for (;;)
00045 {
00051 openmarker = text.find ("<");
00052 if (openmarker == cmt_string::npos) break;
00053
00054 closemarker = text.find (openmarker, "/>");
00055 if (closemarker == cmt_string::npos) break;
00056
00057 if (CmtSystem::testenv ("CMTTESTMODEL"))
00058 {
00059 cerr << "text=[" << text << "]" << endl;
00060 }
00061
00062
00066 cmt_string command;
00067 text.substr (openmarker + 1, closemarker - openmarker - 1, command);
00068
00069 if (CmtSystem::testenv ("CMTTESTMODEL"))
00070 {
00071 cerr << "command=[" << command << "]" << endl;
00072 }
00073
00077 text.substr (closemarker + 2, remaining);
00078
00082 text.erase (openmarker);
00083
00087 display (text);
00088
00092 CmtSystem::split (command, " ", subargs);
00093
00097 expand (subargs);
00098
00102 text = remaining;
00103 }
00104
00105 if (CmtSystem::testenv ("CMTTESTMODEL"))
00106 {
00107 cerr << "text=[" << text << "]" << endl;
00108 }
00109
00113 display (text);
00114 cout << endl;
00115 }
|
|
| ? |
Filters out all predefined XML constructs. Definition at line 14 of file cmt_model.cxx. References cmt_string::replace_all(). Referenced by expand(), and strict_expand(). 00015 {
00016 text.replace_all ("
|
|
| ? |
Display what is left after extracting the last pattern. Definition at line 117 of file cmt_model.cxx. References cmt_regexp::iterator::_length, cmt_regexp::iterator::_pos, cmt_vector< Variable >::add(), cmt_vector< cmt_string >::add(), cmt_regexp::begin(), cmt_vector< cmt_string >::clear(), FragmentHandle::copy(), display(), cmt_regexp::end(), cmt_string::erase(), filter(), Variable::find(), cmt_string::find(), Variable::set(), cmt_string::size(), cmt_vector< cmt_string >::size(), CmtSystem::split(), and cmt_string::substr(). Referenced by Cmt::do_expand_model(). 00118 {
00119 CmtSystem::cmt_string_vector subargs;
00120
00121 cmt_string text = input_text;
00122 cmt_string remaining;
00123
00124 // The patterns for syntax parsing
00125
00126 cmt_string open_element = "
|
|
||||||||||||
| ? |
We start by decoding all [variable=value] pairs from the arguments A vector of Variables is filled from them. Definition at line 385 of file cmt_model.cxx. References cmt_regexp::iterator::_length, cmt_regexp::iterator::_pos, cmt_regexp::begin(), and cmt_regexp::end(). Referenced by Cmt::do_expand_model(). 00386 {
00387 cout << "Testing pattern [" << pattern << "] against [" << input_text << "]" << endl;
00388
00389 cmt_regexp exp (pattern);
00390
00391 cmt_regexp::iterator it;
00392
00393 for (int pos = 0; pos < 10; pos++)
00394 {
00395 it = exp.begin (input_text, pos);
00396
00397 if (it == exp.end ())
00398 {
00399 cout << "No match" << endl;
00400 }
00401 else
00402 {
00403 cout << "p=" << it._pos << " l=" << it._length << " -> [" << it (input_text) << "]" << endl;
00404 }
00405 }
00406 }
|