sources/basics.h

branch
protocol5
changeset 106
7b156b764d11
parent 99
f9f73eeba3b7
child 109
e4966d7e615d
--- a/sources/basics.h	Sat Jan 09 02:35:00 2016 +0200
+++ b/sources/basics.h	Sat Jan 09 17:41:21 2016 +0200
@@ -29,40 +29,24 @@
 */
 
 #pragma once
-#include <algorithm>
-#include <functional>
+#if !defined(_MSC_VER) && !defined(__cdecl)
+# define __cdecl
+#endif
 
-#define FUNCTION auto
-#define STATIC
-#define METHOD auto
 #define MACRO_TO_STRING_2(A) #A
 #define MACRO_TO_STRING(A) MACRO_TO_STRING_2(A)
 
-class String;
-
-using std::swap;
-using std::min;
-using std::max;
-
-template<typename Signature>
-using Function = std::function<Signature>;
+// The Windows SDK appears to use identifiers that conflicts with the identifiers defined in ZFC,
+// so they have to be put in a namespace.
+#define BEGIN_ZFC_NAMESPACE namespace zfc {
+#define END_ZFC_NAMESPACE }
 
-// -------------------------------------------------------------------------------------------------
-//
-enum Color
-{
-	BLACK,
-	RED,
-	GREEN,
-	YELLOW,
-	BLUE,
-	MAGENTA,
-	CYAN,
-	WHITE,
-	DEFAULT,
-
-	NUM_COLORS
-};
+// Goddamnit, MSVC
+#ifdef _MSC_VER
+# define and &&
+# define or ||
+# define not !
+#endif
 
 #define TEXTCOLOR_Escape "\x1C"
 #define TEXTCOLOR_Black			TEXTCOLOR_Escape "M"
@@ -81,18 +65,29 @@
 #define TEXTCOLOR_BrightCyan	TEXTCOLOR_Escape "V"
 #define TEXTCOLOR_Reset			TEXTCOLOR_Escape "-"
 
-// -------------------------------------------------------------------------------------------------
-//
-FUNCTION print_to_console (String a) -> void;
+#undef min
+#undef max
+
+BEGIN_ZFC_NAMESPACE
 
-// -------------------------------------------------------------------------------------------------
-//
-template<typename T> inline FUNCTION
-clamp (T a, T b, T c) -> T
+template<typename T>
+T min (T a, T b)
+{
+	return (a < b) ? a : b;
+}
+
+template<typename T>
+T max (T a, T b)
+{
+	return (a > b) ? a : b;
+}
+
+template<typename T>
+T clamp (T a, T b, T c)
 {
 	return (a < b) ? b : (a > c) ? c : a;
 }
 
-// -------------------------------------------------------------------------------------------------
-//
 struct Exitception {};
+
+END_ZFC_NAMESPACE

mercurial