The namespace that contains the micro-SED interpreter definitions. More...
Classes | |
struct | BlockStatement |
A group of statements that executes a single statement with a single pair of line context filters -- optionally with a "while condition" that allows the block to be run multiple times on the same input line while the condition is true. More... | |
struct | CompiledScript |
A list of compiled muSED statements and the parsing tools needed to create it. More... | |
struct | DeleteStatement |
A sed delete statement, usually specified like this: More... | |
struct | Filter |
A (possibly empty) criteria for deciding to execute a line in a sed script. The criteria include. More... | |
struct | FilterableStatement |
A kind of sed Statement that can have 0, 1, or 2 filter criteria. More... | |
struct | GetStatement |
A sed get statement, usually specified like this: More... | |
struct | HoldStatement |
A sed hold statement, usually specified like this: More... | |
struct | OuterStatement |
A fairly useless kind of statement that exists only to serve as the top level statement in a script. It is not "block" statement because it is not filterable. More... | |
struct | PrintStatement |
A sed print statement, usually specified in one of the following forms: More... | |
struct | QuitStatement |
A sed quit statement, usually specified like this: More... | |
struct | ScriptRuntimeContext |
The runtime data needed to execute a muSED script on a stream of input lines. It contains the script and the activation state of the lines within the script, as well as the pattern and hold buffers, the only two variables defined by the sed language. More... | |
struct | Statement |
A statement as defined by the sed language -- except for branches and labels which are not supported. More... | |
struct | SubstStatement |
A regex replacment statement from sed. Typically specified something like this: More... | |
struct | SwapStatement |
A sed swap statement, usually specified like this: More... | |
struct | TranslateStatement |
A character set replacment statement from sed. Typically specified like this: More... | |
Typedefs | |
typedef std::map< Statement *, LineRangeActivationState > | ActivationMap |
Enumerations | |
enum | LineRangeActivationState { neverExecuted = 0, inRange, lastLine } |
Statements with two conditionals as prefixes define a range of lines, and this enumeration type defines the states of activation that such a statement can be in. More... | |
Functions | |
template<class StringContainer > | |
bool | apply (ScriptRuntimeContext &context, std::string const ¤tLine, size_t lineNumber, bool isLast, StringContainer &output, ActivationMap *activationMap) |
Apply a line, with accompanying attributes, to the specified runtime context, which includes a compiled script. Basically this is the function that executes a compiled script on a given line to produce output specific to that line. The assumption is that if the script says not to return any output data, via the return code from the ScriptRuntimeContext::execute(), then it won't have produced any output by mistake. | |
template<class ScriptContainer , class StringContainer1 , class StringContainer2 > | |
std::string | apply (ScriptContainer const &scriptText, StringContainer1 const &input, StringContainer2 &output, int maxIter=0) |
Easy interface for a multi-line script -- compile it and execute it on the input and output containers. This interface will be slower than compiling the script once and using the compiled script many times, but has a simpler interface. | |
template<class StringContainer1 , class StringContainer2 > | |
std::string | apply (CompiledScript &script, StringContainer1 const &input, StringContainer2 &output, int maxIter=0) |
void | expandEscapes (std::string &input) |
translate standard escape sequences, such as \n, into the single character form (such as 0x0a). | |
template<class StringContainer1 , class StringContainer2 > | |
std::string | oneLiner (std::string const &scriptText, StringContainer1 const &input, StringContainer2 &output, int maxIter=0) |
Easy interface for a single line script -- compile it and execute it on the input and output containers. This interface will be slower than compiling the script once and using the compiled script many times, but has a simpler interface. | |
template<class StringIterator1 , class StringIterator2 > | |
bool | parseEscapedString (char delim, std::string &output, StringIterator1 &firstChar, StringIterator2 &lastChar) |
template<class StringIterator1 , class StringIterator2 > | |
void | skipBlanks (StringIterator1 &firstChar, StringIterator2 &lastChar) |
The namespace that contains the micro-SED interpreter definitions.
See the following classes and functions of interest:
typedef std::map<Statement*, LineRangeActivationState> ActivationMap |
Statements with two conditionals as prefixes define a range of lines, and this enumeration type defines the states of activation that such a statement can be in.
bool cxxtls::muSED::apply | ( | ScriptRuntimeContext & | context, | |
std::string const & | currentLine, | |||
size_t | lineNumber, | |||
bool | isLast, | |||
StringContainer & | output, | |||
ActivationMap * | activationMap | |||
) |
Apply a line, with accompanying attributes, to the specified runtime context, which includes a compiled script. Basically this is the function that executes a compiled script on a given line to produce output specific to that line. The assumption is that if the script says not to return any output data, via the return code from the ScriptRuntimeContext::execute(), then it won't have produced any output by mistake.
A given script invocation on a line can produce multiple lines of output, if need be.
[in] | context | The runtime context for the script, including it's compiled form. |
[in] | currentLine | The text of the current line to be processed by the script. |
[in] | isLast | A flag indicating that this particular line is the last one in the input stream. |
[in] | output | A std::liststd::string> that defines the script's output for this one line. |
[in,out] | activationMap | The data structure that keeps track of whether the particular scritp statements are currently active on any given line. |
Definition at line 2440 of file muSED.h.
std::string cxxtls::muSED::apply | ( | ScriptContainer const & | scriptText, | |
StringContainer1 const & | input, | |||
StringContainer2 & | output, | |||
int | maxIter = 0 | |||
) |
Easy interface for a multi-line script -- compile it and execute it on the input and output containers. This interface will be slower than compiling the script once and using the compiled script many times, but has a simpler interface.
[in] | scriptText | The script as a sequences of lines of text. |
[in] | input | The text to be transformed by the script. |
ou] | output The sequence of output text. | |
[in] | maxIter | The maximum number of times a while loop will be allowed to iterate on a single line of input. 0 signifies that the default value should be used. The default can be found in muSED::ScriptRuntimeContext. |
Definition at line 2371 of file muSED.h.
std::string cxxtls::muSED::apply | ( | CompiledScript & | script, | |
StringContainer1 const & | input, | |||
StringContainer2 & | output, | |||
int | maxIter = 0 | |||
) |
apply a script to the strings in the input container and store the results in the output container.
if the script is "not ok" then don't perform any operations and return false;
[in] | script | A string container holding the script. |
[in] | input | The input data stream to process. |
[out] | output | The output data set. |
[in] | maxIter | The maximum number of times a while loop will be allowed to iterate on a single line of input. 0 signifies that the default value should be used. The default can be found in muSED::ScriptRuntimeContext. |
Definition at line 2293 of file muSED.h.
void expandEscapes | ( | std::string & | input | ) |
translate standard escape sequences, such as \n, into the single character form (such as 0x0a).
std::string cxxtls::muSED::oneLiner | ( | std::string const & | scriptText, | |
StringContainer1 const & | input, | |||
StringContainer2 & | output, | |||
int | maxIter = 0 | |||
) |
Easy interface for a single line script -- compile it and execute it on the input and output containers. This interface will be slower than compiling the script once and using the compiled script many times, but has a simpler interface.
Note that since ; is a command separator, as well as end of line, you can still have your script multiple commands.
Sorry about the name. The template instantiator could not properly disambiguate all these "apply" methods without the name change.
Definition at line 2405 of file muSED.h.
bool cxxtls::muSED::parseEscapedString | ( | char | delim, | |
std::string & | output, | |||
StringIterator1 & | firstChar, | |||
StringIterator2 & | lastChar | |||
) |
Parse for a string until the delimiter is reached, handling delims. All other \ sequences will be left unmodified, but will be skipped over properly.
NOTE: the firstChar should not be the leading delimiter of a delimited group. For example, if you are dealing with a regex, first char should be past the leading delimiter, as in the following:
/regex/ ^ fc
Definition at line 70 of file muSED.h.
void cxxtls::muSED::skipBlanks | ( | StringIterator1 & | firstChar, | |
StringIterator2 & | lastChar | |||
) |