#include <cmt_fragment.h>
Collaboration diagram for Fragment:
Public Types | |
typedef cmt_vector<Fragment> | FragmentVector |
Public Methods | |
Fragment () | |
Fragment (const cmt_string& fragment_name) | |
~Fragment () | |
void | clear () |
int | print () |
bool | locate () |
bool | copy (FILE* out, int variables, ...) |
bool | copy (cmt_string& out, int variables, ...) |
bool | copy (FILE* out, int variables, va_list ids) |
bool | copy (cmt_string& out, int variables, va_list ids) |
bool | wincopy (FILE* out, int variables, va_list ids) |
bool | wincopy (cmt_string& out, int variables, va_list ids) |
bool | copy (FILE* out, const Variable::VariableVector& vector, int variables, ...) |
bool | copy (cmt_string& out, const Variable::VariableVector& vector, int variables, ...) |
bool | copy (FILE* out, const Variable::VariableVector& vector, int variables, va_list ids) |
bool | copy (cmt_string& out, const Variable::VariableVector& vector, int variables, va_list ids) |
bool | wincopy (FILE* out, const Variable::VariableVector& vector, int variables, va_list ids) |
bool | wincopy (cmt_string& out, const Variable::VariableVector& vector, int variables, va_list ids) |
Public Attributes | |
cmt_string | name |
cmt_string | suffix |
cmt_string | header |
cmt_string | trailer |
bool | need_dependencies |
cmt_string | path |
UseRef | use |
Static Public Methods | |
void | action (const CmtSystem::cmt_string_vector& words, Use* use) |
Fragment* | find (const cmt_string& name) |
void | add (const cmt_string& name, const cmt_string& suffix, const cmt_string& header, const cmt_string& trailer, bool need_dependencies, Use* use) |
void | show (const cmt_string& name) |
void | show_all () |
void | clear_all () |
bool | copy (FILE* out, const cmt_string& name, int variables, ...) |
bool | copy (cmt_string& out, const cmt_string& name, int variables, ...) |
bool | copy (FILE* out, const cmt_string& name, const Variable::VariableVector& vector, int variables, ...) |
bool | copy (cmt_string& out, const cmt_string& name, const Variable::VariableVector& vector, int variables, ...) |
FragmentVector& | fragments () |
|
Definition at line 47 of file cmt_fragment.h. |
|
Definition at line 307 of file cmt_fragment.cxx. 00308 { 00309 use = 0; 00310 } |
|
Definition at line 313 of file cmt_fragment.cxx. 00314 { 00315 name = fragment_name; 00316 use = 0; 00317 path = ""; 00318 } |
|
Definition at line 321 of file cmt_fragment.cxx. 00322 { 00323 use = 0; 00324 } |
|
Definition at line 158 of file cmt_fragment.cxx. Referenced by Cmt::select(). 00160 { 00161 if (words.size () > 1) 00162 { 00163 cmt_string suffix; 00164 cmt_string header; 00165 cmt_string trailer; 00166 bool need_dependencies = false; 00167 00168 cmt_string name = words[1]; 00169 00170 for (int i = 2; i < words.size (); i++) 00171 { 00172 const cmt_string& word = words[i]; 00173 00174 if (word.find ("-suffix=") != cmt_string::npos) 00175 { 00176 suffix = word; 00177 suffix.replace ("-suffix=", ""); 00178 } 00179 else if (word.find ("-dependencies") != cmt_string::npos) 00180 { 00181 need_dependencies = true; 00182 } 00183 else if (word.find ("-header=") != cmt_string::npos) 00184 { 00185 header = word; 00186 header.replace ("-header=", ""); 00187 00188 if (find (header) == 0) 00189 { 00190 add (header, "", "", "", false, use); 00191 } 00192 } 00193 else if (word.find ("-trailer=") != cmt_string::npos) 00194 { 00195 trailer = word; 00196 trailer.replace ("-trailer=", ""); 00197 00198 if (find (trailer) == 0) 00199 { 00200 add (trailer, "", "", "", false, use); 00201 } 00202 } 00203 } 00204 00205 add (name, suffix, header, trailer, need_dependencies, use); 00206 } 00207 } |
|
Definition at line 234 of file cmt_fragment.cxx. Referenced by action(). 00240 { 00241 static FragmentVector& Fragments = fragments (); 00242 00243 { 00244 Fragment* fragment; 00245 00246 if (name == "") return; 00247 00248 fragment = find (name); 00249 if (fragment != 0) 00250 { 00251 if (suffix != "") 00252 { 00253 fragment->suffix = suffix; 00254 } 00255 00256 if (header != "") 00257 { 00258 fragment->header = header; 00259 } 00260 00261 if (trailer != "") 00262 { 00263 fragment->trailer = trailer; 00264 } 00265 00266 fragment->need_dependencies = need_dependencies; 00267 00268 fragment->use = use; 00269 return; 00270 } 00271 } 00272 00273 Fragment& fragment = Fragments.add (); 00274 00275 fragment.name = name; 00276 fragment.suffix = suffix; 00277 fragment.header = header; 00278 fragment.trailer = trailer; 00279 fragment.need_dependencies = need_dependencies; 00280 fragment.use = use; 00281 } |
|
Definition at line 327 of file cmt_fragment.cxx. Referenced by clear_all(). 00328 { 00329 name = ""; 00330 suffix = ""; 00331 header = ""; 00332 trailer = ""; 00333 need_dependencies = false; 00334 path = ""; 00335 use = 0; 00336 } |
|
Definition at line 284 of file cmt_fragment.cxx. Referenced by Database::clear(). |
|
Definition at line 791 of file cmt_fragment.cxx. 00792 { 00793 int i; 00794 00795 if (!locate ()) return (false); 00796 00797 out.read (path); 00798 00799 Variable* var = 0; 00800 00801 for (i = 0; i < vector.size (); i++) 00802 { 00803 var = &(vector[i]); 00804 out.replace_all (var->macro_braces (), var->value); 00805 out.replace_all (var->macro_pars (), var->value); 00806 } 00807 00808 for (i = 0; i < variables; i++) 00809 { 00810 var = va_arg (ids, Variable*); 00811 out.replace_all (var->macro_braces (), var->value); 00812 out.replace_all (var->macro_pars (), var->value); 00813 } 00814 00815 return (true); 00816 } |
|
Definition at line 774 of file cmt_fragment.cxx. 00775 { 00776 static cmt_string cline; 00777 00778 bool result = copy (cline, vector, variables, ids); 00779 if (result) 00780 { 00781 cline.write (out); 00782 return (true); 00783 } 00784 else 00785 { 00786 return (false); 00787 } 00788 } |
|
Definition at line 762 of file cmt_fragment.cxx. 00763 { 00764 va_list ids; 00765 00766 va_start (ids, variables); 00767 bool result = copy (out, vector, variables, ids); 00768 va_end (ids); 00769 00770 return (result); 00771 } |
|
Definition at line 750 of file cmt_fragment.cxx. 00751 { 00752 va_list ids; 00753 00754 va_start (ids, variables); 00755 bool result = copy (out, vector, variables, ids); 00756 va_end (ids); 00757 00758 return (result); 00759 } |
|
Definition at line 543 of file cmt_fragment.cxx. 00544 { 00545 int i; 00546 00547 if (!locate ()) return (false); 00548 00549 out.read (path); 00550 00551 Variable* var = 0; 00552 for (i = 0; i < variables; i++) 00553 { 00554 var = va_arg (ids, Variable*); 00555 out.replace_all (var->macro_braces (), var->value); 00556 out.replace_all (var->macro_pars (), var->value); 00557 } 00558 00559 return (true); 00560 } |
|
Definition at line 526 of file cmt_fragment.cxx. 00527 { 00528 static cmt_string cline; 00529 00530 bool result = copy (cline, variables, ids); 00531 if (result) 00532 { 00533 cline.write (out); 00534 return (true); 00535 } 00536 else 00537 { 00538 return (false); 00539 } 00540 } |
|
Definition at line 514 of file cmt_fragment.cxx. 00515 { 00516 va_list ids; 00517 00518 va_start (ids, variables); 00519 bool result = copy (out, variables, ids); 00520 va_end (ids); 00521 00522 return (result); 00523 } |
|
Definition at line 502 of file cmt_fragment.cxx. 00503 { 00504 va_list ids; 00505 00506 va_start (ids, variables); 00507 bool result = copy (out, variables, ids); 00508 va_end (ids); 00509 00510 return (result); 00511 } |
|
Definition at line 732 of file cmt_fragment.cxx. 00736 { 00737 va_list ids; 00738 00739 Fragment* fragment = Fragment::find (name); 00740 if (fragment == 0) return (false); 00741 00742 va_start (ids, variables); 00743 bool result = fragment->copy (out, vector, variables, ids); 00744 va_end (ids); 00745 00746 return (result); 00747 } |
|
Definition at line 714 of file cmt_fragment.cxx. 00718 { 00719 va_list ids; 00720 00721 Fragment* fragment = Fragment::find (name); 00722 if (fragment == 0) return (false); 00723 00724 va_start (ids, variables); 00725 bool result = fragment->copy (out, vector, variables, ids); 00726 va_end (ids); 00727 00728 return (result); 00729 } |
|
Definition at line 485 of file cmt_fragment.cxx. 00488 { 00489 va_list ids; 00490 00491 Fragment* fragment = Fragment::find (name); 00492 if (fragment == 0) return (false); 00493 00494 va_start (ids, variables); 00495 bool result = fragment->copy (out, variables, ids); 00496 va_end (ids); 00497 00498 return (result); 00499 } |
|
Definition at line 468 of file cmt_fragment.cxx. Referenced by FragmentHandle::copy(), and copy(). 00471 { 00472 va_list ids; 00473 00474 Fragment* fragment = Fragment::find (name); 00475 if (fragment == 0) return (false); 00476 00477 va_start (ids, variables); 00478 bool result = fragment->copy (out, variables, ids); 00479 va_end (ids); 00480 00481 return (result); 00482 } |
|
Definition at line 210 of file cmt_fragment.cxx. Referenced by action(), add(), copy(), FragmentHandle::setup(), and show(). 00211 { 00212 static FragmentVector& Fragments = fragments (); 00213 00214 int fragment_index; 00215 00216 if (Fragments.size () == 0) return (0); 00217 00218 for (fragment_index = 0; 00219 fragment_index < Fragments.size (); 00220 fragment_index++) 00221 { 00222 Fragment& fragment = Fragments[fragment_index]; 00223 00224 if (fragment.name == name) 00225 { 00226 return (&fragment); 00227 } 00228 } 00229 00230 return (0); 00231 } |
|
Definition at line 298 of file cmt_fragment.cxx. Referenced by add(), clear_all(), find(), and show_all(). 00299 { 00300 static Database& db = Database::instance (); 00301 static FragmentVector& Fragments = db.fragments (); 00302 00303 return (Fragments); 00304 } |
|
Definition at line 380 of file cmt_fragment.cxx. Referenced by copy(), print(), and wincopy(). 00381 { 00382 if (path == "") 00383 { 00384 if (use == 0) 00385 { 00386 // Assume CMT 00387 use = Use::find ("CMT"); 00388 } 00389 00390 path = use->real_path; 00391 path += CmtSystem::file_separator (); 00392 path += use->package; 00393 path += CmtSystem::file_separator (); 00394 path += use->version; 00395 path += CmtSystem::file_separator (); 00396 path += "fragments"; 00397 path += CmtSystem::file_separator (); 00398 00399 if (Cmt::build_nmake ()) 00400 { 00401 path += "nmake"; 00402 path += CmtSystem::file_separator (); 00403 } 00404 00405 path += name; 00406 } 00407 00408 if (CmtSystem::test_file (path)) return (true); 00409 00410 path = use->real_path; 00411 path += CmtSystem::file_separator (); 00412 path += use->package; 00413 path += CmtSystem::file_separator (); 00414 path += use->version; 00415 path += CmtSystem::file_separator (); 00416 path += "fragments"; 00417 path += CmtSystem::file_separator (); 00418 path += name; 00419 00420 if (CmtSystem::test_file (path)) return (true); 00421 00422 path = use->real_path; 00423 path += CmtSystem::file_separator (); 00424 path += use->package; 00425 path += CmtSystem::file_separator (); 00426 path += use->version; 00427 path += CmtSystem::file_separator (); 00428 00429 if (use->style == mgr_style) path += "mgr"; 00430 else path += "cmt"; 00431 00432 path += CmtSystem::file_separator (); 00433 path += "fragments"; 00434 path += CmtSystem::file_separator (); 00435 00436 if (Cmt::build_nmake ()) 00437 { 00438 path += "nmake"; 00439 path += CmtSystem::file_separator (); 00440 } 00441 00442 path += name; 00443 00444 if (CmtSystem::test_file (path)) return (true); 00445 00446 path = use->real_path; 00447 path += CmtSystem::file_separator (); 00448 path += use->package; 00449 path += CmtSystem::file_separator (); 00450 path += use->version; 00451 path += CmtSystem::file_separator (); 00452 00453 if (use->style == mgr_style) path += "mgr"; 00454 else path += "cmt"; 00455 00456 path += CmtSystem::file_separator (); 00457 path += "fragments"; 00458 path += CmtSystem::file_separator (); 00459 00460 path += name; 00461 00462 if (CmtSystem::test_file (path)) return (true); 00463 00464 return (false); 00465 } |
|
Definition at line 339 of file cmt_fragment.cxx. Referenced by show(), and show_all(). 00340 { 00341 int result = 1; 00342 00343 if (name == "") return (0); 00344 00345 locate (); 00346 00347 if (use == 0) 00348 { 00349 Use& u = Use::current(); 00350 use = &u; 00351 } 00352 00353 cmt_string the_path = path; 00354 00355 cmt_string pattern = use->real_path; 00356 pattern += CmtSystem::file_separator (); 00357 pattern += use->package; 00358 pattern += CmtSystem::file_separator (); 00359 pattern += use->version; 00360 00361 cmt_string replacement = "${"; 00362 replacement += use->prefix; 00363 replacement += "ROOT}"; 00364 00365 the_path.replace (pattern, replacement); 00366 00367 cout << the_path; 00368 00369 if (suffix != "") 00370 { 00371 cout << "->" << suffix; 00372 } 00373 00374 cout << endl; 00375 00376 return (result); 00377 } |
|
Definition at line 129 of file cmt_fragment.cxx. Referenced by Cmt::do_show_fragment(). 00130 { 00131 Fragment* fragment = Fragment::find (name); 00132 if (fragment == 0) 00133 { 00134 cout << "Fragment " << name << " not found" << endl; 00135 } 00136 else 00137 { 00138 fragment->print (); 00139 } 00140 } |
|
Definition at line 143 of file cmt_fragment.cxx. Referenced by Cmt::do_show_fragments(). 00144 { 00145 static FragmentVector& Fragments = fragments (); 00146 00147 int number; 00148 00149 for (number = 0; number < Fragments.size (); number++) 00150 { 00151 Fragment& fragment = Fragments[number]; 00152 00153 fragment.print (); 00154 } 00155 } |
|
Definition at line 836 of file cmt_fragment.cxx. 00838 { 00839 int i; 00840 00841 if (!locate ()) return (false); 00842 00843 out.read (path); 00844 00845 Variable* var = 0; 00846 00847 for (i = 0; i < vector.size (); i++) 00848 { 00849 var = &(vector[i]); 00850 out.replace_all (var->macro_braces (), var->value); 00851 out.replace_all (var->macro_pars (), var->value); 00852 } 00853 00854 for (i = 0; i < variables; i++) 00855 { 00856 var = va_arg (ids, Variable*); 00857 out.replace_all (var->macro_braces (), var->value); 00858 out.replace_all (var->macro_pars (), var->value); 00859 } 00860 00861 cmt_string pattern; 00862 cmt_string macro_name; 00863 char end_pattern; 00864 00865 int start = 0; 00866 00867 for (;;) 00868 { 00869 // 00870 // Try and substitute all ${xxx} or $(xxx) patterns 00871 // using symbol values. 00872 // 00873 int par; 00874 int brace; 00875 int begin; 00876 00877 par = out.find (start, "$("); 00878 brace = out.find (start, "${"); 00879 00880 if (par == cmt_string::npos) 00881 { 00882 // No parentheses. Look for brace 00883 if (brace == cmt_string::npos) 00884 { 00885 // No pattern, finish the scan. 00886 break; 00887 } 00888 00889 // Brace found 00890 end_pattern = '}'; 00891 begin = brace; 00892 } 00893 else 00894 { 00895 // Parenthese found. Look for closest from {par, brace} 00896 if ((brace == cmt_string::npos) || 00897 (brace > par)) 00898 { 00899 end_pattern = ')'; 00900 begin = par; 00901 } 00902 else 00903 { 00904 end_pattern = '}'; 00905 begin = brace; 00906 } 00907 } 00908 00909 // Skip the pattern intro. 00910 start = begin + 2; 00911 00912 int end; 00913 end = out.find (start, end_pattern); 00914 if (end == cmt_string::npos) 00915 { 00916 // The pattern is a fake one (no ending!) 00917 break; 00918 } 00919 00920 // This should never happen... 00921 if (end < begin) break; 00922 00923 // Extract the complete pattern 00924 out.substr (begin, end - begin + 1, pattern); 00925 00926 // Then only the macro name 00927 out.substr (begin + 2, end - begin - 2, macro_name); 00928 00929 if (macro_name == "CFG") 00930 { 00931 // This is a Windows reserved keyword... 00932 start = end + 1; 00933 } 00934 else 00935 { 00936 Symbol* macro = Symbol::find (macro_name); 00937 if (macro != 0) 00938 { 00939 // Macro found 00940 cmt_string value = macro->resolve_macro_value (); 00941 //cout << "resolve_macro_value2> value=" << value << endl; 00942 out.replace_all (pattern, value); 00943 00944 // The substitution will restart from the same place 00945 // allowing for recursive replacements 00946 start = begin; 00947 } 00948 else 00949 { 00950 // Macro not found. Look for env. variable 00951 cmt_string value = CmtSystem::getenv (macro_name); 00952 //cout << "resolve_macro_value3> " << macro_name << "=" << value << endl; 00953 out.replace_all (pattern, value); 00954 00955 // The substitution will restart from the same place 00956 // allowing for recursive replacements 00957 start = begin; 00958 } 00959 } 00960 } 00961 00962 // Uniformly install CR-LF doublets. 00963 00964 out.replace_all ("\r\n", "\n"); 00965 out.replace_all ("\n", "\r\n"); 00966 00967 return (true); 00968 } |
|
Definition at line 819 of file cmt_fragment.cxx. 00820 { 00821 static cmt_string cline; 00822 00823 bool result = wincopy (cline, vector, variables, ids); 00824 if (result) 00825 { 00826 cline.write (out); 00827 return (true); 00828 } 00829 else 00830 { 00831 return (false); 00832 } 00833 } |
|
Definition at line 581 of file cmt_fragment.cxx. 00582 { 00583 int i; 00584 00585 if (!locate ()) return (false); 00586 00587 out.read (path); 00588 00589 Variable* var = 0; 00590 for (i = 0; i < variables; i++) 00591 { 00592 var = va_arg (ids, Variable*); 00593 out.replace_all (var->macro_braces (), var->value); 00594 out.replace_all (var->macro_pars (), var->value); 00595 } 00596 00597 cmt_string pattern; 00598 cmt_string macro_name; 00599 char end_pattern; 00600 00601 int start = 0; 00602 00603 for (;;) 00604 { 00605 // 00606 // Try and substitute all ${xxx} or $(xxx) patterns 00607 // using symbol values. 00608 // 00609 int par; 00610 int brace; 00611 int begin; 00612 00613 par = out.find (start, "$("); 00614 brace = out.find (start, "${"); 00615 00616 if (par == cmt_string::npos) 00617 { 00618 // No parentheses. Look for brace 00619 if (brace == cmt_string::npos) 00620 { 00621 // No pattern, finish the scan. 00622 break; 00623 } 00624 00625 // Brace found 00626 end_pattern = '}'; 00627 begin = brace; 00628 } 00629 else 00630 { 00631 // Parenthese found. Look for closest from {par, brace} 00632 if ((brace == cmt_string::npos) || 00633 (brace > par)) 00634 { 00635 end_pattern = ')'; 00636 begin = par; 00637 } 00638 else 00639 { 00640 end_pattern = '}'; 00641 begin = brace; 00642 } 00643 } 00644 00645 // Skip the pattern intro. 00646 start = begin + 2; 00647 00648 int end; 00649 end = out.find (start, end_pattern); 00650 if (end == cmt_string::npos) 00651 { 00652 // The pattern is a fake one (no ending!) 00653 break; 00654 } 00655 00656 // This should never happen... 00657 if (end < begin) break; 00658 00659 // Extract the complete pattern 00660 out.substr (begin, end - begin + 1, pattern); 00661 00662 // Then only the macro name 00663 out.substr (begin + 2, end - begin - 2, macro_name); 00664 00665 if (macro_name == "CFG") 00666 { 00667 // This is a Windows reserved keyword... 00668 start = end + 1; 00669 } 00670 else 00671 { 00672 Symbol* macro = Symbol::find (macro_name); 00673 if (macro != 0) 00674 { 00675 // Macro found 00676 cmt_string value = macro->resolve_macro_value (); 00677 //cout << "resolve_macro_value2> value=" << value << endl; 00678 out.replace_all (pattern, value); 00679 00680 // The substitution will restart from the same place 00681 // allowing for recursive replacements 00682 start = begin; 00683 } 00684 else 00685 { 00686 // Macro not found. Look for env. variable 00687 cmt_string value = CmtSystem::getenv (macro_name); 00688 //cout << "resolve_macro_value3> " << macro_name << "=" << value << endl; 00689 out.replace_all (pattern, value); 00690 00691 // The substitution will restart from the same place 00692 // allowing for recursive replacements 00693 start = begin; 00694 } 00695 } 00696 } 00697 00698 // Uniformly install CR-LF doublets. 00699 00700 out.replace_all ("\r\n", "\n"); 00701 out.replace_all ("\n", "\r\n"); 00702 00703 return (true); 00704 } |
|
Definition at line 563 of file cmt_fragment.cxx. Referenced by FragmentHandle::wincopy(), and wincopy(). 00564 { 00565 static cmt_string cline; 00566 00567 bool result = wincopy (cline, variables, ids); 00568 00569 if (result) 00570 { 00571 cline.write (out); 00572 return (true); 00573 } 00574 else 00575 { 00576 return (false); 00577 } 00578 } |
|
Definition at line 94 of file cmt_fragment.h. |
|
Definition at line 92 of file cmt_fragment.h. |
|
Definition at line 96 of file cmt_fragment.h. |
|
Definition at line 97 of file cmt_fragment.h. |
|
Definition at line 93 of file cmt_fragment.h. |
|
Definition at line 95 of file cmt_fragment.h. |
|
Definition at line 98 of file cmt_fragment.h. |