Home » U++ Library support » U++ Core » no String::Replace() ?
Re: no String::Replace() ? [message #29361 is a reply to message #11274] |
Sat, 16 October 2010 02:14  |
zsolt
Messages: 702 Registered: December 2005 Location: Budapest, Hungary
|
Contributor |
|
|
BTW, some years ago I created a simple template based string replacer class. Replacing a lot of template variables in a long string many times is much faster that way.
The sample code:
#include <Core/Core.h>
#include <StringReplacer/StringReplacer.h>
CONSOLE_APP_MAIN
{
String template_str = "This is an example\n"
"!PARTNER! lives in !CITY!\n"
"Price of !PRODUCT.NAME! is !PRODUCT.PRICE!\n"
"This is some text at the end.";
VectorMap<String, Value> template_args;
template_args.Add("PARTNER", "John Doe");
template_args.Add("CITY", "Budapest");
template_args.Add("PRODUCT.NAME", "Disk");
template_args.Add("PRODUCT.PRICE", "12.34");
StringReplacer replacer;
replacer.SetTemplate(template_str);
String result;
replacer.Cat(template_args, result);
Cout() << result;
Cout() << "\n\nDone\n";
}
I can upload it here if somebody would use it.
|
|
|
 |
|
no String::Replace() ?
By: guido on Wed, 29 August 2007 19:44
|
 |
|
Re: no String::Replace() ?
By: mirek on Thu, 30 August 2007 16:23
|
 |
|
Re: no String::Replace() ?
By: forlano on Sun, 05 April 2009 09:16
|
 |
|
Re: no String::Replace() ?
By: mirek on Sun, 05 April 2009 09:45
|
 |
|
Re: no String::Replace() ?
By: koldo on Fri, 10 April 2009 17:27
|
 |
|
Re: no String::Replace() ?
By: forlano on Fri, 10 April 2009 20:12
|
 |
|
Re: no String::Replace() ?
By: tojocky on Sat, 23 May 2009 19:13
|
 |
|
Re: no String::Replace() ?
By: alendar on Mon, 08 March 2010 02:18
|
 |
|
Re: no String::Replace() ?
By: sevenjay on Thu, 07 October 2010 15:13
|
 |
|
Re: no String::Replace() ?
By: mirek on Sun, 10 October 2010 20:01
|
 |
|
Re: no String::Replace() ?
By: mdelfede on Mon, 11 October 2010 09:39
|
 |
|
Re: no String::Replace() ?
By: zsolt on Sat, 16 October 2010 02:02
|
 |
|
Re: no String::Replace() ?
|
 |
|
Re: no String::Replace() ?
By: mirek on Mon, 11 October 2010 12:19
|
 |
|
Re: no String::Replace() ?
By: zsolt on Sat, 16 October 2010 02:14
|
Goto Forum:
Current Time: Sun Aug 24 00:20:24 CEST 2025
Total time taken to generate the page: 0.03909 seconds
|