SubstStatement Struct Reference
A regex replacment statement from sed. Typically specified something like this:
More...
#include <muSED.h>
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) |
| SubstStatement (Statement *parent, int fc, Filter const &f1, Filter const &f2, bool filtersInverted, std::string const &tgt, std::string const &rep, int count, bool insensitive) |
virtual | ~SubstStatement () |
Static Public Member Functions |
static void | debugPrint (Statement *p) |
template<class StringIterator1 , class StringIterator2 , class CompiledScript > |
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) |
| Parse a SubstStatement from an input stream.
|
Public Attributes |
ActivationMap | childStatementActivationMap_ |
std::list< Statement * > | childStatements_ |
int | count_ |
Filter | filter1_ |
Filter | filter2_ |
int | filters_ |
bool | inverted_ |
Statement * | parentStatement_ |
SimpleRegex | replacement_ |
SimpleRegex | target_ |
Detailed Description
A regex replacment statement from sed. Typically specified something like this:
s/target/replacement/options
Where options includes at least one of
- 1 -- only replace the FIRST match of the target string in the pattern buffer with replacement.
- g -- replace all of the matches of the target with the replacement.
and is optionally followed by
- i -- forces the comparison to be case insensitive.
Note that the target string is a basic regular expression, with all of it's complexities, and that the replacement string can contain special character sequences to allow the inclusion of parts of the substrings matching the target expression. See the online SED language manuals for examples.
Definition at line 652 of file muSED.h.
Constructor & Destructor Documentation
SubstStatement |
( |
Statement * |
parent, |
|
|
int |
fc, |
|
|
Filter const & |
f1, |
|
|
Filter const & |
f2, |
|
|
bool |
filtersInverted, |
|
|
std::string const & |
tgt, |
|
|
std::string const & |
rep, |
|
|
int |
count, |
|
|
bool |
insensitive | |
|
) |
| | |
Member Function Documentation
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.
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.
void clear |
( |
|
) |
[inherited] |
std::string debugPrefix |
( |
|
) |
const [inherited] |
static void debugPrint |
( |
Statement * |
p |
) |
[static, inherited] |
std::string debugString |
( |
|
) |
const [virtual] |
std::string debugStringPrefix |
( |
|
) |
const [virtual, inherited] |
Execute this statemement in a given runtime context.
- Parameters:
-
[in,out] | context | The runtime context in which to execute this statement. |
- Returns:
- true if the parsing was successful.
Implements Statement.
Definition at line 218 of file muSED.cxx.
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 SubstStatement 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 714 of file muSED.h.
Member Data Documentation
The documentation for this struct was generated from the following files: