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

MacroBuilder Class Reference

Inheritance diagram for MacroBuilder:

[legend]
Collaboration diagram for MacroBuilder:

[legend]
List of all members.

Public Methods

const cmt_string? build (const Symbol &symbol, const cmt_string &tag_name="")
const cmt_string? clean (const Symbol &symbol, const cmt_string &tag_name="")

Member Function Documentation

const cmt_string MacroBuilder::build (? const Symbol &? ? symbol,
const cmt_string &? ? tag_name = ""
)? [virtual]
?

Implements ValueBuilder.

Definition at line 2269 of file cmt_symbol.cxx.

References cmt_regexp::iterator::_length, cmt_regexp::iterator::_pos, action_show_macro, ActionType, cmt_regexp::begin(), SymbolValueList::command_type, CommandMacro, CommandMacroAppend, CommandMacroPrepend, CommandMacroRemove, CommandMacroRemoveAll, CommandMacroRemoveAllRegexp, CommandMacroRemoveRegexp, SymbolValueList::discarded, Use::discarded, cmt_regexp::end(), cmt_string::erase(), Cmt::get_action(), Cmt::get_current_target(), SymbolValueList::is_reflexive, Symbol::name, cmt_string::replace(), cmt_string::replace_all(), SymbolValueList::select_first(), SymbolValueList::show(), cmt_vector< SymbolValueList >::size(), SymbolValue::text, SymbolValueList::use, Symbol::value_is_reflexive(), Symbol::value_lists, and SymbolValueList::values.

02271 {
02272     // Control of recursivity
02273   static int level = 0;
02274 
02275   cmt_string temp;
02276   cmt_string previous_temp;
02277   static const cmt_string empty;
02278   int show_it = 0;
02279 
02280   ActionType action = Cmt::get_action ();
02281 
02282   if (action == action_show_macro)
02283     {
02284       if (symbol.name == Cmt::get_current_target ())
02285         {
02286              // Should not display on recursive calls
02287           if (level == 0) show_it = 1;
02288         }
02289     }
02290 
02291   level++;
02292 
02293   temp = "";
02294 
02295   int i;
02296 
02297   bool first_definition = true;
02298   bool defined = false;
02299 
02300   for (i = 0; i < symbol.value_lists.size (); i++)
02301     {
02302       const SymbolValueList& value_list = symbol.value_lists[i];
02303 
02304       if ((value_list.use != 0) &&
02305           (value_list.use->discarded)) continue;
02306 
02307       if (value_list.command_type != CommandMacroPrepend) continue;
02308 
02309       const int selected = value_list.select_first (tag_name);
02310 
02311       if (selected < 0) continue;
02312 
02313       SymbolValue& value = value_list.values[selected];
02314 
02315       if (show_it)
02316         {
02317           value_list.show (symbol, value, first_definition);
02318         }
02319 
02320       if (value_list.discarded) continue;
02321 
02322       previous_temp = temp;
02323       temp = value.text;
02324       temp += previous_temp;
02325     }
02326 
02327   previous_temp = temp;
02328   temp = "";
02329 
02330   first_definition = true;
02331 
02332   for (i = 0; i < symbol.value_lists.size (); i++)
02333     {
02334       const SymbolValueList& value_list = symbol.value_lists[i];
02335 
02336       if ((value_list.use != 0) &&
02337           (value_list.use->discarded)) continue;
02338 
02339       if (value_list.command_type != CommandMacro) continue;
02340 
02341       const int selected = value_list.select_first (tag_name);
02342 
02343       if (selected < 0) continue;
02344 
02345       SymbolValue& value = value_list.values[selected];
02346 
02347       if (show_it)
02348         {
02349           value_list.show (symbol, value, first_definition);
02350         }
02351 
02352       // WARNING:
02353       // Commented just for a test : should be uncommented after the test
02354       if (value_list.discarded) continue;
02355       
02356       if (!value_list.is_reflexive || 
02357           !symbol.value_is_reflexive (value.text))
02358         {
02359           temp = value.text;
02360 
02361           if (!defined)
02362             {
02363               defined = true;
02364             }
02365           else
02366             {
02367               /*
02368               if ((!Cmt::get_quiet ()) &&
02369                   ((action == action_show_macro) ||
02370                    (action == action_show_set) ||
02371                    (action == action_show_action) ||
02372                    (action == action_show_macros) ||
02373                    (action == action_show_sets) ||
02374                    (action == action_show_actions)))
02375                 {
02376                   cerr << "#CMT> Warning: Symbol " << symbol.name << " overridden";
02377                   
02378                   if (value_list.use != 0)
02379                     {
02380                       cerr << " in package " << value_list.use->get_package_name ();
02381                     }
02382 
02383                   cerr << endl;
02384                 }
02385               */
02386             }
02387         }
02388     }
02389 
02390   previous_temp += temp;
02391   temp = previous_temp;
02392 
02393   for (i = 0; i < symbol.value_lists.size (); i++)
02394     {
02395       const SymbolValueList& value_list = symbol.value_lists[i];
02396 
02397       if ((value_list.use != 0) &&
02398           (value_list.use->discarded)) continue;
02399 
02400       if (value_list.command_type != CommandMacroAppend) continue;
02401 
02402       const int selected = value_list.select_first (tag_name);
02403 
02404       if (selected < 0) continue;
02405 
02406       SymbolValue& value = value_list.values[selected];
02407 
02408       if (show_it)
02409         {
02410           value_list.show (symbol, value, first_definition);
02411         }
02412 
02413       if (value_list.discarded) continue;
02414 
02415       temp += value.text;
02416     }
02417 
02418   for (i = 0; i < symbol.value_lists.size (); i++)
02419     {
02420       const SymbolValueList& value_list = symbol.value_lists[i];
02421 
02422       if ((value_list.use != 0) &&
02423           (value_list.use->discarded)) continue;
02424 
02425       if ((value_list.command_type != CommandMacroRemove) &&
02426           (value_list.command_type != CommandMacroRemoveRegexp) &&
02427           (value_list.command_type != CommandMacroRemoveAll) &&
02428           (value_list.command_type != CommandMacroRemoveAllRegexp)) continue;
02429 
02430       const int selected = value_list.select_first (tag_name);
02431 
02432       if (selected < 0) continue;
02433 
02434       SymbolValue& value = value_list.values[selected];
02435 
02436       if (show_it)
02437         {
02438           value_list.show (symbol, value, first_definition);
02439         }
02440 
02441       if (value_list.discarded) continue;
02442 
02443       switch (value_list.command_type)
02444         {
02445           case CommandMacroRemove :
02446             temp.replace (value.text, empty);
02447             break;
02448           case CommandMacroRemoveRegexp :
02449             if (value.text != "")
02450               {
02451                 cmt_regexp e (value.text);
02452                 cmt_regexp::iterator it;
02453 
02454                 it = e.begin (temp);
02455                 if (it != e.end ())
02456                   {
02457                     temp.erase (it._pos, it._length);
02458                   }
02459               }
02460             break;
02461           case CommandMacroRemoveAll :
02462             temp.replace_all (value.text, empty);
02463             break;
02464           case CommandMacroRemoveAllRegexp :
02465             if (value.text != "")
02466               {
02467                 cmt_regexp e (value.text);
02468                 cmt_regexp::iterator it;
02469 
02470                 for (;;)
02471                   {
02472                     it = e.begin (temp);
02473                     if (it != e.end ())
02474                       {
02475                         temp.erase (it._pos, it._length);
02476                       }
02477                     else
02478                       {
02479                         break;
02480                       }
02481                   }
02482               }
02483             break;
02484         }
02485     }
02486 
02487   level--;
02488 
02489   return (temp);
02490 }

const cmt_string MacroBuilder::clean (? const Symbol &? ? symbol,
const cmt_string &? ? tag_name = ""
)? [inline, virtual]
?

Implements ValueBuilder.

Definition at line 49 of file cmt_symbol.cxx.

00051       {
00052         static const cmt_string empty = "";
00053         return (empty);
00054       }

The documentation for this class was generated from the following file:
Generated on Wed Sep 1 11:00:44 2004 for CMT by 1.2.18