src/types.cpp

Sun, 11 Aug 2013 03:02:50 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sun, 11 Aug 2013 03:02:50 +0300
changeset 11
3ddebf76105e
parent 6
67b6ef6917ba
child 13
9bdddd2ccde6
permissions
-rw-r--r--

made style more consistent

0
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 #include <QObject>
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 #include <QStringList>
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 #include <QTextStream>
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 #include <assert.h>
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 #include "types.h"
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
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
c9b22c06307c Done config box base
Teemu Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
9 str text = args.begin()->value();
0
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
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
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 return text;
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 }
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
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
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 }
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
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); }

mercurial