Skip to content

Commit

Permalink
Use an inline definition of sajson::globals_struct::parse_flags.
Browse files Browse the repository at this point in the history
Improves compatibility with VS2015 and GCC 4.7.2-4.8.5.

Fixes #48.
  • Loading branch information
ihameed committed Oct 4, 2020
1 parent 93a7aa9 commit 55b448b
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions include/sajson.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,12 @@ constexpr inline size_t make_element(tag t, size_t value) {
// header. This trick courtesy of Rich Geldreich's Purple JSON parser.
template <typename unused = void>
struct globals_struct {
static const unsigned char parse_flags[256];
};
typedef globals_struct<> globals;

// clang-format off

// bit 0 (1) - set if: plain ASCII string character
// bit 1 (2) - set if: whitespace
// bit 4 (0x10) - set if: 0-9 e E .
template <typename unused>
constexpr uint8_t globals_struct<unused>::parse_flags[256] = {
constexpr static const uint8_t parse_flags[256] = {
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 2, 0, 0, // 0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1
Expand All @@ -167,6 +162,8 @@ typedef globals_struct<> globals;
};

// clang-format on
};
typedef globals_struct<> globals;

constexpr inline bool is_plain_string_character(char c) {
// return c >= 0x20 && c <= 0x7f && c != 0x22 && c != 0x5c;
Expand Down

0 comments on commit 55b448b

Please sign in to comment.