nostrdb

an unfairly fast embedded nostr database backed by lmdb
git clone git://jb55.com/nostrdb
Log | Files | Refs | Submodules | README | LICENSE

flatcc_rtconfig.h (4917B)


      1 #ifndef FLATCC_RTCONFIG_H
      2 #define FLATCC_RTCONFIG_H
      3 
      4 #ifdef __cplusplus
      5 extern "C" {
      6 #endif
      7 
      8 
      9 /* Include portability layer here since all other files depend on it. */
     10 #ifdef FLATCC_PORTABLE
     11 #include "flatcc/portable/portable.h"
     12 #endif
     13 
     14 /*
     15  * Fast printing and parsing of double.
     16  *
     17  * This requires the grisu3/grisu3_* files to be in the include path,
     18  * otherwise strod and sprintf will be used (these needed anyway
     19  * as fallback for cases not supported by grisu3).
     20  */
     21 #ifndef FLATCC_USE_GRISU3
     22 #define FLATCC_USE_GRISU3 1
     23 #endif
     24 
     25 /*
     26  * This requires compiler that has enabled marc=native or similar so
     27  * __SSE4_2__ flag is defined. Otherwise it will have no effect.
     28  *
     29  * While SSE may be used for different purposes, it has (as of this
     30  * writing) only be used to test the effect on JSON whitespace handling
     31  * which improved, but not by a lot, assuming 64-bit unligned access is
     32  * otherwise available:
     33  *
     34  * With 8 space indentation, the JSON benchmark handles 308K parse ops/sec
     35  * while SSE ups that to 333 parse ops/sec or 336 if \r\n is also
     36  * consumed by SSE. Disabling indentation leaves SSE spacing handling
     37  * ineffective, and performance reaches 450K parse ops/sec and can
     38  * improve further to 500+K parse ops/sec if inexact GRISU3 numbers are
     39  * allowed (they are pretty accurate anyway, just not exact). This
     40  * feature requires hacking a flag direct in the grisu3 double parsing
     41  * lib directly and only mentioned for comparison.
     42  *
     43  * In conclusion SSE doesn't add a lot to JSON space handling at least.
     44  *
     45  * Disabled by default, but can be overriden by build system.
     46  */
     47 #ifndef FLATCC_USE_SSE4_2
     48 #define FLATCC_USE_SSE4_2 0
     49 #endif
     50 
     51 /*
     52  * The verifier only reports yes and no. The following setting
     53  * enables assertions in debug builds. It must be compiled into
     54  * the runtime library and is not normally the desired behavior.
     55  *
     56  * NOTE: enabling this can break test cases so use with build, not test.
     57  */
     58 #if !defined(FLATCC_DEBUG_VERIFY) && !defined(NDEBUG)
     59 #define FLATCC_DEBUG_VERIFY 0
     60 #endif
     61 
     62 #if !defined(FLATCC_TRACE_VERIFY)
     63 #define FLATCC_TRACE_VERIFY 0
     64 #endif
     65 
     66 
     67 /*
     68  * Limit recursion level for tables. Actual level may be deeper
     69  * when structs are deeply nested - but these are limited by the
     70  * schema compiler.
     71  */
     72 #ifndef FLATCC_JSON_PRINT_MAX_LEVELS
     73 #define FLATCC_JSON_PRINT_MAX_LEVELS 100
     74 #endif
     75 
     76 /* Maximum length of names printed exluding _type suffix. */
     77 #ifndef FLATCC_JSON_PRINT_NAME_LEN_MAX
     78 #define FLATCC_JSON_PRINT_NAME_LEN_MAX 100
     79 #endif
     80 
     81 /*
     82  * Print float and double values with C99 hexadecimal floating point
     83  * notation. This option is not valid JSON but it avoids precision
     84  * loss, correctly handles NaN, +/-Infinity and is significantly faster
     85  * to parse and print. Some JSON parsers rely on strtod which does
     86  * support hexadecimal floating points when C99 compliant.
     87  */
     88 #ifndef FLATCC_JSON_PRINT_HEX_FLOAT
     89 #define FLATCC_JSON_PRINT_HEX_FLOAT 0
     90 #endif
     91 
     92 /*
     93  * Always print multipe enum flags like `color: "Red Green"`
     94  * even when unquote is selected as an option for single
     95  * value like `color: Green`. Otherwise multiple values
     96  * are printed as `color: Red Green`, but this could break
     97  * some flatbuffer json parser.
     98  */
     99 #ifndef FLATCC_JSON_PRINT_ALWAYS_QUOTE_MULTIPLE_FLAGS
    100 #define FLATCC_JSON_PRINT_ALWAYS_QUOTE_MULTIPLE_FLAGS 1
    101 #endif
    102 
    103 /*
    104  * The general nesting limit may be lower, but for skipping
    105  * JSON we do not need to - we can set this high as it only
    106  * costs a single char per level in a stack array.
    107  */
    108 #ifndef FLATCC_JSON_PARSE_GENERIC_MAX_NEST
    109 #define FLATCC_JSON_PARSE_GENERIC_MAX_NEST 512
    110 #endif
    111 
    112 /* Store value even if it is default. */
    113 #ifndef FLATCC_JSON_PARSE_FORCE_DEFAULTS
    114 #define FLATCC_JSON_PARSE_FORCE_DEFAULTS 0
    115 #endif
    116 
    117 #ifndef FLATCC_JSON_PARSE_ALLOW_UNQUOTED
    118 #define FLATCC_JSON_PARSE_ALLOW_UNQUOTED 1
    119 #endif
    120 
    121 /*
    122  * Multiple enum values are by default not permitted unless
    123  * quoted like `color: "Red Green" as per Googles flatc JSON
    124  * parser while a single value like `color: Red` can be
    125  * unquoted.  Enabling this setting will allow `color: Red
    126  * Green`, but only if FLATCC_JSON_PARSE_ALLOW_UNQUOTED is
    127  * also enabled.
    128  */
    129 #ifndef FLATCC_JSON_PARSE_ALLOW_UNQUOTED_LIST
    130 #define FLATCC_JSON_PARSE_ALLOW_UNQUOTED_LIST 0
    131 #endif
    132 
    133 #ifndef FLATCC_JSON_PARSE_ALLOW_UNKNOWN_FIELD
    134 #define FLATCC_JSON_PARSE_ALLOW_UNKNOWN_FIELD 1
    135 #endif
    136 
    137 #ifndef FLATCC_JSON_PARSE_ALLOW_TRAILING_COMMA
    138 #define FLATCC_JSON_PARSE_ALLOW_TRAILING_COMMA 1
    139 #endif
    140 
    141 /*
    142  * Just parse to the closing bracket '}' if set.
    143  * Otherwise parse to end by consuming space and
    144  * fail if anything but space follows.
    145  */
    146 #ifndef FLATCC_PARSE_IGNORE_TRAILING_DATA
    147 #define FLATCC_PARSE_IGNORE_TRAILING_DATA 0
    148 #endif
    149 
    150 /*
    151  * Optimize to parse a lot of white space, but
    152  * in most cases it probably slows parsing down.
    153  */
    154 #ifndef FLATCC_JSON_PARSE_WIDE_SPACE
    155 #define FLATCC_JSON_PARSE_WIDE_SPACE 0
    156 #endif
    157 
    158 #ifdef __cplusplus
    159 }
    160 #endif
    161 
    162 #endif /* FLATCC_RTCONFIG_H */