FilterableStatement Struct Reference

A kind of sed Statement that can have 0, 1, or 2 filter criteria. More...

#include <muSED.h>

Inheritance diagram for FilterableStatement:
Inheritance graph
[legend]
Collaboration diagram for FilterableStatement:
Collaboration graph
[legend]

List of all members.

Public Member Functions

LineRangeActivationState activationState ()
bool active (ScriptRuntimeContext *context, Statement *statement)
 return true if the patternBuffer, line number, and isLast_ flag in the specified context match the requirements of the filters.
void adoptChild (Statement *newbie)
 Take ownership of a new statement and schedule it for delete when *this is destructed.
void clear ()
std::string debugPrefix () const
virtual std::string debugString () const
virtual std::string debugStringPrefix () const
virtual bool execute (ScriptRuntimeContext *context)=0
 Execute this statement on the specified context.
 FilterableStatement (Statement *parent, int fc, Filter const &f1, Filter const &f2, bool inverted)
void setActivationState (LineRangeActivationState newState)
virtual ~FilterableStatement ()

Static Public Member Functions

static void debugPrint (Statement *p)

Public Attributes

ActivationMap childStatementActivationMap_
std::list< Statement * > childStatements_
Filter filter1_
Filter filter2_
int filters_
bool inverted_
StatementparentStatement_

Detailed Description

A kind of sed Statement that can have 0, 1, or 2 filter criteria.

With zero filter criteria, the statement is always executed. With one filter, the statement is only executed if the filter matches. With 2 filters, the statement is only executed on a range of lines that is defined by the first and second filters. That is, if the first filter has passed on this or some line before it and the second filter has NOT passed on some earlier line. That, is, the second filter defines the end of a group of lines. The statement on that line will be executed, but none after it.

Note that any statement that has filters, can have the logic of the filter range inverted. Here are some examples of filters:

           s/fred/bill/g     # unfiltered
        
           10s/fred/bill/g   # on line 10, replace fred with bill, globally
        
           $p                # only on the last line of the input, print the line
        
           10,20p            # print only lines 10 through 20, inclusive
        
           10!p              # print every line EXCEPT 10 (inverted logic case)
        
           /^begin/,/^end/p  # print only lines in a begin/end block
Note:
The handling of filter result inversion is not part of the filter class but part of the FilterableStatement class

Definition at line 510 of file muSED.h.


Constructor & Destructor Documentation

virtual ~FilterableStatement (  )  [virtual]

Definition at line 546 of file muSED.h.

FilterableStatement ( Statement parent,
int  fc,
Filter const &  f1,
Filter const &  f2,
bool  inverted 
)

Definition at line 555 of file muSED.h.


Member Function Documentation

LineRangeActivationState activationState (  )  [inherited]

Definition at line 119 of file muSED.cxx.

Here is the caller graph for this function:

bool active ( ScriptRuntimeContext context,
Statement statement 
)

return true if the patternBuffer, line number, and isLast_ flag in the specified context match the requirements of the filters.

Parameters:
[in] context The runtime context in which to determine if the current statement, as defined both by the statement pointer and by line number information in the context, is active.
[in] statement The statement about to be executed on the current line of input as defined by the line number and is last flag in the context.

Note that the runtime context keeps track of the activation status of statements, by the statement pointer, based on the filters in a filterable statement. Whenever you have a range filter, the activate function manages the activation state.

Definition at line 316 of file muSED.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

void adoptChild ( Statement newbie  )  [inherited]

Take ownership of a new statement and schedule it for delete when *this is destructed.

Definition at line 444 of file muSED.h.

Here is the caller graph for this function:

void clear (  )  [inherited]

Definition at line 434 of file muSED.h.

Here is the caller graph for this function:

std::string debugPrefix (  )  const [inherited]

Definition at line 459 of file muSED.h.

Here is the caller graph for this function:

static void debugPrint ( Statement p  )  [static, inherited]

Definition at line 474 of file muSED.h.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual std::string debugString (  )  const [virtual, inherited]

Reimplemented in OuterStatement, BlockStatement, SubstStatement, TranslateStatement, PrintStatement, SwapStatement, DeleteStatement, QuitStatement, HoldStatement, and GetStatement.

Definition at line 469 of file muSED.h.

Here is the caller graph for this function:

std::string debugStringPrefix (  )  const [virtual]

Definition at line 545 of file muSED.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool execute ( ScriptRuntimeContext context  )  [pure virtual, inherited]

Execute this statement on the specified context.

Returns:
true to indicate that the script should stop immediately.

Implemented in OuterStatement, BlockStatement, SubstStatement, TranslateStatement, PrintStatement, SwapStatement, DeleteStatement, QuitStatement, HoldStatement, and GetStatement.

Here is the caller graph for this function:

void setActivationState ( LineRangeActivationState  newState  )  [inherited]

Definition at line 138 of file muSED.cxx.

Here is the caller graph for this function:


Member Data Documentation

Definition at line 416 of file muSED.h.

std::list<Statement *> childStatements_ [inherited]

Definition at line 415 of file muSED.h.

Definition at line 550 of file muSED.h.

Definition at line 551 of file muSED.h.

int filters_

Definition at line 548 of file muSED.h.

bool inverted_

Definition at line 552 of file muSED.h.

Definition at line 418 of file muSED.h.


The documentation for this struct was generated from the following files:
Generated on Wed Feb 29 22:59:01 2012 for CXXUtilities by  doxygen 1.6.3