summaryrefslogtreecommitdiff
path: root/source/core/slang-char-util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/core/slang-char-util.cpp')
-rw-r--r--source/core/slang-char-util.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/source/core/slang-char-util.cpp b/source/core/slang-char-util.cpp
new file mode 100644
index 000000000..53dd98541
--- /dev/null
+++ b/source/core/slang-char-util.cpp
@@ -0,0 +1,48 @@
+#include "slang-char-util.h"
+
+namespace Slang {
+
+static const CharUtil::CharFlagMap _calcCharFlagsMap()
+{
+ typedef CharUtil::Flag Flag;
+
+ CharUtil::CharFlagMap map;
+ memset(&map, 0, sizeof(map));
+
+ {
+ for (Index i = 'a'; i <= 'z'; ++i)
+ {
+ map.flags[i] |= Flag::Lower;
+ }
+ }
+ {
+ for (Index i = 'A'; i <= 'Z'; ++i)
+ {
+ map.flags[i] |= Flag::Upper;
+ }
+ }
+ {
+ for (Index i = '0'; i <= '9'; ++i)
+ {
+ map.flags[i] |= Flag::Digit | Flag::HexDigit;
+ }
+ }
+ {
+ for (Index i = 'a'; i <= 'f'; ++i)
+ {
+ map.flags[i] |= Flag::HexDigit;
+ map.flags[size_t(CharUtil::toUpper(char(i)))] |= Flag::HexDigit;
+ }
+ }
+
+ {
+ map.flags[size_t(' ')] |= Flag::HorizontalWhitespace;
+ map.flags[size_t('\t')] |= Flag::HorizontalWhitespace;
+ }
+
+ return map;
+}
+
+/* static */const CharUtil::CharFlagMap CharUtil::g_charFlagMap = _calcCharFlagsMap();
+
+} // namespace Slang