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

Fragment Class Reference

#include <cmt_fragment.h>

Collaboration diagram for Fragment:

[legend]
List of all members.

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)

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 ()

Public Attributes

cmt_string? name
cmt_string? suffix
cmt_string? header
cmt_string? trailer
bool? need_dependencies
cmt_string? path
UseRef? use

Member Typedef Documentation

typedef cmt_vector Fragment::FragmentVector
?

Definition at line 53 of file cmt_fragment.h.


Constructor & Destructor Documentation

Fragment::Fragment (? ? )?
?

Definition at line 373 of file cmt_fragment.cxx.

References use.

00374 {
00375   use = 0;
00376 }

Fragment::Fragment (? const cmt_string &? ? fragment_name )?
?

Definition at line 379 of file cmt_fragment.cxx.

References name, path, and use.

00380 {
00381   name = fragment_name;
00382   use = 0;
00383   path = "";
00384 }

Fragment::~Fragment (? ? )?
?

Definition at line 387 of file cmt_fragment.cxx.

References use.

00388 {
00389   use = 0;
00390 }

Member Function Documentation

void Fragment::action (? const CmtSystem::cmt_string_vector &? ? words,
Use *? ? use
)? [static]
?

Definition at line 238 of file cmt_fragment.cxx.

References fragment_action_iterator::add_word(), fragment_action_iterator::commit(), Symbol::expand(), Cmt::get_current_access(), Use::get_current_scope(), ScopePrivate, cmt_vector< cmt_string >::size(), CmtSystem::split(), and UserMode.

Referenced by KwdMakeFragment::action().

00240 {
00241   if ((Cmt::get_current_access () == UserMode) &&
00242       (use->get_current_scope () == ScopePrivate)) return;
00243 
00244   if (words.size () <= 1) return;
00245 
00246   fragment_action_iterator it (use);
00247 
00248   for (int i = 1; i < words.size (); i++)
00249     {
00250       const cmt_string& w = words[i];
00251       cmt_string ew = w;
00252 
00253       Symbol::expand (ew);
00254       if (ew != w)
00255         {
00256           CmtSystem::cmt_string_vector ws;
00257 
00258           CmtSystem::split (ew, " ", ws);
00259 
00260           for (int j = 0; j < ws.size (); ++j)
00261             {
00262               const cmt_string& ww = ws[j];
00263               it.add_word (ww);
00264             }
00265         }
00266       else
00267         {
00268           it.add_word (ew);
00269         }
00270     }
00271 
00272   it.commit ();
00273 }

void Fragment::add (? const cmt_string &? ? name,
const cmt_string &? ? suffix,
const cmt_string &? ? header,
const cmt_string &? ? trailer,
bool? ? need_dependencies,
Use *? ? use
)? [static]
?

Definition at line 300 of file cmt_fragment.cxx.

References cmt_vector< Fragment >::add(), find(), fragments(), header, name, need_dependencies, suffix, trailer, and use.

Referenced by fragment_action_iterator::add_word(), and fragment_action_iterator::commit().

00306 {
00307   static FragmentVector& Fragments = fragments ();
00308 
00309   {
00310     Fragment* fragment;
00311 
00312     if (name == "") return;
00313 
00314     fragment = find (name);
00315     if (fragment != 0)
00316       {
00317         if (suffix != "")
00318           {
00319             fragment->suffix = suffix;
00320           }
00321 
00322         if (header != "")
00323           {
00324             fragment->header = header;
00325           }
00326 
00327         if (trailer != "")
00328           {
00329             fragment->trailer = trailer;
00330           }
00331 
00332         fragment->need_dependencies = need_dependencies;
00333 
00334         fragment->use = use;
00335         return;
00336       }
00337   }
00338 
00339   Fragment& fragment = Fragments.add ();
00340 
00341   fragment.name              = name;
00342   fragment.suffix            = suffix;
00343   fragment.header            = header;
00344   fragment.trailer           = trailer;
00345   fragment.need_dependencies = need_dependencies;
00346   fragment.use               = use;
00347 }

void Fragment::clear (? ? )?
?

Definition at line 393 of file cmt_fragment.cxx.

References header, name, need_dependencies, path, suffix, trailer, and use.

Referenced by clear_all().

00394 {
00395   name    = "";
00396   suffix  = "";
00397   header  = "";
00398   trailer = "";
00399   need_dependencies = false;
00400   path = "";
00401   use  = 0;
00402 }

void Fragment::clear_all (? ? )? [static]
?

Definition at line 350 of file cmt_fragment.cxx.

References cmt_vector< Fragment >::clear(), clear(), fragments(), and cmt_vector< Fragment >::size().

Referenced by Database::clear().

00351 {
00352   static FragmentVector& Fragments = fragments ();
00353 
00354   for (int i = 0; i < Fragments.size (); i++)
00355     {
00356       Fragment& f = Fragments[i];
00357       f.clear ();
00358     }
00359 
00360   Fragments.clear ();
00361 }

bool Fragment::copy (? cmt_string &? ? out,
const Variable::VariableVector &? ? vector,
int? ? variables,
va_list? ? ids
)?
?

Definition at line 835 of file cmt_fragment.cxx.

References locate(), Variable::macro_braces(), Variable::macro_pars(), path, cmt_string::read(), cmt_string::replace_all(), cmt_vector< Variable >::size(), and Variable::value.

00836 {
00837   int i;
00838 
00839   if (!locate ()) return (false);
00840 
00841   out.read (path);
00842 
00843   Variable* var = 0;
00844 
00845   for (i = 0; i < vector.size (); i++)
00846     {
00847       var = &(vector[i]);
00848       out.replace_all (var->macro_braces (), var->value);
00849       out.replace_all (var->macro_pars (), var->value);
00850     }
00851 
00852   for (i = 0; i < variables; i++)
00853     {
00854       var = va_arg (ids, Variable*);
00855       out.replace_all (var->macro_braces (), var->value);
00856       out.replace_all (var->macro_pars (), var->value);
00857     }
00858 
00859   return (true);
00860 }

bool Fragment::copy (? FILE *? ? out,
const Variable::VariableVector &? ? vector,
int? ? variables,
va_list? ? ids
)?
?

Definition at line 818 of file cmt_fragment.cxx.

References copy(), and cmt_string::write().

00819 {
00820   static cmt_string cline;
00821 
00822   bool result = copy (cline, vector, variables, ids);
00823   if (result)
00824     {
00825       cline.write (out);
00826       return (true);
00827     }
00828   else
00829     {
00830       return (false);
00831     }
00832 }

bool Fragment::copy (? cmt_string &? ? out,
const Variable::VariableVector &? ? vector,
int? ? variables,
...? ?
)?
?

Definition at line 806 of file cmt_fragment.cxx.

References copy().

00807 {
00808   va_list ids;
00809 
00810   va_start (ids, variables);
00811   bool result = copy (out, vector, variables, ids);
00812   va_end (ids);
00813 
00814   return (result);
00815 }

bool Fragment::copy (? FILE *? ? out,
const Variable::VariableVector &? ? vector,
int? ? variables,
...? ?
)?
?

Definition at line 794 of file cmt_fragment.cxx.

References copy().

00795 {
00796   va_list ids;
00797 
00798   va_start (ids, variables);
00799   bool result = copy (out, vector, variables, ids);
00800   va_end (ids);
00801 
00802   return (result);
00803 }

bool Fragment::copy (? cmt_string &? ? out,
int? ? variables,
va_list? ? ids
)?
?

Definition at line 587 of file cmt_fragment.cxx.

References locate(), Variable::macro_braces(), Variable::macro_pars(), path, cmt_string::read(), cmt_string::replace_all(), and Variable::value.

00588 {
00589   int i;
00590 
00591   if (!locate ()) return (false);
00592 
00593   out.read (path);
00594 
00595   Variable* var = 0;
00596   for (i = 0; i < variables; i++)
00597     {
00598       var = va_arg (ids, Variable*);
00599       out.replace_all (var->macro_braces (), var->value);
00600       out.replace_all (var->macro_pars (), var->value);
00601     }
00602 
00603   return (true);
00604 }

bool Fragment::copy (? FILE *? ? out,
int? ? variables,
va_list? ? ids
)?
?

Definition at line 570 of file cmt_fragment.cxx.

References copy(), and cmt_string::write().

00571 {
00572   static cmt_string cline;
00573 
00574   bool result = copy (cline, variables, ids);
00575   if (result)
00576     {
00577       cline.write (out);
00578       return (true);
00579     }
00580   else
00581     {
00582       return (false);
00583     }
00584 }

bool Fragment::copy (? cmt_string &? ? out,
int? ? variables,
...? ?
)?
?

Definition at line 558 of file cmt_fragment.cxx.

References copy().

00559 {
00560   va_list ids;
00561 
00562   va_start (ids, variables);
00563   bool result = copy (out, variables, ids);
00564   va_end (ids);
00565 
00566   return (result);
00567 }

bool Fragment::copy (? FILE *? ? out,
int? ? variables,
...? ?
)?
?

Definition at line 546 of file cmt_fragment.cxx.

References copy().

00547 {
00548   va_list ids;
00549 
00550   va_start (ids, variables);
00551   bool result = copy (out, variables, ids);
00552   va_end (ids);
00553 
00554   return (result);
00555 }

bool Fragment::copy (? cmt_string &? ? out,
const cmt_string &? ? name,
const Variable::VariableVector &? ? vector,
int? ? variables,
...? ?
)? [static]
?

Definition at line 776 of file cmt_fragment.cxx.

References copy(), and find().

00780 {
00781   va_list ids;
00782 
00783   Fragment* fragment = Fragment::find (name);
00784   if (fragment == 0) return (false);
00785 
00786   va_start (ids, variables);
00787   bool result = fragment->copy (out, vector, variables, ids);
00788   va_end (ids);
00789 
00790   return (result);
00791 }

bool Fragment::copy (? FILE *? ? out,
const cmt_string &? ? name,
const Variable::VariableVector &? ? vector,
int? ? variables,
...? ?
)? [static]
?

Definition at line 758 of file cmt_fragment.cxx.

References copy(), and find().

00762 {
00763   va_list ids;
00764 
00765   Fragment* fragment = Fragment::find (name);
00766   if (fragment == 0) return (false);
00767 
00768   va_start (ids, variables);
00769   bool result = fragment->copy (out, vector, variables, ids);
00770   va_end (ids);
00771 
00772   return (result);
00773 }

bool Fragment::copy (? cmt_string &? ? out,
const cmt_string &? ? name,
int? ? variables,
...? ?
)? [static]
?

Definition at line 529 of file cmt_fragment.cxx.

References copy(), and find().

00532 {
00533   va_list ids;
00534 
00535   Fragment* fragment = Fragment::find (name);
00536   if (fragment == 0) return (false);
00537 
00538   va_start (ids, variables);
00539   bool result = fragment->copy (out, variables, ids);
00540   va_end (ids);
00541 
00542   return (result);
00543 }

bool Fragment::copy (? FILE *? ? out,
const cmt_string &? ? name,
int? ? variables,
...? ?
)? [static]
?

Definition at line 512 of file cmt_fragment.cxx.

References find().

Referenced by FragmentHandle::copy(), and copy().

00515 {
00516   va_list ids;
00517 
00518   Fragment* fragment = Fragment::find (name);
00519   if (fragment == 0) return (false);
00520 
00521   va_start (ids, variables);
00522   bool result = fragment->copy (out, variables, ids);
00523   va_end (ids);
00524 
00525   return (result);
00526 }

Fragment * Fragment::find (? const cmt_string &? ? name )? [static]
?

Definition at line 276 of file cmt_fragment.cxx.

References fragments(), name, and cmt_vector< Fragment >::size().

Referenced by add(), fragment_action_iterator::add_word(), copy(), FragmentHandle::setup(), and show().

00277 {
00278   static FragmentVector& Fragments = fragments ();
00279 
00280   int fragment_index;
00281 
00282   if (Fragments.size () == 0) return (0);
00283 
00284   for (fragment_index = 0;
00285        fragment_index < Fragments.size ();
00286        fragment_index++)
00287     {
00288       Fragment& fragment = Fragments[fragment_index];
00289 
00290       if (fragment.name == name)
00291         {
00292           return (&fragment);
00293         }
00294     }
00295 
00296   return (0);
00297 }

Fragment::FragmentVector & Fragment::fragments (? ? )? [static]
?

Definition at line 364 of file cmt_fragment.cxx.

References Database::fragments(), and Database::instance().

Referenced by add(), clear_all(), find(), and show_all().

00365 {
00366   static Database& db = Database::instance ();
00367   static FragmentVector& Fragments = db.fragments ();
00368 
00369   return (Fragments);
00370 }

bool Fragment::locate (? ? )?
?

Definition at line 436 of file cmt_fragment.cxx.

References Cmt::build_nmake(), CmtSystem::file_separator(), Use::find(), Use::get_full_path(), mgr_style, name, path, Use::style, CmtSystem::test_file(), and use.

Referenced by copy(), print(), and wincopy().

00437 {
00438   cmt_string root_path;
00439 
00440   if (use == 0)
00441     {
00442       // Assume CMT
00443       use = Use::find ("CMT");
00444     }
00445 
00446   use->get_full_path (root_path);
00447 
00448   if (path != "") return (true);
00449 
00450   // First try /fragments/ or /fragments/nmake/
00451 
00452   path = root_path;
00453   path += CmtSystem::file_separator ();
00454   path += "fragments";
00455   path += CmtSystem::file_separator ();
00456   
00457   if (Cmt::build_nmake ())
00458     {
00459       path += "nmake";
00460       path += CmtSystem::file_separator ();
00461     }
00462   
00463   path += name;
00464 
00465   if (CmtSystem::test_file (path)) return (true);
00466 
00467   // Then try /fragments/ for both Win and Unix
00468 
00469   path = root_path;
00470   path += CmtSystem::file_separator ();
00471   path += "fragments";
00472   path += CmtSystem::file_separator ();
00473   path += name;
00474 
00475   if (CmtSystem::test_file (path)) return (true);
00476 
00477   // Then try /cmt/fragments/ or /cmt/fragments/nmake/
00478 
00479   root_path += CmtSystem::file_separator ();
00480 
00481   if (use->style == mgr_style) root_path += "mgr";
00482   else root_path += "cmt";
00483   
00484   root_path += CmtSystem::file_separator ();
00485   root_path += "fragments";
00486   root_path += CmtSystem::file_separator ();
00487   
00488   path = root_path;
00489   
00490   if (Cmt::build_nmake ())
00491     {
00492       path += "nmake";
00493       path += CmtSystem::file_separator ();
00494     }
00495   
00496   path += name;
00497   
00498   if (CmtSystem::test_file (path)) return (true);
00499 
00500   // Then try /cmt/fragments/ for both Win and Unix
00501 
00502   path = root_path;
00503   
00504   path += name;
00505 
00506   if (CmtSystem::test_file (path)) return (true);
00507 
00508   return (false);
00509 }

int Fragment::print (? ? )?
?

Definition at line 405 of file cmt_fragment.cxx.

References Use::current(), locate(), name, path, Use::reduce_path(), suffix, and use.

Referenced by show(), and show_all().

00406 {
00407   int result = 1;
00408 
00409   if (name == "") return (0);
00410   
00411   locate ();
00412 
00413   if (use == 0)
00414     {
00415       Use& u = Use::current();
00416       use = &u;
00417     }
00418   
00419   cmt_string the_path = path;
00420 
00421   use->reduce_path (the_path);
00422 
00423   cout << the_path;
00424 
00425   if (suffix != "")
00426     {
00427       cout << "->" << suffix;
00428     }
00429 
00430   cout << endl;
00431 
00432   return (result);
00433 }

void Fragment::show (? const cmt_string &? ? name )? [static]
?

Definition at line 134 of file cmt_fragment.cxx.

References find(), and print().

Referenced by Cmt::do_show_fragment().

00135 {
00136   Fragment* fragment = Fragment::find (name);
00137   if (fragment == 0)
00138     {
00139       cout << "Fragment " << name << " not found" << endl;
00140     }
00141   else
00142     {
00143       fragment->print ();
00144     }
00145 }

void Fragment::show_all (? ? )? [static]
?

Definition at line 148 of file cmt_fragment.cxx.

References fragments(), print(), and cmt_vector< Fragment >::size().

Referenced by Cmt::do_show_fragments().

00149 {
00150   static FragmentVector& Fragments = fragments ();
00151 
00152   int number;
00153 
00154   for (number = 0; number < Fragments.size (); number++)
00155     {
00156       Fragment& fragment = Fragments[number];
00157 
00158       fragment.print ();
00159     }
00160 }

bool Fragment::wincopy (? cmt_string &? ? out,
const Variable::VariableVector &? ? vector,
int? ? variables,
va_list? ? ids
)?
?

Definition at line 880 of file cmt_fragment.cxx.

References Symbol::find(), cmt_string::find(), CmtSystem::getenv(), locate(), Variable::macro_braces(), Variable::macro_pars(), cmt_string::npos, path, cmt_string::read(), cmt_string::replace_all(), Symbol::resolve_macro_value(), cmt_vector< Variable >::size(), cmt_string::substr(), and Variable::value.

00882 {
00883   int i;
00884 
00885   if (!locate ()) return (false);
00886 
00887   out.read (path);
00888 
00889   Variable* var = 0;
00890 
00891   for (i = 0; i < vector.size (); i++)
00892     {
00893       var = &(vector[i]);
00894       out.replace_all (var->macro_braces (), var->value);
00895       out.replace_all (var->macro_pars (), var->value);
00896     }
00897 
00898   for (i = 0; i < variables; i++)
00899     {
00900       var = va_arg (ids, Variable*);
00901       out.replace_all (var->macro_braces (), var->value);
00902       out.replace_all (var->macro_pars (), var->value);
00903     }
00904 
00905   cmt_string pattern;
00906   cmt_string macro_name;
00907   char end_pattern;
00908 
00909   int start = 0;
00910 
00911   for (;;)
00912     {
00913       //
00914       // Try and substitute all ${xxx} or $(xxx) patterns
00915       // using symbol values.
00916       //
00917       int par;
00918       int brace;
00919       int begin;
00920 
00921       par = out.find (start, "$(");
00922       brace = out.find (start, "${");
00923 
00924       if (par == cmt_string::npos)
00925         {
00926           // No parentheses. Look for brace
00927           if (brace == cmt_string::npos)
00928             {
00929               // No pattern, finish the scan.
00930               break;
00931             }
00932 
00933           // Brace found
00934           end_pattern = '}';
00935           begin = brace;
00936         }
00937       else
00938         {
00939           // Parenthese found. Look for closest from {par, brace}
00940           if ((brace == cmt_string::npos) ||
00941               (brace > par))
00942             {
00943               end_pattern = ')';
00944               begin = par;
00945             }
00946           else
00947             {
00948               end_pattern = '}';
00949               begin = brace;
00950             }
00951         }
00952 
00953       // Skip the pattern intro.
00954       start = begin + 2;
00955 
00956       int end;
00957       end = out.find (start, end_pattern);
00958       if (end == cmt_string::npos)
00959         {
00960           // The pattern is a fake one (no ending!)
00961           break;
00962         }
00963 
00964       // This should never happen...
00965       if (end < begin) break;
00966 
00967       // Extract the complete pattern
00968       out.substr (begin, end - begin + 1, pattern);
00969 
00970       // Then only the macro name
00971       out.substr (begin + 2, end - begin - 2, macro_name);
00972 
00973       if (macro_name == "CFG")
00974         {
00975           // This is a Windows reserved keyword...
00976           start = end + 1;
00977         }
00978       else
00979         {
00980           Symbol* macro = Symbol::find (macro_name);
00981           if (macro != 0)
00982             {
00983               // Macro found
00984               cmt_string value = macro->resolve_macro_value ();
00985               //cout << "resolve_macro_value2> value=" << value << endl;
00986               out.replace_all (pattern, value);
00987 
00988               // The substitution will restart from the same place
00989               // allowing for recursive replacements
00990               start = begin;
00991             }
00992           else
00993             {
00994               // Macro not found. Look for env. variable
00995               cmt_string value = CmtSystem::getenv (macro_name);
00996               //cout << "resolve_macro_value3> " << macro_name << "=" << value << endl;
00997               out.replace_all (pattern, value);
00998 
00999               // The substitution will restart from the same place
01000               // allowing for recursive replacements
01001               start = begin;
01002             }
01003         }
01004     }
01005 
01006   // Uniformly install CR-LF doublets.
01007 
01008   out.replace_all ("\r\n", "\n");
01009   out.replace_all ("\n", "\r\n");
01010 
01011   return (true);
01012 }

bool Fragment::wincopy (? FILE *? ? out,
const Variable::VariableVector &? ? vector,
int? ? variables,
va_list? ? ids
)?
?

Definition at line 863 of file cmt_fragment.cxx.

References wincopy(), and cmt_string::write().

00864 {
00865   static cmt_string cline;
00866 
00867   bool result = wincopy (cline, vector, variables, ids);
00868   if (result)
00869     {
00870       cline.write (out);
00871       return (true);
00872     }
00873   else
00874     {
00875       return (false);
00876     }
00877 }

bool Fragment::wincopy (? cmt_string &? ? out,
int? ? variables,
va_list? ? ids
)?
?

Definition at line 625 of file cmt_fragment.cxx.

References Symbol::find(), cmt_string::find(), CmtSystem::getenv(), locate(), Variable::macro_braces(), Variable::macro_pars(), cmt_string::npos, path, cmt_string::read(), cmt_string::replace_all(), Symbol::resolve_macro_value(), cmt_string::substr(), and Variable::value.

00626 {
00627   int i;
00628 
00629   if (!locate ()) return (false);
00630 
00631   out.read (path);
00632 
00633   Variable* var = 0;
00634   for (i = 0; i < variables; i++)
00635     {
00636       var = va_arg (ids, Variable*);
00637       out.replace_all (var->macro_braces (), var->value);
00638       out.replace_all (var->macro_pars (), var->value);
00639     }
00640 
00641   cmt_string pattern;
00642   cmt_string macro_name;
00643   char end_pattern;
00644 
00645   int start = 0;
00646 
00647   for (;;)
00648     {
00649       //
00650       // Try and substitute all ${xxx} or $(xxx) patterns
00651       // using symbol values.
00652       //
00653       int par;
00654       int brace;
00655       int begin;
00656 
00657       par = out.find (start, "$(");
00658       brace = out.find (start, "${");
00659 
00660       if (par == cmt_string::npos)
00661         {
00662           // No parentheses. Look for brace
00663           if (brace == cmt_string::npos)
00664             {
00665               // No pattern, finish the scan.
00666               break;
00667             }
00668 
00669           // Brace found
00670           end_pattern = '}';
00671           begin = brace;
00672         }
00673       else
00674         {
00675           // Parenthese found. Look for closest from {par, brace}
00676           if ((brace == cmt_string::npos) ||
00677               (brace > par))
00678             {
00679               end_pattern = ')';
00680               begin = par;
00681             }
00682           else
00683             {
00684               end_pattern = '}';
00685               begin = brace;
00686             }
00687         }
00688 
00689       // Skip the pattern intro.
00690       start = begin + 2;
00691 
00692       int end;
00693       end = out.find (start, end_pattern);
00694       if (end == cmt_string::npos)
00695         {
00696           // The pattern is a fake one (no ending!)
00697           break;
00698         }
00699 
00700       // This should never happen...
00701       if (end < begin) break;
00702 
00703       // Extract the complete pattern
00704       out.substr (begin, end - begin + 1, pattern);
00705 
00706       // Then only the macro name
00707       out.substr (begin + 2, end - begin - 2, macro_name);
00708 
00709       if (macro_name == "CFG")
00710         {
00711           // This is a Windows reserved keyword...
00712           start = end + 1;
00713         }
00714       else
00715         {
00716           Symbol* macro = Symbol::find (macro_name);
00717           if (macro != 0)
00718             {
00719               // Macro found
00720               cmt_string value = macro->resolve_macro_value ();
00721               //cout << "resolve_macro_value2> value=" << value << endl;
00722               out.replace_all (pattern, value);
00723 
00724               // The substitution will restart from the same place
00725               // allowing for recursive replacements
00726               start = begin;
00727             }
00728           else
00729             {
00730               // Macro not found. Look for env. variable
00731               cmt_string value = CmtSystem::getenv (macro_name);
00732               //cout << "resolve_macro_value3> " << macro_name << "=" << value << endl;
00733               out.replace_all (pattern, value);
00734 
00735               // The substitution will restart from the same place
00736               // allowing for recursive replacements
00737               start = begin;
00738             }
00739         }
00740     }
00741 
00742   // Uniformly install CR-LF doublets.
00743 
00744   out.replace_all ("\r\n", "\n");
00745   out.replace_all ("\n", "\r\n");
00746 
00747   return (true);
00748 }

bool Fragment::wincopy (? FILE *? ? out,
int? ? variables,
va_list? ? ids
)?
?

Definition at line 607 of file cmt_fragment.cxx.

References cmt_string::write().

Referenced by FragmentHandle::wincopy(), and wincopy().

00608 {
00609   static cmt_string cline;
00610 
00611   bool result = wincopy (cline, variables, ids);
00612 
00613   if (result)
00614     {
00615       cline.write (out);
00616       return (true);
00617     }
00618   else
00619     {
00620       return (false);
00621     }
00622 }

Member Data Documentation

cmt_string Fragment::header
?

Definition at line 100 of file cmt_fragment.h.

Referenced by add(), clear(), and FragmentHandle::header().

cmt_string Fragment::name
?

Definition at line 98 of file cmt_fragment.h.

Referenced by add(), clear(), find(), Fragment(), locate(), FragmentHandle::name(), and print().

bool Fragment::need_dependencies
?

Definition at line 102 of file cmt_fragment.h.

Referenced by add(), clear(), and FragmentHandle::need_dependencies().

cmt_string Fragment::path
?

Definition at line 103 of file cmt_fragment.h.

Referenced by clear(), copy(), Fragment(), locate(), print(), and wincopy().

cmt_string Fragment::suffix
?

Definition at line 99 of file cmt_fragment.h.

Referenced by add(), clear(), print(), and FragmentHandle::suffix().

cmt_string Fragment::trailer
?

Definition at line 101 of file cmt_fragment.h.

Referenced by add(), clear(), and FragmentHandle::trailer().

UseRef Fragment::use
?

Definition at line 104 of file cmt_fragment.h.

Referenced by add(), clear(), Fragment(), locate(), print(), and ~Fragment().


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