Sun, 11 Aug 2013 03:02:50 +0300
made style more consistent
0 | 1 | #include <QObject> |
2 | #include <QStringList> | |
3 | #include <QTextStream> | |
4 | #include <assert.h> | |
5 | #include "types.h" | |
6 | ||
11
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
7 | str doFormat (initlist<StringFormatArg> args) { |
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
8 | assert (args.size() >= 1); |
1 | 9 | str text = args.begin()->value(); |
0 | 10 | |
11
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
11 | for (initlist<StringFormatArg>::iterator it = args.begin() + 1; it != args.end(); ++it) |
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
12 | text = text.arg (it->value()); |
0 | 13 | |
14 | return text; | |
15 | } | |
16 | ||
11
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
17 | void doPrint (FILE* fp, initlist<StringFormatArg> args) { |
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
18 | fprintf (fp, "%s", doFormat (args).toStdString().c_str()); |
0 | 19 | } |
20 | ||
21 | // ============================================================================= | |
11
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
22 | StringFormatArg::StringFormatArg (const str& v) { m_val = v; } |
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
23 | StringFormatArg::StringFormatArg (const char& v) { m_val = v; } |
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
24 | StringFormatArg::StringFormatArg (const uchar& v) { m_val = v; } |
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
25 | StringFormatArg::StringFormatArg (const qchar& v) { m_val = v; } |
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
26 | StringFormatArg::StringFormatArg (const float& v) { m_val = str::number (v); } |
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
27 | StringFormatArg::StringFormatArg (const double& v) { m_val = str::number (v); } |
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
28 | StringFormatArg::StringFormatArg (const char* v) { m_val = v; } |
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
29 | StringFormatArg::StringFormatArg (const void* v) { m_val.sprintf ("%p", v); } |