]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/lib/bool.qh
5510c171cfcc357487f4cd92182e8b987f88d7ea
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / bool.qh
1 #ifndef BOOL_H
2 #define BOOL_H
3
4 #ifndef QCC_SUPPORT_BOOL
5         // Boolean Constants
6         const int true  = 1;
7         const int false = 0;
8 #endif
9
10 // Transitional aliases
11 [[deprecated("use true")]][[alias("true")]] const bool TRUE;
12 [[deprecated("use false")]][[alias("false")]] const bool FALSE;
13
14 #define boolean(value) ((value) != 0)
15
16 // get true/false value of a string with multiple different inputs
17 float InterpretBoolean(string input)
18 {
19         switch (strtolower(input))
20         {
21                 case "yes":
22                 case "true":
23                 case "on":
24                         return true;
25
26                 case "no":
27                 case "false":
28                 case "off":
29                         return false;
30
31                 default: return boolean(stof(input));
32         }
33 }
34
35 #endif