|
1 #ifndef MISC_H |
|
2 #define MISC_H |
|
3 |
|
4 #include "types.h" |
|
5 |
|
6 uint32 makeByteID( uint8 a, uint8 b, uint8 c, uint8 d ); |
|
7 str binaryConfigName( str ver ); |
|
8 |
|
9 // ----------------------------------------------------------------------------- |
|
10 // Templated clamp |
|
11 template<class T> static inline T clamp (T a, T min, T max) { |
|
12 return (a > max) ? max : (a < min) ? min : a; |
|
13 } |
|
14 |
|
15 // Templated minimum |
|
16 template<class T> static inline T min (T a, T b) { |
|
17 return (a < b) ? a : b; |
|
18 } |
|
19 |
|
20 // Templated maximum |
|
21 template<class T> static inline T max (T a, T b) { |
|
22 return (a > b) ? a : b; |
|
23 } |
|
24 |
|
25 // Templated absolute value |
|
26 template<class T> static inline T abs (T a) { |
|
27 return (a >= 0) ? a : -a; |
|
28 } |
|
29 |
|
30 #endif // MISC_H |