|
1 #include <QObject> |
|
2 #include <QStringList> |
|
3 #include <QTextStream> |
|
4 #include <assert.h> |
|
5 #include "types.h" |
|
6 |
|
7 str doFormat( std::vector<StringFormatArg> args ) { |
|
8 assert( args.size() >= 1 ); |
|
9 str text = args[0].value(); |
|
10 |
|
11 for( uchar i = 1; i < args.size(); ++i ) |
|
12 text = text.arg( args[i].value() ); |
|
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 ); } |