2 #include <QStringList> |
2 #include <QStringList> |
3 #include <QTextStream> |
3 #include <QTextStream> |
4 #include <assert.h> |
4 #include <assert.h> |
5 #include "types.h" |
5 #include "types.h" |
6 |
6 |
7 str doFormat( initlist<StringFormatArg> args ) { |
7 str doFormat (initlist<StringFormatArg> args) { |
8 assert( args.size() >= 1 ); |
8 assert (args.size() >= 1); |
9 str text = args.begin()->value(); |
9 str text = args.begin()->value(); |
10 |
10 |
11 for( initlist<StringFormatArg>::iterator it = args.begin() + 1; it != args.end(); ++it ) |
11 for (initlist<StringFormatArg>::iterator it = args.begin() + 1; it != args.end(); ++it) |
12 text = text.arg( it->value() ); |
12 text = text.arg (it->value()); |
13 |
13 |
14 return text; |
14 return text; |
15 } |
15 } |
16 |
16 |
17 void doPrint( FILE* fp, initlist<StringFormatArg> args ) { |
17 void doPrint (FILE* fp, initlist<StringFormatArg> args) { |
18 fprintf( fp, "%s", doFormat( args ).toStdString().c_str() ); |
18 fprintf (fp, "%s", doFormat (args).toStdString().c_str()); |
19 } |
19 } |
20 |
20 |
21 // ============================================================================= |
21 // ============================================================================= |
22 StringFormatArg::StringFormatArg( const str& v ) { m_val = v; } |
22 StringFormatArg::StringFormatArg (const str& v) { m_val = v; } |
23 StringFormatArg::StringFormatArg( const char& v ) { m_val = v; } |
23 StringFormatArg::StringFormatArg (const char& v) { m_val = v; } |
24 StringFormatArg::StringFormatArg( const uchar& v ) { m_val = v; } |
24 StringFormatArg::StringFormatArg (const uchar& v) { m_val = v; } |
25 StringFormatArg::StringFormatArg( const qchar& v ) { m_val = v; } |
25 StringFormatArg::StringFormatArg (const qchar& v) { m_val = v; } |
26 StringFormatArg::StringFormatArg( const float& v ) { m_val = str::number( v ); } |
26 StringFormatArg::StringFormatArg (const float& v) { m_val = str::number (v); } |
27 StringFormatArg::StringFormatArg( const double& v ) { m_val = str::number( v ); } |
27 StringFormatArg::StringFormatArg (const double& v) { m_val = str::number (v); } |
28 StringFormatArg::StringFormatArg( const char* v ) { m_val = v; } |
28 StringFormatArg::StringFormatArg (const char* v) { m_val = v; } |
29 StringFormatArg::StringFormatArg( const void* v ) { m_val.sprintf( "%p", v ); } |
29 StringFormatArg::StringFormatArg (const void* v) { m_val.sprintf ("%p", v); } |