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

Awk Class Reference

#include <cmt_awk.h>

Inheritance diagram for Awk

Inheritance graph
[legend]
List of all members.

Public Types

enum  condition { ok, stopped, failed }

Public Methods

 Awk ()
virtual ~Awk ()
condition run (const cmt_string& text, const cmt_string& pattern = "")
condition run (const cmt_string& text, const cmt_regexp& expression)
void stop ()
void abort ()
void allow_continuation ()
condition get_last_condition () const
virtual void begin ()
virtual void filter (const cmt_string& line)
virtual void end ()

Protected Attributes

int m_line_number
condition m_condition
bool m_continuation_allowed

Member Enumeration Documentation

enum Awk::condition
 

Enumeration values:
ok  
stopped  
failed  

Definition at line 56 of file cmt_awk.h.

00056                {ok, stopped, failed}


Constructor & Destructor Documentation

Awk::Awk ( )
 

Definition at line 196 of file cmt_awk.cxx.

00197 {
00198   m_condition = ok;
00199 }

Awk::~Awk ( ) [virtual]
 

Definition at line 202 of file cmt_awk.cxx.

00203 {
00204 }


Member Function Documentation

void Awk::abort ( )
 

Definition at line 382 of file cmt_awk.cxx.

00383 {
00384   m_condition = failed;
00385 }

void Awk::allow_continuation ( )
 

Definition at line 388 of file cmt_awk.cxx.

00389 {
00390   m_continuation_allowed = true;
00391 }

void Awk::begin ( ) [virtual]
 

Reimplemented in Grep, Cut, RecursivePass1, RecursivePass2, Packager, DependencyFilter, Prototyper, WinDefAwk, TriggerAnalyzer, and DependencyAnalyzer.

Definition at line 400 of file cmt_awk.cxx.

Referenced by PAwk::run(), and run().

00401 {
00402 }

void Awk::end ( ) [virtual]
 

Reimplemented in Prototyper, WinDefAwk, TriggerAnalyzer, DependencyAnalyzer, LibraryAnalyzer, and ApplicationAnalyzer.

Definition at line 411 of file cmt_awk.cxx.

Referenced by PAwk::run(), and run().

00412 {
00413 }

void Awk::filter ( const cmt_string & line ) [virtual]
 

Reimplemented in Grep, Cut, RecursivePass1, RecursivePass2, Packager, DependencyFilter, Prototyper, WinDefAwk, TriggerAnalyzer, and DependencyAnalyzer.

Definition at line 405 of file cmt_awk.cxx.

Referenced by Parser::parse_line(), PAwk::run(), and run().

00406 {
00407     //cout << "awk> " << line << endl;
00408 }

Awk::condition Awk::get_last_condition ( ) const
 

Definition at line 394 of file cmt_awk.cxx.

Referenced by Parser::parse_line().

00395 {
00396   return (m_condition);
00397 }

Awk::condition Awk::run ( const cmt_string & command,
const cmt_regexp & expression )
 

Reimplemented in FAwk, and PAwk.

Definition at line 292 of file cmt_awk.cxx.

00294 {
00295   m_line_number = 0;
00296   m_condition = ok;
00297 
00298   begin ();
00299   if (m_condition != ok) return (m_condition);
00300 
00301   if (CmtSystem::testenv ("CMTTESTAWK"))
00302     {
00303       Parser p (this, "", &expression);
00304 
00305       m_condition = p.parse (text);
00306       if (m_condition != ok) return (m_condition);
00307     }
00308   else
00309     {
00310       cmt_string line;
00311       int pos = 0;
00312       int max_pos;
00313 
00314       max_pos = text.size ();
00315 
00316       for (pos = 0; pos < max_pos;)
00317         {
00318           int cr = text.find (pos, "\r\n");
00319           int nl = text.find (pos, '\n');
00320           
00321             // Get the first end-of-line (either lf or cr-lf)
00322           
00323           int first = nl;
00324           
00325           if (cr != cmt_string::npos)
00326             {
00327               if (nl == cmt_string::npos)
00328                 {
00329                   first = cr;
00330                 }
00331               else
00332                 {
00333                   first = (nl < cr) ? nl : cr;
00334                 }
00335             }
00336           
00337           if (first == cmt_string::npos)
00338             {
00339                 // This is likely the last line since there is no end-of-line
00340               text.substr (pos, line);
00341               pos = max_pos;
00342             }
00343           else if (first > pos)
00344             {
00345                 // The eol was found beyond the current position
00346                 // (ie. this is a non empty line)
00347               text.substr (pos, first - pos, line);
00348               pos = first + 1;
00349             }
00350           else
00351             {
00352                 // an empty line
00353               line = "";
00354               pos++;
00355             }
00356           
00357           m_line_number++;
00358           
00359           if (line != "")
00360             {
00361               if (expression.match (line))
00362                 {
00363                   filter (line);
00364                   if (m_condition != ok) return (m_condition);
00365                 }
00366             }
00367         }
00368     }
00369 
00370   end ();
00371 
00372   return (m_condition);
00373 }

Awk::condition Awk::run ( const cmt_string & command,
const cmt_string & pattern = "" )
 

Reimplemented in FAwk, and PAwk.

Definition at line 207 of file cmt_awk.cxx.

Referenced by Generator::build_dependencies(), Generator::build_windefs(), CvsImplementation::do_checkout(), FAwk::run(), and CvsImplementation::show_cvs_infos().

00209 {
00210   m_line_number = 0;
00211   m_condition = ok;
00212 
00213   begin ();
00214   if (m_condition != ok) return (m_condition);
00215 
00216   if (CmtSystem::testenv ("CMTTESTAWK"))
00217     {
00218       Parser p (this, pattern, 0);
00219 
00220       m_condition = p.parse (text);
00221       if (m_condition != ok) return (m_condition);
00222     }
00223   else
00224     {
00225       cmt_string line;
00226       int pos = 0;
00227       int max_pos;
00228 
00229       max_pos = text.size ();
00230 
00231       for (pos = 0; pos < max_pos;)
00232         {
00233           int cr = text.find (pos, "\r\n");
00234           int nl = text.find (pos, '\n');
00235           
00236             // Get the first end-of-line (either lf or cr-lf)
00237           
00238           int first = nl;
00239           
00240           if (cr != cmt_string::npos)
00241             {
00242               if (nl == cmt_string::npos)
00243                 {
00244                   first = cr;
00245                 }
00246               else
00247                 {
00248                   first = (nl < cr) ? nl : cr;
00249                 }
00250             }
00251           
00252           if (first == cmt_string::npos)
00253             {
00254                 // This is likely the last line since there is no end-of-line
00255               text.substr (pos, line);
00256               pos = max_pos;
00257             }
00258           else if (first > pos)
00259             {
00260                 // The eol was found beyond the current position
00261                 // (ie. this is a non empty line)
00262               text.substr (pos, first - pos, line);
00263               pos = first + 1;
00264             }
00265           else
00266             {
00267                 // an empty line
00268               line = "";
00269               pos++;
00270             }
00271           
00272           m_line_number++;
00273           
00274           if (line != "")
00275             {
00276               if ((pattern == "") ||
00277                   (line.find (pattern) != cmt_string::npos))
00278                 {
00279                   filter (line);
00280                   if (m_condition != ok) return (m_condition);
00281                 }
00282             }
00283         }
00284     }
00285 
00286   end ();
00287 
00288   return (m_condition);
00289 }

void Awk::stop ( )
 

Definition at line 376 of file cmt_awk.cxx.

Referenced by Prototyper::begin().

00377 {
00378   m_condition = stopped;
00379 }


Member Data Documentation

condition Awk::m_condition [protected]
 

Definition at line 71 of file cmt_awk.h.

bool Awk::m_continuation_allowed [protected]
 

Definition at line 72 of file cmt_awk.h.

int Awk::m_line_number [protected]
 

Definition at line 70 of file cmt_awk.h.


The documentation for this class was generated from the following files:
Generated at Thu May 16 16:27:34 2002 for CMT by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000