libhext: C++ Library Documentation  1.0.8-3ad0ae4
Public Member Functions | List of all members
hext::RegexReplacePipe Class Referencefinal

Replaces a string within a string according to a given regex. More...

Inheritance diagram for hext::RegexReplacePipe:
Inheritance graph
[legend]
Collaboration diagram for hext::RegexReplacePipe:
Collaboration graph
[legend]

Public Member Functions

 RegexReplacePipe (boost::regex regex, std::string str)
 Constructs a RegexReplacePipe. More...
 
std::string transform (std::string str) const override
 Replaces a string within str according to the regex given in the constructor. More...
 
- Public Member Functions inherited from hext::Cloneable< RegexReplacePipe, StringPipe >
virtual std::unique_ptr< StringPipeclone () const override
 Clones objects of template type Derived and returns an owning pointer to the newly allocated Base. More...
 
- Public Member Functions inherited from hext::StringPipe
 StringPipe () noexcept
 
 StringPipe (const StringPipe &other)
 
 StringPipe (StringPipe &&) noexcept=default
 
StringPipeoperator= (const StringPipe &other)
 
StringPipeoperator= (StringPipe &&) noexcept=default
 
virtual ~StringPipe () noexcept=default
 
std::string pipe (std::string str) const
 Calls StringPipe::transform successively until the whole StringPipe chain was traversed. More...
 
void append (std::unique_ptr< StringPipe > pipe) noexcept
 Append a StringPipe at the end of the chain. More...
 
template<typename StringPipeType , typename... Args>
void emplace (Args &&... arg)
 Construct a StringPipe at the end of the chain. More...
 

Detailed Description

Replaces a string within a string according to a given regex.

Example:
Use backreferences to address capture groups:
RegexReplacePipe r(boost::regex("^(\\w+) (\\\w+)$"), "$2 $1");
r.transform("first second"); // "second first"
RegexReplacePipe(boost::regex regex, std::string str)
Constructs a RegexReplacePipe.

Definition at line 41 of file RegexReplacePipe.h.

Constructor & Destructor Documentation

◆ RegexReplacePipe()

hext::RegexReplacePipe::RegexReplacePipe ( boost::regex  regex,
std::string  str 
)

Constructs a RegexReplacePipe.

Parameters
regexA regular expression that is applied to the string.
strThe string that will replace the portion matching regex.

Member Function Documentation

◆ transform()

std::string hext::RegexReplacePipe::transform ( std::string  str) const
overridevirtual

Replaces a string within str according to the regex given in the constructor.

Implements hext::StringPipe.


The documentation for this class was generated from the following file: