StrOps::Replace( StrBuf &, const StrPtr &, const StrPtr &, const StrPtr & )

Replace substrings in a StrPtr and store the result to a StrBuf.

Virtual?

No

 

Class

StrOps

 

Arguments

StrBuf &o

the output string

 

StrPtr &i

the input string

 

StrBuf &s

the substring to match

 

StrPtr &r

the substring to replace s

Returns

void

 

Notes

This function reads the input string i and copies it to the output string o, after replacing each occurrence of the string s with string r.

Example

StrBuf i = StrBuf();
i.Set( "PerForce is PerForce, of course, of course!" );

StrBuf wrong, right;
wrong.Set( "PerForce" );
right.Set( "Perforce" );

StrBuf o = StrBuf();

StrOps::Replace( o, i, wrong, right );

StrOps::Dump( o );

Executing the preceding code produces the following output:

% a.out
Perforce is Perforce, of course, of course!