|
| 1 | +// ArduinoJson - arduinojson.org |
| 2 | +// Copyright Benoit Blanchon 2014-2019 |
| 3 | +// MIT License |
| 4 | + |
| 5 | +#pragma once |
| 6 | + |
| 7 | +// Small or big machine? |
| 8 | +#ifndef ARDUINOJSON_EMBEDDED_MODE |
| 9 | +#if defined(ARDUINO) || defined(__IAR_SYSTEMS_ICC__) || defined(__XC) || \ |
| 10 | + defined(__ARMCC_VERSION) |
| 11 | +#define ARDUINOJSON_EMBEDDED_MODE 1 |
| 12 | +#else |
| 13 | +#define ARDUINOJSON_EMBEDDED_MODE 0 |
| 14 | +#endif |
| 15 | +#endif |
| 16 | + |
| 17 | +#if ARDUINOJSON_EMBEDDED_MODE |
| 18 | + |
| 19 | +// Store floats by default to reduce the memory usage (issue #134) |
| 20 | +#ifndef ARDUINOJSON_USE_DOUBLE |
| 21 | +#define ARDUINOJSON_USE_DOUBLE 0 |
| 22 | +#endif |
| 23 | + |
| 24 | +// Store longs by default, because they usually match the size of a float. |
| 25 | +#ifndef ARDUINOJSON_USE_LONG_LONG |
| 26 | +#define ARDUINOJSON_USE_LONG_LONG 0 |
| 27 | +#endif |
| 28 | +#ifndef ARDUINOJSON_USE_INT64 |
| 29 | +#define ARDUINOJSON_USE_INT64 0 |
| 30 | +#endif |
| 31 | + |
| 32 | +// Embedded systems usually don't have std::string |
| 33 | +#ifndef ARDUINOJSON_ENABLE_STD_STRING |
| 34 | +#define ARDUINOJSON_ENABLE_STD_STRING 0 |
| 35 | +#endif |
| 36 | + |
| 37 | +// Embedded systems usually don't have std::stream |
| 38 | +#ifndef ARDUINOJSON_ENABLE_STD_STREAM |
| 39 | +#define ARDUINOJSON_ENABLE_STD_STREAM 0 |
| 40 | +#endif |
| 41 | + |
| 42 | +// Limit nesting as the stack is likely to be small |
| 43 | +#ifndef ARDUINOJSON_DEFAULT_NESTING_LIMIT |
| 44 | +#define ARDUINOJSON_DEFAULT_NESTING_LIMIT 10 |
| 45 | +#endif |
| 46 | + |
| 47 | +#else // ARDUINOJSON_EMBEDDED_MODE |
| 48 | + |
| 49 | +// On a computer we have plenty of memory so we can use doubles |
| 50 | +#ifndef ARDUINOJSON_USE_DOUBLE |
| 51 | +#define ARDUINOJSON_USE_DOUBLE 1 |
| 52 | +#endif |
| 53 | + |
| 54 | +// Use long long when available |
| 55 | +#ifndef ARDUINOJSON_USE_LONG_LONG |
| 56 | +#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) |
| 57 | +#define ARDUINOJSON_USE_LONG_LONG 1 |
| 58 | +#else |
| 59 | +#define ARDUINOJSON_USE_LONG_LONG 0 |
| 60 | +#endif |
| 61 | +#endif |
| 62 | + |
| 63 | +// Use _int64 on old versions of Visual Studio |
| 64 | +#ifndef ARDUINOJSON_USE_INT64 |
| 65 | +#if defined(_MSC_VER) && _MSC_VER <= 1700 |
| 66 | +#define ARDUINOJSON_USE_INT64 1 |
| 67 | +#else |
| 68 | +#define ARDUINOJSON_USE_INT64 0 |
| 69 | +#endif |
| 70 | +#endif |
| 71 | + |
| 72 | +// On a computer, we can use std::string |
| 73 | +#ifndef ARDUINOJSON_ENABLE_STD_STRING |
| 74 | +#define ARDUINOJSON_ENABLE_STD_STRING 1 |
| 75 | +#endif |
| 76 | + |
| 77 | +// On a computer, we can assume std::stream |
| 78 | +#ifndef ARDUINOJSON_ENABLE_STD_STREAM |
| 79 | +#define ARDUINOJSON_ENABLE_STD_STREAM 1 |
| 80 | +#endif |
| 81 | + |
| 82 | +// On a computer, the stack is large so we can increase nesting limit |
| 83 | +#ifndef ARDUINOJSON_DEFAULT_NESTING_LIMIT |
| 84 | +#define ARDUINOJSON_DEFAULT_NESTING_LIMIT 50 |
| 85 | +#endif |
| 86 | + |
| 87 | +#endif // ARDUINOJSON_EMBEDDED_MODE |
| 88 | + |
| 89 | +#ifdef ARDUINO |
| 90 | + |
| 91 | +// Enable support for Arduino String |
| 92 | +#ifndef ARDUINOJSON_ENABLE_ARDUINO_STRING |
| 93 | +#define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 |
| 94 | +#endif |
| 95 | + |
| 96 | +// Enable support for Arduino Stream |
| 97 | +#ifndef ARDUINOJSON_ENABLE_ARDUINO_STREAM |
| 98 | +#define ARDUINOJSON_ENABLE_ARDUINO_STREAM 1 |
| 99 | +#endif |
| 100 | + |
| 101 | +#else // ARDUINO |
| 102 | + |
| 103 | +// Disable support for Arduino String |
| 104 | +#ifndef ARDUINOJSON_ENABLE_ARDUINO_STRING |
| 105 | +#define ARDUINOJSON_ENABLE_ARDUINO_STRING 0 |
| 106 | +#endif |
| 107 | + |
| 108 | +// Disable support for Arduino Stream |
| 109 | +#ifndef ARDUINOJSON_ENABLE_ARDUINO_STREAM |
| 110 | +#define ARDUINOJSON_ENABLE_ARDUINO_STREAM 0 |
| 111 | +#endif |
| 112 | + |
| 113 | +#endif // ARDUINO |
| 114 | + |
| 115 | +#ifndef ARDUINOJSON_ENABLE_PROGMEM |
| 116 | +#ifdef PROGMEM |
| 117 | +#define ARDUINOJSON_ENABLE_PROGMEM 1 |
| 118 | +#else |
| 119 | +#define ARDUINOJSON_ENABLE_PROGMEM 0 |
| 120 | +#endif |
| 121 | +#endif |
| 122 | + |
| 123 | +#ifndef ARDUINOJSON_ENABLE_ALIGNMENT |
| 124 | +#ifdef ARDUINO_ARCH_AVR |
| 125 | +// alignment isn't needed for 8-bit AVR |
| 126 | +#define ARDUINOJSON_ENABLE_ALIGNMENT 0 |
| 127 | +#else |
| 128 | +// but most processors need pointers to be align on word size |
| 129 | +#define ARDUINOJSON_ENABLE_ALIGNMENT 1 |
| 130 | +#endif |
| 131 | +#endif |
| 132 | + |
| 133 | +// Enable deprecated functions by default |
| 134 | +#ifndef ARDUINOJSON_ENABLE_DEPRECATED |
| 135 | +#define ARDUINOJSON_ENABLE_DEPRECATED 1 |
| 136 | +#endif |
| 137 | + |
| 138 | +// Control the exponentiation threshold for big numbers |
| 139 | +// CAUTION: cannot be more that 1e9 !!!! |
| 140 | +#ifndef ARDUINOJSON_POSITIVE_EXPONENTIATION_THRESHOLD |
| 141 | +#define ARDUINOJSON_POSITIVE_EXPONENTIATION_THRESHOLD 1e7 |
| 142 | +#endif |
| 143 | + |
| 144 | +// Control the exponentiation threshold for small numbers |
| 145 | +#ifndef ARDUINOJSON_NEGATIVE_EXPONENTIATION_THRESHOLD |
| 146 | +#define ARDUINOJSON_NEGATIVE_EXPONENTIATION_THRESHOLD 1e-5 |
| 147 | +#endif |
| 148 | + |
| 149 | +#if ARDUINOJSON_USE_LONG_LONG && ARDUINOJSON_USE_INT64 |
| 150 | +#error ARDUINOJSON_USE_LONG_LONG and ARDUINOJSON_USE_INT64 cannot be set together |
| 151 | +#endif |
0 commit comments