Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

SetBuilder Class Reference

Inheritance diagram for SetBuilder:

Inheritance graph
[legend]
Collaboration diagram for SetBuilder:

Collaboration graph
[legend]
List of all members.

Public Member Functions

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 1780 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< T >::size(), SymbolValue::text, SymbolValueList::use, Symbol::value_is_reflexive(), Symbol::value_lists, and SymbolValueList::values.

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

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 Mon May 2 10:26:01 2005 for CMT by doxygen 1.3.5