Main Page Class Hierarchy Compound List File List Compound Members File Members

# CmtModel Class Reference

`#include <cmt_model.h>`

List of all members.

## Static Public Methods
void | expand (const cmt_string& input_text)
## Static Private Methods
void | filter (cmt_string& text)
| Filters out all predefined XML constructs. More...
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} ). More...

## Member Function Documentation

void CmtModel::display ( | cmt_string & text )`[static, private]`

| Definition at line 16 of file cmt_model.cxx. Referenced by expand().
    00017 {
    00018   text.replace_all ("&lt;", "<");
    00019   text.replace_all ("&gt;", ">");
    00020   Symbol::expand (text);
    00021   cout << text;
    00022 }

void CmtModel::expand ( | const CmtSystem::cmt_string_vector & arguments )`[static, private]`

| 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 116 of file cmt_model.cxx.
    00117 {
    00118   int i;
    00119
    00120   Variable::VariableVector variables;
    00121
    00126   for (i = 0; i < arguments.size (); i++)
    00127     {
    00128       const cmt_string& arg = arguments[i];
    00129
    00130       if (arg.find ("=") != cmt_string::npos)
    00131         {
    00132           cmt_string name;
    00133           cmt_string value;
    00134           int pos = arg.find ("=");
    00135
    00136           arg.substr (0, pos, name);
    00137           arg.substr (pos + 1, value);
    00138
    00139           Variable* v = Variable::find (variables, name);
    00140           if (v == 0)
    00141             {
    00142               v = &(variables.add ());
    00143               v->set (name);
    00144             }
    00145
    00146           (*v) = value;
    00147         }
    00148     }
    00149
    00161   cmt_string text;
    00162
    00163   for (i = 0; i < arguments.size (); i++)
    00164     {
    00165       const cmt_string& arg = arguments[i];
    00166
    00167       if (arg.find ("=") == cmt_string::npos)
    00168         {
    00169           FragmentHandle fragment (arg);
    00170           fragment.copy (text, variables, 0);
    00171
    00172           filter (text);
    00173
    00174           int openmarker;
    00175           int closemarker;
    00176
    00177           CmtSystem::cmt_string_vector subargs;
    00178
    00179           cmt_string remaining;
    00180
    00181           for (;;)
    00182             {
    00188               openmarker = text.find ("<");
    00189               if (openmarker == cmt_string::npos) break;
    00190
    00191               closemarker = text.find (openmarker, "/>");
    00192               if (closemarker == cmt_string::npos)
    00193                 {
    00201                   text.substr (openmarker + 1, remaining);
    00202                   text.erase (openmarker + 1);
    00203
    00207                   display (text);
    00208                 }
    00209               else
    00210                 {
    00214                   cmt_string command;
    00215                   text.substr (openmarker + 1, closemarker - openmarker - 1, command);
    00216
    00220                   text.substr (closemarker + 2, remaining);
    00221                   text.erase (openmarker);
    00222
    00226                   display (text);
    00227
    00231                   CmtSystem::split (command, " ", subargs);
    00232
    00236                   expand (subargs);
    00237                 }
    00238
    00242               text = remaining;
    00243             }
    00244
    00248           display (text);
    00249         }
    00250     }
    00251 }

void CmtModel::expand ( | const cmt_string & input_text )`[static]`

| Definition at line 24 of file cmt_model.cxx. Referenced by Cmt::do_expand_model(), and expand().
    00025 {
    00026   int openmarker;
    00027   int closemarker;
    00028
    00029   CmtSystem::cmt_string_vector subargs;
    00030
    00031   cmt_string text = input_text;
    00032   cmt_string remaining;
    00033
    00034   filter (text);
    00035
    00036   for (;;)
    00037     {
    00043       openmarker = text.find ("<");
    00044       if (openmarker == cmt_string::npos) break;
    00045
    00046       closemarker = text.find (openmarker, "/>");
    00047       if (closemarker == cmt_string::npos) break;
    00048
    00049       if (CmtSystem::testenv ("CMTTESTMODEL"))
    00050         {
    00051           cerr << "text=[" << text << "]" << endl;
    00052         }
    00053
    00054
    00058       cmt_string command;
    00059       text.substr (openmarker + 1, closemarker - openmarker - 1, command);
    00060
    00061       if (CmtSystem::testenv ("CMTTESTMODEL"))
    00062         {
    00063           cerr << "command=[" << command << "]" << endl;
    00064         }
    00065
    00069       text.substr (closemarker + 2, remaining);
    00070
    00074       text.erase (openmarker);
    00075
    00079       display (text);
    00080
    00084       CmtSystem::split (command, " ", subargs);
    00085
    00089       expand (subargs);
    00090
    00094       text = remaining;
    00095     }
    00096
    00097   if (CmtSystem::testenv ("CMTTESTMODEL"))
    00098     {
    00099       cerr << "text=[" << text << "]" << endl;
    00100     }
    00101
    00105   display (text);
    00106   cout << endl;
    00107 }

void CmtModel::filter ( | cmt_string & text )`[static, private]`

| Filters out all predefined XML constructs. Definition at line 9 of file cmt_model.cxx. Referenced by expand().
    00010 {
    00011   text.replace_all ("<cmt:tab/>", "\t");
    00012   text.replace_all ("<cmt:cr/>",  "\r");
    00013   text.replace_all ("<cmt:lf/>",  "\n");
    00014 }

The documentation for this class was generated from the following files:

- cmt_model.h
- cmt_model.cxx