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

CmtPathPattern Class Reference

#include <cmt_cmtpath_pattern.h>

Collaboration diagram for CmtPathPattern:

[legend]
List of all members.

Public Types

typedef cmt_vector< CmtPathPattern >? CmtPathPatternVector
typedef cmt_vector< CmtPathPattern * >? CmtPathPatternPtrVector

Public Methods

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

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

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.

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

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

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


Public Attributes

cmt_string? line
Use *? use

Member Typedef Documentation

typedef cmt_vector CmtPathPattern::CmtPathPatternPtrVector
?

Definition at line 16 of file cmt_cmtpath_pattern.h.

typedef cmt_vector CmtPathPattern::CmtPathPatternVector
?

Definition at line 15 of file cmt_cmtpath_pattern.h.


Constructor & Destructor Documentation

CmtPathPattern::CmtPathPattern (? ? )?
?

Definition at line 166 of file cmt_cmtpath_pattern.cxx.

00167 {
00168 }

CmtPathPattern::~CmtPathPattern (? ? )?
?

Definition at line 171 of file cmt_cmtpath_pattern.cxx.

00173 {
00174 }

Member Function Documentation

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

Definition at line 17 of file cmt_cmtpath_pattern.cxx.

References add(), Cmt::get_debug(), and cmt_vector< cmt_string >::size().

Referenced by KwdCmtPathPattern::action().

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

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

Definition at line 40 of file cmt_cmtpath_pattern.cxx.

References cmt_vector< CmtPathPattern >::add(), clear(), cmt_string::find(), line, cmt_string::npos, patterns(), cmt_vector< cmt_string >::size(), and use.

Referenced by action().

00041 {
00042   static CmtPathPatternVector& CmtPathPatterns = patterns ();
00043 
00044   CmtPathPattern& p = CmtPathPatterns.add ();
00045 
00046   p.clear ();
00047 
00048   p.use  = use;
00049 
00050   int first_word = 1;
00051 
00052     //
00053     // Install the cmt-statement as a vector of words.
00054     //
00055   for (int i = first_word; i < words.size (); i++)
00056     {
00057       bool need_quotes = (i > (first_word + 1));
00058 
00059       cmt_string& s = words[i];
00060 
00061       if (i > first_word) p.line += " ";
00062 
00063       if (s == ";") first_word = i+1;
00064 
00065       if ((s == "\n") | (s == ";"))
00066         {
00067           p.line += "\n  ";
00068         }
00069       else
00070         {
00071           cmt_string sep = "\"";
00072 
00073           if (s.find (sep) != cmt_string::npos)
00074             {
00075               sep = "\'";
00076             }
00077 
00078           if (!need_quotes) sep = "";
00079 
00080           p.line += sep;
00081           p.line += s;
00082           p.line += sep;
00083         }
00084     }
00085 }

void CmtPathPattern::apply (? ? )? const
?

Applies a pattern to all CMTPATH entries.

Definition at line 224 of file cmt_cmtpath_pattern.cxx.

References Use::current(), expand(), cmt_string::find(), Cmt::get_debug(), Use::get_package_name(), line, cmt_string::npos, SyntaxParser::parse_requirements_text(), Project::reverse_broadcast(), and use.

Referenced by apply_all().

00225 {
00226   if (Cmt::get_debug ())
00227     {
00228       cout << "CmtPathPattern::apply> cmtpath_pattern defined in " << use->get_package_name () << endl;
00229     }
00230 
00231   Use& current_use = Use::current ();
00232 
00233   bool is_constant = ((line.find ("") == cmt_string::npos) &&
00234                       (line.find ("") == cmt_string::npos));
00235 
00236   if (is_constant)
00237     {
00238       cmt_string buffer;
00239 
00240       expand (buffer, "", "");
00241 
00242       if (Cmt::get_debug ())
00243         {
00244           cout << "CmtPathPattern::apply> text=[" << buffer << "]" << endl;
00245         }
00246 
00247       SyntaxParser::parse_requirements_text (buffer, "", ¤t_use);
00248       buffer = "";
00249     }
00250   else
00251     {
00252       CmtPathPatternProjectAction pa (*this, current_use);
00253 
00254       Project::reverse_broadcast (pa);
00255     }
00256 }

void CmtPathPattern::apply_all (? ? )? [static]
?

Applies all patterns to all CMTPATH item.

Definition at line 131 of file cmt_cmtpath_pattern.cxx.

References apply(), patterns(), and cmt_vector< CmtPathPattern >::size().

Referenced by CmtInstallAreaMgr::config(), and Cmt::set_standard_macros().

00132 {
00133   static CmtPathPatternVector& CmtPathPatterns = patterns ();
00134 
00135   int i;
00136 
00137   for (i = 0; i < CmtPathPatterns.size (); i++)
00138     {
00139       CmtPathPattern& p = CmtPathPatterns[i];
00140 
00141       p.apply ();
00142     }
00143 }

void CmtPathPattern::clear (? ? )?
?

Definition at line 177 of file cmt_cmtpath_pattern.cxx.

References line, and use.

Referenced by add(), and clear_all().

00178 {
00179   use = 0;
00180   line = "";
00181 }

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

Definition at line 107 of file cmt_cmtpath_pattern.cxx.

References cmt_vector< CmtPathPattern >::clear(), clear(), patterns(), and cmt_vector< CmtPathPattern >::size().

Referenced by Database::clear().

00108 {
00109   static CmtPathPatternVector& CmtPathPatterns = patterns ();
00110 
00111   for (int i = 0; i < CmtPathPatterns.size (); i++)
00112     {
00113       CmtPathPattern& p = CmtPathPatterns[i];
00114       p.clear ();
00115     }
00116 
00117   CmtPathPatterns.clear ();
00118 }

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

Definition at line 258 of file cmt_cmtpath_pattern.cxx.

References cmt_string::c_str(), line, and cmt_string::replace_all().

Referenced by apply(), and CmtPathPatternProjectAction::run().

00261 {
00262   replacement = line;
00263 
00264   if (replacement != "")
00265     {
00266       // Substitute  template from the cmt statement
00267       replacement.replace_all ("", path.c_str ());
00268       replacement.replace_all ("", project.c_str ());
00269     }
00270 }

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

Get the index'th pattern in the database.

Definition at line 100 of file cmt_cmtpath_pattern.cxx.

References patterns().

00101 {
00102   static CmtPathPatternVector& CmtPathPatterns = patterns ();
00103 
00104   return (CmtPathPatterns[index]);
00105 }

int CmtPathPattern::pattern_number (? ? )? [static]
?

Get the number of registered patterns.

Definition at line 90 of file cmt_cmtpath_pattern.cxx.

References patterns(), and cmt_vector< CmtPathPattern >::size().

00091 {
00092   static CmtPathPatternVector& CmtPathPatterns = patterns ();
00093 
00094   return (CmtPathPatterns.size ());
00095 }

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

Definition at line 120 of file cmt_cmtpath_pattern.cxx.

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

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

00121 {
00122   static Database& db = Database::instance ();
00123   static CmtPathPatternVector& CmtPathPatterns = db.cmtpath_patterns ();
00124 
00125   return (CmtPathPatterns);
00126 }

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

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

Definition at line 149 of file cmt_cmtpath_pattern.cxx.

References Use::get_package_name(), line, patterns(), cmt_vector< CmtPathPattern >::size(), use, and Use::version.

Referenced by Cmt::do_show_cmtpath_patterns().

00150 {
00151   static CmtPathPatternVector& CmtPathPatterns = patterns ();
00152 
00153   int i;
00154 
00155   for (i = 0; i < CmtPathPatterns.size (); i++)
00156     {
00157       CmtPathPattern& p = CmtPathPatterns[i];
00158 
00159       cout << "# " << p.use->get_package_name () << " " << p.use->version 
00160            << " adds a cmtpath_pattern as " << endl;
00161       cout << "  " << p.line << endl;
00162     }
00163 }

Member Data Documentation

cmt_string CmtPathPattern::line
?

Definition at line 38 of file cmt_cmtpath_pattern.h.

Referenced by add(), apply(), clear(), expand(), and show_all().

Use* CmtPathPattern::use
?

Definition at line 39 of file cmt_cmtpath_pattern.h.

Referenced by add(), apply(), clear(), and show_all().


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