next up previous contents index
Next: 4.10.33 nxo_stack Up: 4.10 Classes Previous: 4.10.31 nxo_regex   Contents   Index

Subsections


4.10.32 nxo_regsub

The nxo_regsub class is a subclass of the nxo class.

4.10.32.1 API

cw_nxn_t nxo_regsub_new(cw_nxo_t *a_nxo, const char *a_pattern, uint32_t a_plen, bool a_global, bool a_insensitive, bool a_multiline, bool a_singleline, const char *a_template, uint32_t a_tlen):

Input(s):
a_nxo:
Pointer to a regsub nxo.
a_pattern:
Pointer to a string that specifies a regular expression.
a_plen:
Length of a_pattern.
a_global:
Substitute as many times as possible if true.
a_insensitive:
Match with case insensitivity if true.
a_multiline:
Treat input as a multi-line string if true.
a_singleline:
Treat input as a single line, so that the dot metacharacter matches any character, including a newline.
a_template:
Pointer to a string that specifies a substitution template.
a_tlen:
Length of a_template.
Output(s):
retval:
NXN_ZERO:
Success.
NXN_regexerror:
Regular expression error.
Exception(s):
CW_ONYXX_OOM.
Description:
Constructor.
void nxo_regsub_subst(cw_nxo_t *a_nxo, cw_nxo_t *a_thread, cw_nxo_t *a_input, cw_nxo_t *r_output, uint32_t *r_count):

Input(s):
a_nxo:
Pointer to a regsub nxo.
a_thread:
Pointer to a thread nxo.
a_input:
Pointer to a string nxo.
r_output:
Pointer to an nxo to dup a string reference to.
r_count:
Pointer to a uint32_t .
Output(s):
*r_output:
A string that was created by substituting regular expression matches according to a substitution template.
*r_count:
Number of substitutions made. If 0 substitutions were made, *r_output is a duplicate of a_input, rather than a copy.
Exception(s):
CW_ONYXX_OOM.
Description:
Create a string by substituting according to a_template for each substring within input that matches a regular expression.

As a side effect, set the thread's match cache, which can be queried via nxo_regex_submatch().

cw_nxn_t nxo_regsub_nonew_subst(cw_nxo_t *a_thread, const char *a_pattern, uint32_t a_plen, bool a_global, bool a_insensitive, bool a_multiline, bool a_singleline, const char *a_template, uint32_t a_tlen, cw_nxo_t *a_input, cw_nxo_t *r_output, uint32_t *r_count):

Input(s):
a_thread:
Pointer to a thread nxo.
a_pattern:
Pointer to a string that specifies a regular expression.
a_plen:
Length of a_pattern.
a_global:
Substitute as many times as possible if true.
a_insensitive:
Match with case insensitivity if true.
a_multiline:
Treat input as a multi-line string if true.
a_singleline:
Treat input as a single line, so that the dot metacharacter matches any character, including a newline.
a_template:
Pointer to a string that specifies a substitution template.
a_tlen:
Length of a_template.
a_input:
Pointer to a string nxo.
r_output:
Pointer to an nxo to dup a string reference to.
r_count:
Pointer to a uint32_t .
Output(s):
retval:
NXN_ZERO:
Success.
NXN_regexerror:
Regular expression error.
*r_output:
A string that was created by substituting regular expression matches (specified by a_pattern) according to a_template.
*r_count:
Number of substitutions made. If 0 substitutions were made, *r_output is a duplicate of a_input, rather than a copy.
Exception(s):
CW_ONYXX_OOM.
Description:
Create a string by substituting according to a_template for each substring within input that matches a regular expression.

As a side effect, set the thread's match cache, which can be queried via nxo_regex_submatch().

This function combines nxo_regsub_new() and nxo_regsub_subst() in such a way that no Onyx regsub object is created, thus providing a more efficient way of doing a one-off subst.


next up previous contents index
Next: 4.10.33 nxo_stack Up: 4.10 Classes Previous: 4.10.31 nxo_regex   Contents   Index
Jason Evans 2005-03-16