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

Awk Class Reference

#include

Inheritance diagram for Awk

[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 ()
void? inc_line_number ()

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 209 of file cmt_awk.cxx.

00210 {
00211   m_condition = ok;
00212 }

Awk::~Awk ( ) [virtual]
?

Definition at line 215 of file cmt_awk.cxx.

00216 {
00217 }

Member Function Documentation

void Awk::abort ( )
?

Definition at line 413 of file cmt_awk.cxx.

00414 {
00415   m_condition = failed;
00416 }

void Awk::allow_continuation ( )
?

Definition at line 419 of file cmt_awk.cxx.

00420 {
00421   m_continuation_allowed = true;
00422 }

void Awk::begin ( ) [virtual]
?

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

Definition at line 431 of file cmt_awk.cxx.

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

00432 {
00433 }

void Awk::end ( ) [virtual]
?

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

Definition at line 442 of file cmt_awk.cxx.

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

00443 {
00444 }

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

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

Definition at line 436 of file cmt_awk.cxx.

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

00437 {
00438     //cout << "awk> " << line << endl;
00439 }

Awk::condition Awk::get_last_condition ( ) const
?

Definition at line 425 of file cmt_awk.cxx.

Referenced by Parser::parse_line().

00426 {
00427   return (m_condition);
00428 }

void Awk::inc_line_number ( )
?

Definition at line 447 of file cmt_awk.cxx.

Referenced by Parser::parse().

00448 {
00449   m_line_number++;
00450 }

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

Reimplemented in FAwk, and PAwk.

Definition at line 320 of file cmt_awk.cxx.

00322 {
00323   m_line_number = 0;
00324   m_condition = ok;
00325 
00326   begin ();
00327   if (m_condition != ok) return (m_condition);
00328 
00329   Parser p (this, "", &expression);
00330 
00331   m_condition = p.parse (text);
00332   if (m_condition != ok) return (m_condition);
00333 
00334     /*
00335   if (CmtSystem::testenv ("CMTTESTAWK"))
00336     {
00337     }
00338   else
00339     {
00340       cmt_string line;
00341       int pos = 0;
00342       int max_pos;
00343 
00344       max_pos = text.size ();
00345 
00346       for (pos = 0; pos < max_pos;)
00347         {
00348           int cr = text.find (pos, "\r\n");
00349           int nl = text.find (pos, '\n');
00350           
00351             // Get the first end-of-line (either lf or cr-lf)
00352           
00353           int first = nl;
00354           
00355           if (cr != cmt_string::npos)
00356             {
00357               if (nl == cmt_string::npos)
00358                 {
00359                   first = cr;
00360                 }
00361               else
00362                 {
00363                   first = (nl < cr) ? nl : cr;
00364                 }
00365             }
00366           
00367           if (first == cmt_string::npos)
00368             {
00369                 // This is likely the last line since there is no end-of-line
00370               text.substr (pos, line);
00371               pos = max_pos;
00372             }
00373           else if (first > pos)
00374             {
00375                 // The eol was found beyond the current position
00376                 // (ie. this is a non empty line)
00377               text.substr (pos, first - pos, line);
00378               pos = first + 1;
00379             }
00380           else
00381             {
00382                 // an empty line
00383               line = "";
00384               pos++;
00385             }
00386           
00387           m_line_number++;
00388           
00389           if (line != "")
00390             {
00391               if (expression.match (line))
00392                 {
00393                   filter (line);
00394                   if (m_condition != ok) return (m_condition);
00395                 }
00396             }
00397         }
00398     }
00399     */
00400 
00401   end ();
00402 
00403   return (m_condition);
00404 }

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

Reimplemented in FAwk, and PAwk.

Definition at line 220 of file cmt_awk.cxx.

Referenced by DependencyGenerator::build(), Cmt::do_awk(), CvsImplementation::do_checkout(), FAwk::run(), and CvsImplementation::show_cvs_infos().

00222 {
00223   m_line_number = 0;
00224   m_condition = ok;
00225 
00226   begin ();
00227   if (m_condition != ok) return (m_condition);
00228 
00229   if (CmtSystem::testenv ("CMTTESTAWK"))
00230     {
00231       Parser p (this, pattern, 0);
00232 
00233       m_condition = p.parse (text);
00234       if (m_condition != ok) return (m_condition);
00235     }
00236   else
00237     {
00238       cmt_string line;
00239       int pos = 0;
00240       int max_pos;
00241 
00242       max_pos = text.size ();
00243 
00244       for (pos = 0; pos < max_pos;)
00245         {
00246           int cr = text.find (pos, "\r\n");
00247           int nl = text.find (pos, '\n');
00248           
00249             // Get the first end-of-line (either lf or cr-lf)
00250 
00251             //--------------------
00252             //
00253             //     cr    1    0
00254             //   nl
00255             //
00256             //    1      a    b
00257             //
00258             //    0      c    d
00259             //
00260             //--------------------
00261           
00262           int first = nl;
00263           
00264           if (cr != cmt_string::npos)
00265             {
00266                 // cases a or c
00267 
00268               if (nl == cmt_string::npos)
00269                 {
00270                     // case a
00271                   first = cr;
00272                 }
00273               else
00274                 {
00275                     // case c
00276                   first = (nl < cr) ? nl : cr;
00277                 }
00278             }
00279           
00280           if (first == cmt_string::npos)
00281             {
00282                 // This is likely the last line since there is no end-of-line
00283               text.substr (pos, line);
00284               pos = max_pos;
00285             }
00286           else if (first > pos)
00287             {
00288                 // The eol was found beyond the current position
00289                 // (ie. this is a non empty line)
00290               text.substr (pos, first - pos, line);
00291               pos = first + 1;
00292             }
00293           else
00294             {
00295                 // an empty line
00296               line = "";
00297               pos++;
00298             }
00299           
00300           m_line_number++;
00301           
00302           if (line != "")
00303             {
00304               if ((pattern == "") ||
00305                   (line.find (pattern) != cmt_string::npos))
00306                 {
00307                   filter (line);
00308                   if (m_condition != ok) return (m_condition);
00309                 }
00310             }
00311         }
00312     }
00313 
00314   end ();
00315 
00316   return (m_condition);
00317 }

void Awk::stop ( )
?

Definition at line 407 of file cmt_awk.cxx.

Referenced by Prototyper::begin().

00408 {
00409   m_condition = stopped;
00410 }

Member Data Documentation

condition Awk::m_condition [protected]
?

Definition at line 74 of file cmt_awk.h.

bool Awk::m_continuation_allowed [protected]
?

Definition at line 75 of file cmt_awk.h.

int Awk::m_line_number [protected]
?

Definition at line 73 of file cmt_awk.h.


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