Main Page | Class Hierarchy | Class List | File List | Class 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 Member Functions

 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 62 of file cmt_awk.h.

Referenced by get_last_condition(), and run().


Constructor & Destructor Documentation

Awk::Awk  ) 
 

Definition at line 214 of file cmt_awk.cxx.

References m_condition, and ok.

00215 {
00216   m_condition = ok;
00217 }

Awk::~Awk  )  [virtual]
 

Definition at line 220 of file cmt_awk.cxx.

00221 {
00222 }


Member Function Documentation

void Awk::abort  ) 
 

Definition at line 418 of file cmt_awk.cxx.

References failed, and m_condition.

00419 {
00420   m_condition = failed;
00421 }

void Awk::allow_continuation  ) 
 

Definition at line 424 of file cmt_awk.cxx.

References m_continuation_allowed.

00425 {
00426   m_continuation_allowed = true;
00427 }

void Awk::begin  )  [virtual]
 

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

Definition at line 436 of file cmt_awk.cxx.

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

00437 {
00438 }

void Awk::end  )  [virtual]
 

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

Definition at line 447 of file cmt_awk.cxx.

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

00448 {
00449 }

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

Reimplemented in Grep, Cut, RecursivePass1, RecursivePass2, RecursivePass3, RecursivePass4, WinDefAwk, Packager, Prototyper, DependencyFilter, CmtMountFilterParser, AwkActor, ProjectReader, ProjectPatcher, SequenceRunner, TriggerAnalyzer, and DependencyAnalyzer.

Definition at line 441 of file cmt_awk.cxx.

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

00442 {
00443     //cout << "awk> " << line << endl;
00444 }

Awk::condition Awk::get_last_condition  )  const
 

Definition at line 430 of file cmt_awk.cxx.

References condition, and m_condition.

Referenced by Parser::parse_line().

00431 {
00432   return (m_condition);
00433 }

void Awk::inc_line_number  ) 
 

Definition at line 452 of file cmt_awk.cxx.

References m_line_number.

Referenced by Parser::parse().

00453 {
00454   m_line_number++;
00455 }

Awk::condition Awk::run const cmt_string text,
const cmt_regexp expression
 

Reimplemented in FAwk, and PAwk.

Definition at line 325 of file cmt_awk.cxx.

References begin(), condition, end(), m_condition, m_line_number, ok, and Parser::parse().

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

Awk::condition Awk::run const cmt_string text,
const cmt_string pattern = ""
 

Reimplemented in FAwk, and PAwk.

Definition at line 225 of file cmt_awk.cxx.

References begin(), condition, end(), filter(), cmt_string::find(), m_condition, m_line_number, ok, Parser::parse(), cmt_string::size(), cmt_string::substr(), and CmtSystem::testenv().

Referenced by DependencyGenerator::build(), CvsImplementation::checkout_from_project_file(), CvsImplementation::checkout_from_requirements(), Project::create(), ProjectFactory::create_project(), Cmt::do_awk(), CvsImplementation::do_checkout_phase1(), CvsImplementation::get_cvs_infos_with_offset(), and FAwk::run().

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

void Awk::stop  ) 
 

Definition at line 412 of file cmt_awk.cxx.

References m_condition, and stopped.

Referenced by Prototyper::begin(), and CmtMountFilterParser::filter().

00413 {
00414   m_condition = stopped;
00415 }


Member Data Documentation

condition Awk::m_condition [protected]
 

Definition at line 80 of file cmt_awk.h.

Referenced by abort(), Awk(), get_last_condition(), run(), and stop().

bool Awk::m_continuation_allowed [protected]
 

Definition at line 81 of file cmt_awk.h.

Referenced by allow_continuation().

int Awk::m_line_number [protected]
 

Definition at line 79 of file cmt_awk.h.

Referenced by inc_line_number(), and run().


The documentation for this class was generated from the following files:
Generated on Mon May 2 10:25:26 2005 for CMT by doxygen 1.3.5