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

CmtPathPattern Class Reference

#include

Collaboration diagram for CmtPathPattern:

[legend]
List of all members.

Public Types

typedef cmt_vector? CmtPathPatternVector
typedef cmt_vector? CmtPathPatternPtrVector

Public Methods

? CmtPathPattern ()
? ~CmtPathPattern ()
void? clear ()
void? apply () const
? Applies a pattern to all CMTPATH entries. More...

void? expand (cmt_string& line, const cmt_string& path) const

Public Attributes

CmtSystem::cmt_string_vector? words
Use*? use

Static Public Methods

void? action (const CmtSystem::cmt_string_vector& words, Use* use)
void? add (const CmtSystem::cmt_string_vector& words, Use* use)
int? pattern_number ()
? Get the number of registered patterns. More...

CmtPathPattern&? pattern (int index)
? Get the index'th pattern in the database. More...

void? clear_all ()
CmtPathPatternVector&? patterns ()
void? apply_all ()
? Applies all patterns to all CMTPATH item. More...

void? show_all ()
? this is the cmt show cmtpath_patterns command It just shows the cmtpath_pattern declarations. More...


Member Typedef Documentation

typedef cmt_vector CmtPathPattern::CmtPathPatternPtrVector
?

Definition at line 10 of file cmt_cmtpath_pattern.h.

typedef cmt_vector CmtPathPattern::CmtPathPatternVector
?

Definition at line 9 of file cmt_cmtpath_pattern.h.


Constructor & Destructor Documentation

CmtPathPattern::CmtPathPattern ( )
?

Definition at line 141 of file cmt_cmtpath_pattern.cxx.

00142 {
00143 }

CmtPathPattern::~CmtPathPattern ( )
?

Definition at line 146 of file cmt_cmtpath_pattern.cxx.

00148 {
00149 }

Member Function Documentation

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

Definition at line 12 of file cmt_cmtpath_pattern.cxx.

Referenced by KwdCmtPathPattern::action().

00013 {
00014   if (words.size () < 1) return;
00015 
00016     //
00017     // expected syntax is:
00018     //
00019     //  cmtpath_pattern any-cmt-statement
00020     //
00021     // where any-cmt-statement may contain the "template"
00022     //
00023     //      
00024     //
00025 
00026   add (words, use);
00027 
00028   if (Cmt::get_debug ())
00029     {
00030       cout << "CmtPathPattern::action> add " << endl;
00031     }
00032 }

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

Definition at line 34 of file cmt_cmtpath_pattern.cxx.

Referenced by action().

00035 {
00036   static CmtPathPatternVector& CmtPathPatterns = patterns ();
00037 
00038   CmtPathPattern& p = CmtPathPatterns.add ();
00039 
00040   p.clear ();
00041 
00042   p.use  = use;
00043 
00044     //
00045     // Install the cmt-statement as a vector of words.
00046     //
00047   for (int i = 1; i < words.size (); i++)
00048     {
00049       cmt_string& s = p.words.add ();
00050       s = words[i];
00051     }
00052 }

void CmtPathPattern::apply ( ) const
?

Applies a pattern to all CMTPATH entries.

Definition at line 161 of file cmt_cmtpath_pattern.cxx.

Referenced by apply_all().

00162 {
00163   if (Cmt::get_debug ())
00164     {
00165       cout << "CmtPathPattern::apply> cmtpath_pattern defined in " << use->get_package_name () << endl;
00166     }
00167 
00168   Use& current_use = Use::current ();
00169 
00170   const CmtSystem::cmt_string_vector& paths = Cmt::get_cmt_path ();
00171   const CmtSystem::cmt_string_vector& path_sources = Cmt::get_cmt_path_sources ();
00172 
00173   cmt_string buffer;
00174 
00175   bool is_constant = true;
00176 
00177   int i;
00178 
00179   for (i = 0; i < words.size (); i++)
00180     {
00181       const cmt_string& w = words[i];
00182 
00183       int pos = w.find ("");
00184       if (pos != cmt_string::npos)
00185         {
00186           is_constant = false;
00187           break;
00188         }
00189     }
00190 
00191   if (is_constant)
00192     {
00193       expand (buffer, "");
00194 
00195       SyntaxParser::parse_requirements_text (buffer, "", ¤t_use);
00196       buffer = "";
00197     }
00198   else
00199     {
00200       for (i = (paths.size () - 1); i >= 0; i--)
00201         {  
00202           const cmt_string& p = paths[i];
00203           const cmt_string& s = path_sources[i];
00204 
00205           if (s == "default path") continue;
00206         
00207           expand (buffer, p);
00208           
00209           SyntaxParser::parse_requirements_text (buffer, "", ¤t_use);
00210           buffer = "";
00211         }
00212     }
00213 }

void CmtPathPattern::apply_all ( ) [static]
?

Applies all patterns to all CMTPATH item.

Definition at line 98 of file cmt_cmtpath_pattern.cxx.

Referenced by CmtInstallAreaMgr::config(), and CmtInstallAreaMgr::setup().

00099 {
00100   static CmtPathPatternVector& CmtPathPatterns = patterns ();
00101 
00102   int i;
00103 
00104   for (i = 0; i < CmtPathPatterns.size (); i++)
00105     {
00106       CmtPathPattern& p = CmtPathPatterns[i];
00107 
00108       p.apply ();
00109     }
00110 }

void CmtPathPattern::clear ( )
?

Definition at line 152 of file cmt_cmtpath_pattern.cxx.

Referenced by add(), and clear_all().

00153 {
00154   use = 0;
00155   words.clear ();
00156 }

void CmtPathPattern::clear_all ( ) [static]
?

Definition at line 74 of file cmt_cmtpath_pattern.cxx.

Referenced by Database::clear().

00075 {
00076   static CmtPathPatternVector& CmtPathPatterns = patterns ();
00077 
00078   for (int i = 0; i < CmtPathPatterns.size (); i++)
00079     {
00080       CmtPathPattern& p = CmtPathPatterns[i];
00081       p.clear ();
00082     }
00083 
00084   CmtPathPatterns.clear ();
00085 }

void CmtPathPattern::expand ( cmt_string & line,
const cmt_string & path?) const
?

Definition at line 215 of file cmt_cmtpath_pattern.cxx.

Referenced by apply().

00216 {
00217   line = "";
00218 
00219     // First re-create the cmt statement as one line.
00220   for (int i = 0; i < words.size (); i++)
00221     {
00222       const cmt_string& w = words[i];
00223 
00224       if (i > 0) line += " ";
00225 
00226       if ((w == "\n") | (w == ";"))
00227         {
00228           line += "\n";
00229         }
00230       else
00231         {
00232           line += "\"";
00233           line += w;
00234           line += "\"";
00235         }
00236     }
00237 
00238   if (line != "")
00239     {
00240         // Substitute  template from the cmt statement
00241       line.replace_all ("", path.c_str ());
00242     }
00243 }

CmtPathPattern & CmtPathPattern::pattern ( int index?) [static]
?

Get the index'th pattern in the database.

Definition at line 67 of file cmt_cmtpath_pattern.cxx.

00068 {
00069   static CmtPathPatternVector& CmtPathPatterns = patterns ();
00070 
00071   return (CmtPathPatterns[index]);
00072 }

int CmtPathPattern::pattern_number ( ) [static]
?

Get the number of registered patterns.

Definition at line 57 of file cmt_cmtpath_pattern.cxx.

00058 {
00059   static CmtPathPatternVector& CmtPathPatterns = patterns ();
00060 
00061   return (CmtPathPatterns.size ());
00062 }

CmtPathPattern::CmtPathPatternVector & CmtPathPattern::patterns ( ) [static]
?

Definition at line 87 of file cmt_cmtpath_pattern.cxx.

Referenced by add(), apply_all(), clear_all(), pattern(), pattern_number(), and show_all().

00088 {
00089   static Database& db = Database::instance ();
00090   static CmtPathPatternVector& CmtPathPatterns = db.cmtpath_patterns ();
00091 
00092   return (CmtPathPatterns);
00093 }

void CmtPathPattern::show_all ( ) [static]
?

this is the cmt show cmtpath_patterns command It just shows the cmtpath_pattern declarations.

Definition at line 116 of file cmt_cmtpath_pattern.cxx.

Referenced by Cmt::do_show_cmtpath_patterns().

00117 {
00118   static CmtPathPatternVector& CmtPathPatterns = patterns ();
00119 
00120   int i;
00121 
00122   for (i = 0; i < CmtPathPatterns.size (); i++)
00123     {
00124       CmtPathPattern& p = CmtPathPatterns[i];
00125 
00126       cout << "# " << p.use->get_package_name () << " " << p.use->version << " defines ";
00127       cout << "cmtpath_pattern " << " as [";
00128 
00129       for (int wi = 0; wi < p.words.size (); wi++)
00130         {
00131           const cmt_string& s = p.words[wi];
00132           if (wi > 0) cout << " ";
00133           cout << s;
00134         }
00135 
00136       cout << "]" << endl;
00137     }
00138 }

Member Data Documentation

Use * CmtPathPattern::use
?

Definition at line 33 of file cmt_cmtpath_pattern.h.

CmtSystem::cmt_string_vector CmtPathPattern::words
?

Definition at line 32 of file cmt_cmtpath_pattern.h.


The documentation for this class was generated from the following files:
Generated at Mon Aug 11 12:56:23 2003 for CMT by 1.2.3 written by , ??1997-2000