29 */ |
29 */ |
30 |
30 |
31 #pragma once |
31 #pragma once |
32 #include <algorithm> |
32 #include <algorithm> |
33 #include <functional> |
33 #include <functional> |
|
34 #include <cstdio> |
|
35 #include <cstdlib> |
|
36 #include <cstring> |
|
37 #include <cctype> |
34 |
38 |
35 #ifndef _MSC_VER |
39 #if !defined(_MSC_VER) && !defined(__cdecl) |
36 # define __cdecl |
40 # define __cdecl |
37 #endif |
41 #endif |
38 |
42 |
39 #define FUNCTION auto |
|
40 #define STATIC |
|
41 #define METHOD auto |
|
42 #define MACRO_TO_STRING_2(A) #A |
43 #define MACRO_TO_STRING_2(A) #A |
43 #define MACRO_TO_STRING(A) MACRO_TO_STRING_2(A) |
44 #define MACRO_TO_STRING(A) MACRO_TO_STRING_2(A) |
44 |
45 |
45 class String; |
46 class String; |
46 |
|
47 using std::swap; |
47 using std::swap; |
48 using std::min; |
48 using std::min; |
49 using std::max; |
49 using std::max; |
50 |
|
51 template<typename Signature> |
|
52 using Function = std::function<Signature>; |
|
53 |
50 |
54 // ------------------------------------------------------------------------------------------------- |
51 // ------------------------------------------------------------------------------------------------- |
55 // |
52 // |
56 enum Color |
53 enum Color |
57 { |
54 { |
85 #define TEXTCOLOR_BrightCyan TEXTCOLOR_Escape "V" |
82 #define TEXTCOLOR_BrightCyan TEXTCOLOR_Escape "V" |
86 #define TEXTCOLOR_Reset TEXTCOLOR_Escape "-" |
83 #define TEXTCOLOR_Reset TEXTCOLOR_Escape "-" |
87 |
84 |
88 // ------------------------------------------------------------------------------------------------- |
85 // ------------------------------------------------------------------------------------------------- |
89 // |
86 // |
90 FUNCTION print_to_console (String a) -> void; |
87 template<typename T> |
91 |
88 inline T clamp (T a, T b, T c) |
92 // ------------------------------------------------------------------------------------------------- |
|
93 // |
|
94 template<typename T> inline FUNCTION |
|
95 clamp (T a, T b, T c) -> T |
|
96 { |
89 { |
97 return (a < b) ? b : (a > c) ? c : a; |
90 return (a < b) ? b : (a > c) ? c : a; |
98 } |
91 } |
99 |
92 |
100 // ------------------------------------------------------------------------------------------------- |
93 // ------------------------------------------------------------------------------------------------- |