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

PathBuilder Class Reference

Inheritance diagram for PathBuilder:

[legend]
Collaboration diagram for PathBuilder:

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

Implements ValueBuilder.

Definition at line 1937 of file cmt_symbol.cxx.

References action_show_action, action_show_actions, action_show_macro, action_show_macros, action_show_set, action_show_sets, ActionType, SymbolValueList::command_type, CommandPath, CommandPathAppend, CommandPathPrepend, CommandPathRemove, CommandPathRemoveRegexp, SymbolValueList::discarded, Use::discarded, cmt_string::find(), find_path_entry(), Cmt::get_action(), Cmt::get_current_target(), Use::get_package_name(), Cmt::get_quiet(), CmtSystem::getenv(), SymbolValueList::is_reflexive, cmt_regexp::match(), Symbol::name, cmt_string::npos, CmtSystem::path_separator(), cmt_string::replace_all(), resolve_value(), resolve_value_for_macros(), SymbolValueList::select_first(), SymbolValueList::show(), cmt_vector< cmt_string >::size(), cmt_vector< SymbolValueList >::size(), CmtSystem::split(), SymbolValue::text, SymbolValueList::use, Symbol::value_is_reflexive(), Symbol::value_lists, SymbolValueList::values, and Cmt::vector_to_string().

01939 {
01940     // Control of recursivity
01941   static int level = 0;
01942 
01943   int show_it = 0;
01944 
01945   cmt_string temp;
01946   cmt_string previous_temp;
01947   cmt_string new_value;
01948   static const cmt_string empty;
01949 
01950   static cmt_string path_separator = CmtSystem::path_separator ();
01951 
01952   ActionType action = Cmt::get_action ();
01953 
01954   if (action == action_show_set)
01955     {
01956       if (symbol.name == Cmt::get_current_target ())
01957         {
01958             // Should not display on recursive calls
01959           if (level == 0) show_it = 1;
01960         }
01961     }
01962 
01963   level++;
01964 
01965   temp = CmtSystem::getenv (symbol.name);
01966 
01967   bool first_definition = true;
01968   bool defined = false;
01969 
01970   for (int i = 0; i < symbol.value_lists.size (); i++)
01971     {
01972       const SymbolValueList& value_list = symbol.value_lists[i];
01973 
01974       if ((value_list.use != 0) &&
01975           (value_list.use->discarded)) continue;
01976 
01977       const int selected = value_list.select_first ();
01978       
01979       if (selected < 0) continue;
01980  
01981       SymbolValue& value = value_list.values[selected];
01982           
01983       if (show_it)
01984         {
01985           value_list.show (symbol, value, first_definition);
01986         }
01987           
01988       if (value_list.discarded) continue;
01989 
01990       new_value = value.text;
01991           
01992           //resolve_value (new_value);
01993       resolve_value_for_macros (new_value);
01994           
01995       switch (value_list.command_type)
01996         {
01997           case CommandPath :
01998             
01999             if (!value_list.is_reflexive || 
02000                 !symbol.value_is_reflexive (value.text))
02001               {
02002                 resolve_value (new_value, symbol.name, temp);
02003                 temp = new_value;
02004 
02005                 if (!defined)
02006                   {
02007                     defined = true;
02008                   }
02009                 else
02010                   {
02011                     if ((!Cmt::get_quiet ()) &&
02012                         ((action == action_show_macro) ||
02013                          (action == action_show_set) ||
02014                          (action == action_show_action) ||
02015                          (action == action_show_macros) ||
02016                          (action == action_show_sets) ||
02017                          (action == action_show_actions)))
02018                       {
02019                         cerr << "#CMT> Warning: Symbol " << symbol.name << " overridden";
02020                         
02021                         if (value_list.use != 0)
02022                           {
02023                             cerr << " in package " << value_list.use->get_package_name ();
02024                           }
02025                         
02026                         cerr << endl;
02027                       }
02028                   }
02029               }
02030 
02031             break;
02032           case CommandPathAppend :
02033               
02034             if (new_value != "")
02035               {
02036                 if (!find_path_entry (temp, new_value))
02037                   {
02038                     if (temp != "") temp += path_separator;
02039                       
02040                     temp += new_value;
02041                   }
02042               }
02043                   
02044             break;
02045           case CommandPathPrepend :
02046               
02047             if (new_value != "")
02048               {
02049                 if (!find_path_entry (temp, new_value))
02050                   {
02051                     previous_temp = temp;
02052                     temp = new_value;
02053                     if (previous_temp != "") temp += path_separator;
02054                     temp += previous_temp;
02055                   }
02056               }
02057                   
02058             break;
02059           case CommandPathRemove :
02060               
02061             if (new_value != "")
02062               {
02063                 CmtSystem::cmt_string_vector paths;
02064                   
02065                 CmtSystem::split (temp, path_separator, paths);
02066                   
02067                 for (int j = 0; j < paths.size (); ++j)
02068                   {
02069                     cmt_string& s = paths[j];
02070                       
02071                     if (s.find (new_value) != cmt_string::npos)
02072                       {
02073                         s = "";
02074                       }
02075                   }
02076 
02077                 Cmt::vector_to_string (paths, path_separator, temp);
02078                 temp.replace_all ("::", ":");
02079                 temp.replace_all (";;", ";");
02080               }
02081               
02082             break;
02083           case CommandPathRemoveRegexp :
02084 
02085             if (new_value != "")
02086               {
02087                 cmt_regexp e (new_value);
02088 
02089                 CmtSystem::cmt_string_vector paths;
02090                   
02091                 CmtSystem::split (temp, path_separator, paths);
02092                   
02093                 for (int j = 0; j < paths.size (); ++j)
02094                   {
02095                     cmt_string& s = paths[j];
02096 
02097                     if (CmtSystem::getenv ("TESTPRR") != "")
02098                       {
02099                         cout << "PRR> s=[" << s << "]";
02100                       }
02101 
02102                     if (e.match (s))
02103                       {
02104                         s = "";
02105 
02106                         if (CmtSystem::getenv ("TESTPRR") != "")
02107                           {
02108                             cout << " match ";
02109                           }
02110                       }
02111                     else
02112                       {
02113                         if (CmtSystem::getenv ("TESTPRR") != "")
02114                           {
02115                             cout << " no match ";
02116                           }
02117                       }
02118 
02119                     if (CmtSystem::getenv ("TESTPRR") != "")
02120                       {
02121                         cout << endl;
02122                       }
02123                   }
02124 
02125                 Cmt::vector_to_string (paths, path_separator, temp);
02126                 temp.replace_all ("::", ":");
02127                 temp.replace_all (";;", ";");
02128               }
02129               
02130             break;
02131         }
02132 
02133     }
02134 
02135   level--;
02136   
02137   return (temp);
02138 }

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

Implements ValueBuilder.

Definition at line 2141 of file cmt_symbol.cxx.

References SymbolValueList::command_type, CommandPath, CommandPathAppend, CommandPathPrepend, CommandPathRemove, CommandPathRemoveRegexp, Use::discarded, SymbolValueList::discarded, cmt_string::find(), CmtSystem::getenv(), cmt_regexp::match(), Symbol::name, cmt_string::npos, CmtSystem::path_separator(), cmt_string::replace_all(), resolve_value(), resolve_value_for_macros(), SymbolValueList::select_first(), cmt_vector< cmt_string >::size(), cmt_vector< SymbolValueList >::size(), CmtSystem::split(), SymbolValue::text, SymbolValueList::use, Symbol::value_lists, SymbolValueList::values, and Cmt::vector_to_string().

02143 {
02144     // Control of recursivity
02145   static int level = 0;
02146 
02147   cmt_string temp;
02148   cmt_string new_value;
02149   static const cmt_string empty;
02150 
02151   static cmt_string path_separator = CmtSystem::path_separator ();
02152 
02153   temp = CmtSystem::getenv (symbol.name);
02154 
02155     //cerr << "#####1 temp=" << temp << endl;
02156 
02157   for (int i = 0; i < symbol.value_lists.size (); i++)
02158     {
02159       const SymbolValueList& value_list = symbol.value_lists[i];
02160 
02161       if (value_list.discarded) continue;
02162 
02163       if ((value_list.use != 0) &&
02164           (value_list.use->discarded)) continue;
02165 
02166       const int selected = value_list.select_first ();
02167       
02168       if (selected < 0) continue;
02169  
02170       SymbolValue& value = value_list.values[selected];
02171           
02172       new_value = value.text;
02173           
02174           //resolve_value (new_value);
02175 
02176         //cerr << "#####1 new_value=" << new_value << endl;
02177 
02178       resolve_value_for_macros (new_value);
02179       resolve_value (new_value);
02180           
02181         //cerr << "#####2 new_value=" << new_value << endl;
02182 
02183       switch (value_list.command_type)
02184         {
02185           case CommandPath :
02186             
02187             temp = "";
02188             
02189             break;
02190           case CommandPathAppend :
02191           case CommandPathPrepend :
02192           case CommandPathRemove :
02193 
02194             if (new_value != "")
02195               {
02196                 CmtSystem::cmt_string_vector paths;
02197                   
02198                 CmtSystem::split (temp, path_separator, paths);
02199                   
02200                 for (int j = 0; j < paths.size (); ++j)
02201                   {
02202                     cmt_string& s = paths[j];
02203                       
02204                     if (s.find (new_value) != cmt_string::npos)
02205                       {
02206                         s = "";
02207                       }
02208 
02209                     if (j > 0)
02210                       {
02211                         cmt_string& s2 = paths[j-1];
02212                         if (s2 == s)
02213                           {
02214                             s2 = "";
02215                           }
02216                       }
02217                   }
02218 
02219                 Cmt::vector_to_string (paths, path_separator, temp);
02220                 temp.replace_all ("::", ":");
02221                 temp.replace_all (";;", ";");
02222               }
02223               
02224             break;
02225           case CommandPathRemoveRegexp :
02226 
02227             if (new_value != "")
02228               {
02229                 cmt_regexp e (new_value);
02230 
02231                 CmtSystem::cmt_string_vector paths;
02232                   
02233                 CmtSystem::split (temp, path_separator, paths);
02234                   
02235                 for (int j = 0; j < paths.size (); ++j)
02236                   {
02237                     cmt_string& s = paths[j];
02238                       
02239                     if (e.match (s))
02240                       {
02241                         s = "";
02242                       }
02243 
02244                     if (j > 0)
02245                       {
02246                         cmt_string& s2 = paths[j-1];
02247                         if (s2 == s)
02248                           {
02249                             s2 = "";
02250                           }
02251                       }
02252                   }
02253 
02254                 Cmt::vector_to_string (paths, path_separator, temp);
02255                 temp.replace_all ("::", ":");
02256                 temp.replace_all (";;", ";");
02257               }
02258               
02259             break;
02260         }
02261     }
02262 
02263     //cerr << "#####2 temp=" << temp << endl;
02264   
02265   return (temp);
02266 }

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