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