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="") |
|
Implements ValueBuilder. Definition at line 1984 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, CmtSystem::cmt_string_vector, 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, CmtSystem::path_separator(), cmt_string::replace_all(), resolve_value(), resolve_value_for_macros(), SymbolValueList::select_first(), SymbolValueList::show(), cmt_vector< T >::size(), CmtSystem::split(), SymbolValue::text, SymbolValueList::use, Symbol::value_is_reflexive(), Symbol::value_lists, SymbolValueList::values, and Cmt::vector_to_string().
01986 { 01987 // Control of recursivity 01988 static int level = 0; 01989 01990 bool show_it = false; 01991 01992 cmt_string temp; 01993 cmt_string previous_temp; 01994 cmt_string new_value; 01995 static const cmt_string empty; 01996 01997 static cmt_string path_separator = CmtSystem::path_separator (); 01998 01999 ActionType action = Cmt::get_action (); 02000 02001 if (action == action_show_set) 02002 { 02003 if (symbol.name == Cmt::get_current_target ()) 02004 { 02005 // Should not display on recursive calls 02006 if (level == 0) show_it = m_display_it; 02007 } 02008 } 02009 02010 level++; 02011 02012 temp = CmtSystem::getenv (symbol.name); 02013 02014 bool first_definition = true; 02015 bool defined = false; 02016 02017 for (int i = 0; i < symbol.value_lists.size (); i++) 02018 { 02019 const SymbolValueList& value_list = symbol.value_lists[i]; 02020 02021 if ((value_list.use != 0) && 02022 (value_list.use->discarded)) continue; 02023 02024 const int selected = value_list.select_first (); 02025 02026 if (selected < 0) continue; 02027 02028 SymbolValue& value = value_list.values[selected]; 02029 02030 if (show_it) 02031 { 02032 value_list.show (symbol, value, first_definition); 02033 } 02034 02035 if (value_list.discarded) continue; 02036 02037 new_value = value.text; 02038 02039 //resolve_value (new_value); 02040 resolve_value_for_macros (new_value); 02041 02042 switch (value_list.command_type) 02043 { 02044 case CommandPath : 02045 02046 if (!value_list.is_reflexive || 02047 !symbol.value_is_reflexive (value.text)) 02048 { 02049 resolve_value (new_value, symbol.name, temp); 02050 temp = new_value; 02051 02052 if (!defined) 02053 { 02054 defined = true; 02055 } 02056 else 02057 { 02058 if ((!Cmt::get_quiet ()) && 02059 ((action == action_show_macro) || 02060 (action == action_show_set) || 02061 (action == action_show_action) || 02062 (action == action_show_macros) || 02063 (action == action_show_sets) || 02064 (action == action_show_actions))) 02065 { 02066 cerr << "#CMT> Warning: Symbol " << symbol.name << " overridden"; 02067 02068 if (value_list.use != 0) 02069 { 02070 cerr << " in package " << value_list.use->get_package_name (); 02071 } 02072 02073 cerr << endl; 02074 } 02075 } 02076 } 02077 02078 break; 02079 case CommandPathAppend : 02080 02081 if (new_value != "") 02082 { 02083 if (!find_path_entry (temp, new_value)) 02084 { 02085 if (temp != "") temp += path_separator; 02086 02087 temp += new_value; 02088 } 02089 } 02090 02091 break; 02092 case CommandPathPrepend : 02093 02094 if (new_value != "") 02095 { 02096 if (!find_path_entry (temp, new_value)) 02097 { 02098 previous_temp = temp; 02099 temp = new_value; 02100 if (previous_temp != "") temp += path_separator; 02101 temp += previous_temp; 02102 } 02103 } 02104 02105 break; 02106 case CommandPathRemove : 02107 02108 if (new_value != "") 02109 { 02110 CmtSystem::cmt_string_vector paths; 02111 02112 CmtSystem::split (temp, path_separator, paths); 02113 02114 for (int j = 0; j < paths.size (); ++j) 02115 { 02116 cmt_string& s = paths[j]; 02117 02118 if (s.find (new_value) != cmt_string::npos) 02119 { 02120 s = ""; 02121 } 02122 } 02123 02124 Cmt::vector_to_string (paths, path_separator, temp); 02125 temp.replace_all ("::", ":"); 02126 temp.replace_all (";;", ";"); 02127 } 02128 02129 break; 02130 case CommandPathRemoveRegexp : 02131 02132 if (new_value != "") 02133 { 02134 cmt_regexp e (new_value); 02135 02136 CmtSystem::cmt_string_vector paths; 02137 02138 CmtSystem::split (temp, path_separator, paths); 02139 02140 for (int j = 0; j < paths.size (); ++j) 02141 { 02142 cmt_string& s = paths[j]; 02143 02144 if (CmtSystem::getenv ("TESTPRR") != "") 02145 { 02146 cout << "PRR> s=[" << s << "]"; 02147 } 02148 02149 if (e.match (s)) 02150 { 02151 s = ""; 02152 02153 if (CmtSystem::getenv ("TESTPRR") != "") 02154 { 02155 cout << " match "; 02156 } 02157 } 02158 else 02159 { 02160 if (CmtSystem::getenv ("TESTPRR") != "") 02161 { 02162 cout << " no match "; 02163 } 02164 } 02165 02166 if (CmtSystem::getenv ("TESTPRR") != "") 02167 { 02168 cout << endl; 02169 } 02170 } 02171 02172 Cmt::vector_to_string (paths, path_separator, temp); 02173 temp.replace_all ("::", ":"); 02174 temp.replace_all (";;", ";"); 02175 } 02176 02177 break; 02178 } 02179 02180 } 02181 02182 level--; 02183 02184 return (temp); 02185 } |
|
Implements ValueBuilder. Definition at line 2188 of file cmt_symbol.cxx. References CmtSystem::cmt_string_vector, SymbolValueList::command_type, CommandPath, CommandPathAppend, CommandPathPrepend, CommandPathRemove, CommandPathRemoveRegexp, Use::discarded, SymbolValueList::discarded, cmt_string::find(), CmtSystem::getenv(), cmt_regexp::match(), Symbol::name, CmtSystem::path_separator(), cmt_string::replace_all(), resolve_value(), resolve_value_for_macros(), SymbolValueList::select_first(), cmt_vector< T >::size(), CmtSystem::split(), SymbolValue::text, SymbolValueList::use, Symbol::value_lists, SymbolValueList::values, and Cmt::vector_to_string().
02190 { 02191 // Control of recursivity 02192 static int level = 0; 02193 02194 cmt_string temp; 02195 cmt_string new_value; 02196 static const cmt_string empty; 02197 02198 static cmt_string path_separator = CmtSystem::path_separator (); 02199 02200 temp = CmtSystem::getenv (symbol.name); 02201 02202 //cerr << "#####1 temp=" << temp << endl; 02203 02204 for (int i = 0; i < symbol.value_lists.size (); i++) 02205 { 02206 const SymbolValueList& value_list = symbol.value_lists[i]; 02207 02208 if (value_list.discarded) continue; 02209 02210 if ((value_list.use != 0) && 02211 (value_list.use->discarded)) continue; 02212 02213 const int selected = value_list.select_first (); 02214 02215 if (selected < 0) continue; 02216 02217 SymbolValue& value = value_list.values[selected]; 02218 02219 new_value = value.text; 02220 02221 //resolve_value (new_value); 02222 02223 //cerr << "#####1 new_value=" << new_value << endl; 02224 02225 resolve_value_for_macros (new_value); 02226 resolve_value (new_value); 02227 02228 //cerr << "#####2 new_value=" << new_value << endl; 02229 02230 switch (value_list.command_type) 02231 { 02232 case CommandPath : 02233 02234 temp = ""; 02235 02236 break; 02237 case CommandPathAppend : 02238 case CommandPathPrepend : 02239 case CommandPathRemove : 02240 02241 if (new_value != "") 02242 { 02243 CmtSystem::cmt_string_vector paths; 02244 02245 CmtSystem::split (temp, path_separator, paths); 02246 02247 for (int j = 0; j < paths.size (); ++j) 02248 { 02249 cmt_string& s = paths[j]; 02250 02251 if (s.find (new_value) != cmt_string::npos) 02252 { 02253 s = ""; 02254 } 02255 02256 if (j > 0) 02257 { 02258 cmt_string& s2 = paths[j-1]; 02259 if (s2 == s) 02260 { 02261 s2 = ""; 02262 } 02263 } 02264 } 02265 02266 Cmt::vector_to_string (paths, path_separator, temp); 02267 temp.replace_all ("::", ":"); 02268 temp.replace_all (";;", ";"); 02269 } 02270 02271 break; 02272 case CommandPathRemoveRegexp : 02273 02274 if (new_value != "") 02275 { 02276 cmt_regexp e (new_value); 02277 02278 CmtSystem::cmt_string_vector paths; 02279 02280 CmtSystem::split (temp, path_separator, paths); 02281 02282 for (int j = 0; j < paths.size (); ++j) 02283 { 02284 cmt_string& s = paths[j]; 02285 02286 if (e.match (s)) 02287 { 02288 s = ""; 02289 } 02290 02291 if (j > 0) 02292 { 02293 cmt_string& s2 = paths[j-1]; 02294 if (s2 == s) 02295 { 02296 s2 = ""; 02297 } 02298 } 02299 } 02300 02301 Cmt::vector_to_string (paths, path_separator, temp); 02302 temp.replace_all ("::", ":"); 02303 temp.replace_all (";;", ";"); 02304 } 02305 02306 break; 02307 } 02308 } 02309 02310 //cerr << "#####2 temp=" << temp << endl; 02311 02312 return (temp); 02313 } |