Configuration.hpp 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. // ArduinoJson - arduinojson.org
  2. // Copyright Benoit Blanchon 2014-2020
  3. // MIT License
  4. #pragma once
  5. #if __cplusplus >= 201103L
  6. #define ARDUINOJSON_HAS_LONG_LONG 1
  7. #define ARDUINOJSON_HAS_NULLPTR 1
  8. #define ARDUINOJSON_HAS_RVALUE_REFERENCES 1
  9. #else
  10. #define ARDUINOJSON_HAS_LONG_LONG 0
  11. #define ARDUINOJSON_HAS_NULLPTR 0
  12. #define ARDUINOJSON_HAS_RVALUE_REFERENCES 0
  13. #endif
  14. #if defined(_MSC_VER) && !ARDUINOJSON_HAS_LONG_LONG
  15. #define ARDUINOJSON_HAS_INT64 1
  16. #else
  17. #define ARDUINOJSON_HAS_INT64 0
  18. #endif
  19. // Small or big machine?
  20. #ifndef ARDUINOJSON_EMBEDDED_MODE
  21. #if defined(ARDUINO) /* Arduino*/ \
  22. || defined(__IAR_SYSTEMS_ICC__) /* IAR Embedded Workbench */ \
  23. || defined(__XC) /* MPLAB XC compiler */ \
  24. || defined(__ARMCC_VERSION) /* Keil ARM Compiler */ \
  25. || defined(__AVR) /* Atmel AVR8/GNU C Compiler */
  26. #define ARDUINOJSON_EMBEDDED_MODE 1
  27. #else
  28. #define ARDUINOJSON_EMBEDDED_MODE 0
  29. #endif
  30. #endif
  31. // Auto enable std::stream if the right headers are here and no conflicting
  32. // macro is defined
  33. #if !defined(ARDUINOJSON_ENABLE_STD_STREAM) && defined(__has_include)
  34. #if __has_include(<istream>) && \
  35. __has_include(<ostream>) && \
  36. !defined(min) && \
  37. !defined(max)
  38. #define ARDUINOJSON_ENABLE_STD_STREAM 1
  39. #else
  40. #define ARDUINOJSON_ENABLE_STD_STREAM 0
  41. #endif
  42. #endif
  43. // Auto enable std::string if the right header is here and no conflicting
  44. // macro is defined
  45. #if !defined(ARDUINOJSON_ENABLE_STD_STRING) && defined(__has_include)
  46. #if __has_include(<string>) && !defined(min) && !defined(max)
  47. #define ARDUINOJSON_ENABLE_STD_STRING 1
  48. #else
  49. #define ARDUINOJSON_ENABLE_STD_STRING 0
  50. #endif
  51. #endif
  52. #if ARDUINOJSON_EMBEDDED_MODE
  53. // Store floats by default to reduce the memory usage (issue #134)
  54. #ifndef ARDUINOJSON_USE_DOUBLE
  55. #define ARDUINOJSON_USE_DOUBLE 0
  56. #endif
  57. // Store longs by default, because they usually match the size of a float.
  58. #ifndef ARDUINOJSON_USE_LONG_LONG
  59. #define ARDUINOJSON_USE_LONG_LONG 0
  60. #endif
  61. // Embedded systems usually don't have std::string
  62. #ifndef ARDUINOJSON_ENABLE_STD_STRING
  63. #define ARDUINOJSON_ENABLE_STD_STRING 0
  64. #endif
  65. // Embedded systems usually don't have std::stream
  66. #ifndef ARDUINOJSON_ENABLE_STD_STREAM
  67. #define ARDUINOJSON_ENABLE_STD_STREAM 0
  68. #endif
  69. // Limit nesting as the stack is likely to be small
  70. #ifndef ARDUINOJSON_DEFAULT_NESTING_LIMIT
  71. #define ARDUINOJSON_DEFAULT_NESTING_LIMIT 10
  72. #endif
  73. #else // ARDUINOJSON_EMBEDDED_MODE
  74. // On a computer we have plenty of memory so we can use doubles
  75. #ifndef ARDUINOJSON_USE_DOUBLE
  76. #define ARDUINOJSON_USE_DOUBLE 1
  77. #endif
  78. // Use long long when available
  79. #ifndef ARDUINOJSON_USE_LONG_LONG
  80. #if ARDUINOJSON_HAS_LONG_LONG || ARDUINOJSON_HAS_INT64
  81. #define ARDUINOJSON_USE_LONG_LONG 1
  82. #else
  83. #define ARDUINOJSON_USE_LONG_LONG 0
  84. #endif
  85. #endif
  86. // On a computer, we can use std::string
  87. #ifndef ARDUINOJSON_ENABLE_STD_STRING
  88. #define ARDUINOJSON_ENABLE_STD_STRING 1
  89. #endif
  90. // On a computer, we can assume std::stream
  91. #ifndef ARDUINOJSON_ENABLE_STD_STREAM
  92. #define ARDUINOJSON_ENABLE_STD_STREAM 1
  93. #endif
  94. // On a computer, the stack is large so we can increase nesting limit
  95. #ifndef ARDUINOJSON_DEFAULT_NESTING_LIMIT
  96. #define ARDUINOJSON_DEFAULT_NESTING_LIMIT 50
  97. #endif
  98. #endif // ARDUINOJSON_EMBEDDED_MODE
  99. #ifdef ARDUINO
  100. #include <Arduino.h>
  101. // Enable support for Arduino's String class
  102. #ifndef ARDUINOJSON_ENABLE_ARDUINO_STRING
  103. #define ARDUINOJSON_ENABLE_ARDUINO_STRING 1
  104. #endif
  105. // Enable support for Arduino's Stream class
  106. #ifndef ARDUINOJSON_ENABLE_ARDUINO_STREAM
  107. #define ARDUINOJSON_ENABLE_ARDUINO_STREAM 1
  108. #endif
  109. // Enable support for Arduino's Print class
  110. #ifndef ARDUINOJSON_ENABLE_ARDUINO_PRINT
  111. #define ARDUINOJSON_ENABLE_ARDUINO_PRINT 1
  112. #endif
  113. #else // ARDUINO
  114. // Disable support for Arduino's String class
  115. #ifndef ARDUINOJSON_ENABLE_ARDUINO_STRING
  116. #define ARDUINOJSON_ENABLE_ARDUINO_STRING 0
  117. #endif
  118. // Disable support for Arduino's Stream class
  119. #ifndef ARDUINOJSON_ENABLE_ARDUINO_STREAM
  120. #define ARDUINOJSON_ENABLE_ARDUINO_STREAM 0
  121. #endif
  122. // Disable support for Arduino's Print class
  123. #ifndef ARDUINOJSON_ENABLE_ARDUINO_PRINT
  124. #define ARDUINOJSON_ENABLE_ARDUINO_PRINT 0
  125. #endif
  126. #endif // ARDUINO
  127. #ifndef ARDUINOJSON_ENABLE_PROGMEM
  128. #ifdef PROGMEM
  129. #define ARDUINOJSON_ENABLE_PROGMEM 1
  130. #else
  131. #define ARDUINOJSON_ENABLE_PROGMEM 0
  132. #endif
  133. #endif
  134. // Convert unicode escape sequence (\u0123) to UTF-8
  135. #ifndef ARDUINOJSON_DECODE_UNICODE
  136. #define ARDUINOJSON_DECODE_UNICODE 0
  137. #endif
  138. // Ignore comments in input
  139. #ifndef ARDUINOJSON_ENABLE_COMMENTS
  140. #define ARDUINOJSON_ENABLE_COMMENTS 0
  141. #endif
  142. // Support NaN in JSON
  143. #ifndef ARDUINOJSON_ENABLE_NAN
  144. #define ARDUINOJSON_ENABLE_NAN 0
  145. #endif
  146. // Support Infinity in JSON
  147. #ifndef ARDUINOJSON_ENABLE_INFINITY
  148. #define ARDUINOJSON_ENABLE_INFINITY 0
  149. #endif
  150. // Control the exponentiation threshold for big numbers
  151. // CAUTION: cannot be more that 1e9 !!!!
  152. #ifndef ARDUINOJSON_POSITIVE_EXPONENTIATION_THRESHOLD
  153. #define ARDUINOJSON_POSITIVE_EXPONENTIATION_THRESHOLD 1e7
  154. #endif
  155. // Control the exponentiation threshold for small numbers
  156. #ifndef ARDUINOJSON_NEGATIVE_EXPONENTIATION_THRESHOLD
  157. #define ARDUINOJSON_NEGATIVE_EXPONENTIATION_THRESHOLD 1e-5
  158. #endif
  159. #ifndef ARDUINOJSON_LITTLE_ENDIAN
  160. #if defined(_MSC_VER) || \
  161. (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \
  162. defined(__LITTLE_ENDIAN__) || defined(__i386) || defined(__x86_64)
  163. #define ARDUINOJSON_LITTLE_ENDIAN 1
  164. #else
  165. #define ARDUINOJSON_LITTLE_ENDIAN 0
  166. #endif
  167. #endif
  168. #ifndef ARDUINOJSON_ENABLE_ALIGNMENT
  169. #if defined(__AVR)
  170. #define ARDUINOJSON_ENABLE_ALIGNMENT 0
  171. #else
  172. #define ARDUINOJSON_ENABLE_ALIGNMENT 1
  173. #endif
  174. #endif
  175. #ifndef ARDUINOJSON_TAB
  176. #define ARDUINOJSON_TAB " "
  177. #endif
  178. #ifndef ARDUINOJSON_ENABLE_STRING_DEDUPLICATION
  179. #define ARDUINOJSON_ENABLE_STRING_DEDUPLICATION 1
  180. #endif
  181. #ifndef ARDUINOJSON_STRING_BUFFER_SIZE
  182. #define ARDUINOJSON_STRING_BUFFER_SIZE 32
  183. #endif
  184. #ifndef ARDUINOJSON_DEBUG
  185. #ifdef __PLATFORMIO_BUILD_DEBUG__
  186. #define ARDUINOJSON_DEBUG 1
  187. #else
  188. #define ARDUINOJSON_DEBUG 0
  189. #endif
  190. #endif