src/misc.h

Sun, 11 Aug 2013 02:58:55 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sun, 11 Aug 2013 02:58:55 +0300
changeset 10
bc1414343e19
parent 8
e8f645d9f28f
child 13
9bdddd2ccde6
permissions
-rw-r--r--

Overhauled the way versions are handled, it's all kept dynamically now.

6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 #ifndef MISC_H
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 #define MISC_H
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 #include "types.h"
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
6 uint32 makeByteID (uint8 a, uint8 b, uint8 c, uint8 d);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
7 str binaryConfigName (str ver);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
8 str basename (str path);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
9 list<var> getVersionsList();
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
10 list<var> getReleasesList();
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
11 void addVersion (str name, bool isRelease, str binaryPath);
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 // -----------------------------------------------------------------------------
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 // Templated clamp
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 template<class T> static inline T clamp (T a, T min, T max) {
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 return (a > max) ? max : (a < min) ? min : a;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 // Templated minimum
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 template<class T> static inline T min (T a, T b) {
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 return (a < b) ? a : b;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 // Templated maximum
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 template<class T> static inline T max (T a, T b) {
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 return (a > b) ? a : b;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 // Templated absolute value
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30 template<class T> static inline T abs (T a) {
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 return (a >= 0) ? a : -a;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 #endif // MISC_H

mercurial