TranslateStatement Struct Reference

A character set replacment statement from sed. Typically specified like this: More...

#include <muSED.h>

Inheritance diagram for TranslateStatement:
Inheritance graph
[legend]
Collaboration diagram for TranslateStatement:
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
bool execute (ScriptRuntimeContext *context)
 Execute this statemement in a given runtime context.
void setActivationState (LineRangeActivationState newState)
 TranslateStatement (Statement *parent, int fc, Filter const &f1, Filter const &f2, bool filtersInverted, std::string const &tgt, std::string const &rep)
virtual ~TranslateStatement ()

Static Public Member Functions

static void debugPrint (Statement *p)
template<class StringIterator1 , class StringIterator2 , class CompiledScript >
static Statementparse (Statement *parent, int filterCount, Filter const &f1, Filter const &f2, bool inverted, StringIterator1 &firstChar, StringIterator2 const &lastChar, size_t line, CompiledScript &script)
 Parse a TranslateStatement from an input stream.

Public Attributes

ActivationMap childStatementActivationMap_
std::list< Statement * > childStatements_
Filter filter1_
Filter filter2_
int filters_
bool inverted_
StatementparentStatement_
std::string replacement_
std::string target_
CharSetTranslator translator_

Detailed Description

A character set replacment statement from sed. Typically specified like this:

           y/target/replacement/
        
        @endode
        
         Note that this translate statement is more flexible than that found in
         SED or even gnu SED.  In the standard SED statement, the target and
         replacement must be simple character lists.  But in this statement,
         character translation ranges are allowed.  So, that this replacement
        @code
        
           y/a-z/A-Z/

Will actually translate all characters, a-z into their upper case form. This is the way the standard unix TR command works, but not the way the y command works in sed or even gnu SED. In SED, the above y// command only translates a to A and z to Z (with - being translated into -).

This significant difference is too valuable to ignore -- especially given the relative lack of utility of the SED command (and uncommon use since it is broken!)

Definition at line 858 of file muSED.h.


Constructor & Destructor Documentation

virtual ~TranslateStatement (  )  [virtual]

Definition at line 889 of file muSED.h.

TranslateStatement ( Statement parent,
int  fc,
Filter const &  f1,
Filter const &  f2,
bool  filtersInverted,
std::string const &  tgt,
std::string const &  rep 
)

Definition at line 896 of file muSED.h.

Here is the caller graph for this function:


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 
) [inherited]

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:

std::string debugString (  )  const [virtual]

Reimplemented from Statement.

Definition at line 609 of file muSED.cxx.

Here is the call graph for this function:

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

Definition at line 545 of file muSED.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

bool execute ( ScriptRuntimeContext context  )  [virtual]

Execute this statemement in a given runtime context.

Parameters:
[in,out] context The runtime context in which to execute this statement.
[in] map Ignored.
Returns:
true if the parsing was successful.

Implements Statement.

Definition at line 261 of file muSED.cxx.

Here is the call graph for this function:

static Statement* parse ( Statement parent,
int  filterCount,
Filter const &  f1,
Filter const &  f2,
bool  inverted,
StringIterator1 &  firstChar,
StringIterator2 const &  lastChar,
size_t  line,
CompiledScript script 
) [static]

Parse a TranslateStatement from an input stream.

Returns:
A statement pointer, or null
Parameters:
[in] parent A pointer to the statement that will own this one.
[in] filterCount A count of the range filters for this statement. 0 means that this statement applies to all lines. 1 means that this statement only applies to specific line either by line number within the input stream, or by any line in the stream matching a regular expression, or by the very last line of the stream. When filterCount == 2, then the script statement only applies to a range of lines within the input stream. The range is defined in a manner documented by class muSED::Filter.
[in] f1 Filter1.
[in] f2 Filter2;
[in] inverted Flag indicating that the f1/f2 logic is inverted.
[in,out] firstChar A pointer to the first character to be parsed.
[in] lastChar The end of the range of characters defining a script fragment.

Definition at line 921 of file muSED.h.

Here is the call graph for this function:

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.

Filter filter1_ [inherited]

Definition at line 550 of file muSED.h.

Filter filter2_ [inherited]

Definition at line 551 of file muSED.h.

int filters_ [inherited]

Definition at line 548 of file muSED.h.

bool inverted_ [inherited]

Definition at line 552 of file muSED.h.

Definition at line 418 of file muSED.h.

std::string replacement_

Definition at line 892 of file muSED.h.

std::string target_

Definition at line 891 of file muSED.h.

Definition at line 894 of file muSED.h.


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