header_utils
Loading...
Searching...
No Matches
String Interpolation

interpolate("hello [world]!", func) -> "hello " + func("world") + "!" More...

Functions

template<char open = '[', char close = ']', typename FUNC>
std::string ghassanpl::interpolate_simple (std::string_view str, FUNC &&func)
 The simplest string interpolation function; calls func for every [group] in str.
template<char open = '[', char close = ']', typename FUNC>
std::string ghassanpl::interpolate_recursive (std::string_view str, FUNC &&func)
 Like interpolate_simple except [group]s can be recursive, that is, can contain other groups that will be interpolated before the outer group.
template<bool SYNTAX>
std::string ghassanpl::interpolate_eval (std::string_view str, eval::environment< SYNTAX > &env)
 Interpolation using the eval module functionality.

Detailed Description

interpolate("hello [world]!", func) -> "hello " + func("world") + "!"

Function Documentation

◆ interpolate_eval()

template<bool SYNTAX>
std::string ghassanpl::interpolate_eval ( std::string_view str,
eval::environment< SYNTAX > & env )
nodiscard

Interpolation using the eval module functionality.

Definition at line 76 of file string_interpolate.h.

◆ interpolate_recursive()

template<char open = '[', char close = ']', typename FUNC>
std::string ghassanpl::interpolate_recursive ( std::string_view str,
FUNC && func )
nodiscard

Like interpolate_simple except [group]s can be recursive, that is, can contain other groups that will be interpolated before the outer group.

interpolate("hello [world [woo]]!", func) -> "hello " + func("world " + func("woo")) + "!"

Definition at line 43 of file string_interpolate.h.

◆ interpolate_simple()

template<char open = '[', char close = ']', typename FUNC>
std::string ghassanpl::interpolate_simple ( std::string_view str,
FUNC && func )
nodiscard

The simplest string interpolation function; calls func for every [group] in str.

Definition at line 19 of file string_interpolate.h.