SyTen

◆ streamed_replace()

template<typename T >
void syten::streamed_replace ( std::ostream out,
std::string const &  input,
std::string const &  start_delim,
std::string const &  end_delim,
func 
)

Replaces occurences of delimited substrings by function return values.

Given a string input and two delimiter strings start_delim and end_delim, searches for all pairwise occurences of the delimiters, extracts the characters between them and calls the function func with those characters as argument, then replaces the delimiters plus internal content by the return value of the function and streams the result into the supplied output stream.

Parameters
outoutput stream into which data is written
inputinput string
start_delimdelimiter denoting the start of a replacee string
end_delimdelimiter denoting the end of a replacee string
funcfunction to call to get the replacer
Example\n stream_replace("a {b} c {d e} f} {g", "{", "}",
toupper), with toupper a function taking a std::string and returning an all-uppercase version thereof results in a B c D E f} {g being written to the output stream and a warning about a runaway argument.

References std::string::find(), std::flush(), logGE(), std::string::size(), std::string::substr(), and SYTEN_ASSERT_MSG.

Referenced by do_expval().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: