Wed, 17 Jul 2013 00:31:04 +0300
argh
0 | 1 | #include <QObject> |
2 | #include <QStringList> | |
3 | #include <QTextStream> | |
4 | #include <assert.h> | |
5 | #include "types.h" | |
6 | ||
1 | 7 | str doFormat( initlist<StringFormatArg> args ) { |
0 | 8 | assert( args.size() >= 1 ); |
1 | 9 | str text = args.begin()->value(); |
0 | 10 | |
1 | 11 | for( initlist<StringFormatArg>::iterator it = args.begin() + 1; it != args.end(); ++it ) |
12 | text = text.arg( it->value() ); | |
0 | 13 | |
14 | return text; | |
15 | } | |
16 | ||
17 | void doPrint( initlist<StringFormatArg> args ) { | |
18 | printf( "%s", doFormat( args ).toStdString().c_str() ); | |
19 | } | |
20 | ||
21 | // ============================================================================= | |
22 | StringFormatArg::StringFormatArg( const str& v ) { m_val = v; } | |
23 | StringFormatArg::StringFormatArg( const char& v ) { m_val = v; } | |
24 | StringFormatArg::StringFormatArg( const uchar& v ) { m_val = v; } | |
25 | StringFormatArg::StringFormatArg( const qchar& v ) { m_val = v; } | |
26 | StringFormatArg::StringFormatArg( const float& 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; } | |
29 | StringFormatArg::StringFormatArg( const void* v ) { m_val.sprintf( "%p", v ); } |