Xavax C++ Library | Class Index FAQ Overview |
Constructor Summary |
StringFormatter(String& s)
Construct a StringFormatter object. |
Methods Inherited From Formatter | |
print,
print
|
Related Classes | |
Formatter, Variant, String |
Constructor Detail |
StringFormatter(String& s)
s
- the destination String.Example Code |
#include <iostream.h> #include "StringFormatter.h" int main(int argc, char** argv) { // // Declare some local variables to demonstrate the data // types supported by StringFormatter. // const char* s = "Hello World"; bool b = true; int i = 1234; unsigned int ui = 32767; double d = 1.2345; // // Declare a formatter for a String. // String str; StringFormatter stf(str); // // The format string prints a boolean, an integer, two // unsigned integers, a floating point value, and a string. // const char* format = "bool b = %b;\n" "int i = %d;\n" "uint ui = %u;\n" "uint ui = %x;\n" "double d = %f;\n" "char* s = %s;\n"; // // Each of the variables b, i, ui, d, and s will be // converted to a Variant and passed to print. // stf.print(format, b, i, ui, ui, d, s); cout << "result: " << str(); return 0; }
Copyright © 2003 Xavax Inc. -- All Rights Reserved