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

SetBuilder Class Reference

Inheritance diagram for SetBuilder:

[legend]
Collaboration diagram for SetBuilder:

[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 SetBuilder::build (? const Symbol &? ? symbol,
const cmt_string &? ? tag_name = ""
)? [virtual]
?

Implements ValueBuilder.

Definition at line 1756 of file cmt_symbol.cxx.

References cmt_regexp::iterator::_length, cmt_regexp::iterator::_pos, action_show_action, action_show_actions, action_show_macro, action_show_macros, action_show_set, action_show_sets, ActionType, cmt_regexp::begin(), SymbolValueList::command_type, CommandAlias, CommandSet, CommandSetAppend, CommandSetPrepend, CommandSetRemove, CommandSetRemoveRegexp, SymbolValueList::discarded, Use::discarded, cmt_regexp::end(), cmt_string::erase(), Cmt::get_action(), Cmt::get_current_target(), Use::get_package_name(), Cmt::get_quiet(), CmtSystem::getenv(), SymbolValueList::is_reflexive, Symbol::name, cmt_string::replace_all(), resolve_value(), resolve_value_for_macros(), SymbolValueList::select_first(), SymbolValueList::show(), cmt_vector< SymbolValueList >::size(), SymbolValue::text, SymbolValueList::use, Symbol::value_is_reflexive(), Symbol::value_lists, and SymbolValueList::values.

01758 {
01759     // Control of recursivity
01760   static int level = 0;
01761 
01762   int show_it = 0;
01763 
01764   cmt_string temp;
01765   cmt_string previous_temp;
01766   cmt_string new_value;
01767   static const cmt_string empty;
01768 
01769   ActionType action = Cmt::get_action ();
01770 
01771   if (action == action_show_set)
01772     {
01773       if (symbol.name == Cmt::get_current_target ())
01774         {
01775              // Should not display on recursive calls
01776           if (level == 0) show_it = 1;
01777         }
01778     }
01779 
01780   level++;
01781 
01782   temp = "";
01783 
01784   bool first_definition = true;
01785   bool defined = false;
01786 
01787   for (int i = 0; i < symbol.value_lists.size (); i++)
01788     {
01789       const SymbolValueList& value_list = symbol.value_lists[i];
01790 
01791       if ((value_list.use != 0) &&
01792           (value_list.use->discarded)) continue;
01793 
01794       const int selected = value_list.select_first ();
01795 
01796       if (selected < 0) continue;
01797 
01798       SymbolValue& value = value_list.values[selected];
01799 
01800       if (show_it)
01801         {
01802           value_list.show (symbol, value, first_definition);
01803         }
01804       
01805       if (value_list.discarded) continue;
01806 
01807         //
01808         // One should accumulate values if it refers to
01809         // itself.
01810         //
01811       
01812       new_value = value.text;
01813       
01814       resolve_value_for_macros (new_value);
01815       
01816       switch (value_list.command_type)
01817         {
01818           case CommandSet :
01819 
01820             if (!value_list.is_reflexive || 
01821                 !symbol.value_is_reflexive (value.text))
01822               {
01823                 resolve_value (new_value, symbol.name, temp);
01824                 temp = new_value;
01825               }
01826             else if (temp == "")
01827               {
01828                 temp = CmtSystem::getenv (symbol.name);
01829               }
01830 
01831             if (!defined)
01832               {
01833                 defined = true;
01834               }
01835             else
01836               {
01837                 if ((!Cmt::get_quiet ()) &&
01838                     ((action == action_show_macro) ||
01839                      (action == action_show_set) ||
01840                      (action == action_show_action) ||
01841                      (action == action_show_macros) ||
01842                      (action == action_show_sets) ||
01843                      (action == action_show_actions)))
01844                   {
01845                     cerr << "#CMT> Warning: Symbol " << symbol.name << " overridden";
01846 
01847                     if (value_list.use != 0)
01848                       {
01849                         cerr << " in package " << value_list.use->get_package_name ();
01850                       }
01851 
01852                     cerr << endl;
01853                   }
01854               }
01855 
01856             break;
01857           case CommandSetAppend :
01858             
01859             if (new_value != "")
01860               {
01861                 temp += new_value;
01862               }
01863             
01864             break;
01865           case CommandSetPrepend :
01866             
01867             if (new_value != "")
01868               {
01869                 previous_temp = temp;
01870                 temp = new_value;
01871                 temp += previous_temp;
01872               }
01873             
01874             break;
01875           case CommandSetRemove :
01876             
01877             if (new_value != "")
01878               {
01879                 temp.replace_all (new_value, empty);
01880               }
01881             
01882             break;
01883           case CommandSetRemoveRegexp :
01884             
01885             if (new_value != "")
01886               {
01887                 cmt_regexp e (new_value);
01888                 cmt_regexp::iterator it;
01889 
01890                 for (;;)
01891                   {
01892                     it = e.begin (temp);
01893                     if (it == e.end ()) break;
01894 
01895                     temp.erase (it._pos, it._length);
01896                   }
01897               }
01898             
01899             break;
01900           case CommandAlias :
01901             
01902             resolve_value (new_value, symbol.name, temp);
01903             temp = new_value;
01904             
01905             break;
01906         }
01907     }
01908 
01909   level--;
01910 
01911   return (temp);
01912 }

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

Implements ValueBuilder.

Definition at line 23 of file cmt_symbol.cxx.

00025       {
00026         static const cmt_string empty = "";
00027         return (empty);
00028       }

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