From 39895a677e5d370824e702cfe90ebc67737b8482 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 12 May 2021 09:12:09 +0200 Subject: import ArduinoJson 6.18.0 --- include/lib/ArduinoJson/Polyfills/alias_cast.hpp | 29 ++++++++ include/lib/ArduinoJson/Polyfills/assert.hpp | 14 ++++ include/lib/ArduinoJson/Polyfills/attributes.hpp | 54 +++++++++++++++ include/lib/ArduinoJson/Polyfills/ctype.hpp | 20 ++++++ include/lib/ArduinoJson/Polyfills/integer.hpp | 30 ++++++++ include/lib/ArduinoJson/Polyfills/limits.hpp | 45 ++++++++++++ include/lib/ArduinoJson/Polyfills/math.hpp | 27 ++++++++ include/lib/ArduinoJson/Polyfills/mpl/max.hpp | 26 +++++++ include/lib/ArduinoJson/Polyfills/pgmspace.hpp | 79 ++++++++++++++++++++++ .../lib/ArduinoJson/Polyfills/pgmspace_generic.hpp | 32 +++++++++ include/lib/ArduinoJson/Polyfills/preprocessor.hpp | 35 ++++++++++ include/lib/ArduinoJson/Polyfills/safe_strcmp.hpp | 32 +++++++++ include/lib/ArduinoJson/Polyfills/static_array.hpp | 34 ++++++++++ include/lib/ArduinoJson/Polyfills/type_traits.hpp | 24 +++++++ .../Polyfills/type_traits/conditional.hpp | 20 ++++++ .../ArduinoJson/Polyfills/type_traits/declval.hpp | 14 ++++ .../Polyfills/type_traits/enable_if.hpp | 19 ++++++ .../Polyfills/type_traits/integral_constant.hpp | 19 ++++++ .../ArduinoJson/Polyfills/type_traits/is_array.hpp | 21 ++++++ .../Polyfills/type_traits/is_base_of.hpp | 26 +++++++ .../ArduinoJson/Polyfills/type_traits/is_class.hpp | 26 +++++++ .../ArduinoJson/Polyfills/type_traits/is_const.hpp | 17 +++++ .../Polyfills/type_traits/is_convertible.hpp | 47 +++++++++++++ .../ArduinoJson/Polyfills/type_traits/is_enum.hpp | 22 ++++++ .../Polyfills/type_traits/is_floating_point.hpp | 19 ++++++ .../Polyfills/type_traits/is_integral.hpp | 33 +++++++++ .../Polyfills/type_traits/is_pointer.hpp | 16 +++++ .../ArduinoJson/Polyfills/type_traits/is_same.hpp | 17 +++++ .../Polyfills/type_traits/is_signed.hpp | 43 ++++++++++++ .../Polyfills/type_traits/is_unsigned.hpp | 37 ++++++++++ .../Polyfills/type_traits/make_unsigned.hpp | 49 ++++++++++++++ .../Polyfills/type_traits/remove_const.hpp | 20 ++++++ .../Polyfills/type_traits/remove_reference.hpp | 20 ++++++ .../Polyfills/type_traits/type_identity.hpp | 15 ++++ include/lib/ArduinoJson/Polyfills/utility.hpp | 28 ++++++++ 35 files changed, 1009 insertions(+) create mode 100644 include/lib/ArduinoJson/Polyfills/alias_cast.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/assert.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/attributes.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/ctype.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/integer.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/limits.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/math.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/mpl/max.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/pgmspace.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/pgmspace_generic.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/preprocessor.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/safe_strcmp.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/static_array.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/type_traits.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/type_traits/conditional.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/type_traits/declval.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/type_traits/enable_if.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/type_traits/integral_constant.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/type_traits/is_array.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/type_traits/is_base_of.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/type_traits/is_class.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/type_traits/is_const.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/type_traits/is_convertible.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/type_traits/is_enum.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/type_traits/is_floating_point.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/type_traits/is_integral.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/type_traits/is_pointer.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/type_traits/is_same.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/type_traits/is_signed.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/type_traits/is_unsigned.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/type_traits/make_unsigned.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/type_traits/remove_const.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/type_traits/remove_reference.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/type_traits/type_identity.hpp create mode 100644 include/lib/ArduinoJson/Polyfills/utility.hpp (limited to 'include/lib/ArduinoJson/Polyfills') diff --git a/include/lib/ArduinoJson/Polyfills/alias_cast.hpp b/include/lib/ArduinoJson/Polyfills/alias_cast.hpp new file mode 100644 index 0000000..8f8e277 --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/alias_cast.hpp @@ -0,0 +1,29 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include +#include // for size_t + +#include +#include "math.hpp" + +namespace ARDUINOJSON_NAMESPACE { + +template +struct alias_cast_t { + union { + F raw; + T data; + }; +}; + +template +T alias_cast(F raw_data) { + alias_cast_t ac; + ac.raw = raw_data; + return ac.data; +} +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/assert.hpp b/include/lib/ArduinoJson/Polyfills/assert.hpp new file mode 100644 index 0000000..1030ec6 --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/assert.hpp @@ -0,0 +1,14 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include + +#if ARDUINOJSON_DEBUG +#include +#define ARDUINOJSON_ASSERT(X) assert(X) +#else +#define ARDUINOJSON_ASSERT(X) ((void)0) +#endif diff --git a/include/lib/ArduinoJson/Polyfills/attributes.hpp b/include/lib/ArduinoJson/Polyfills/attributes.hpp new file mode 100644 index 0000000..f04c9ac --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/attributes.hpp @@ -0,0 +1,54 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#ifdef _MSC_VER // Visual Studio + +#define FORCE_INLINE // __forceinline causes C4714 when returning std::string +#define NO_INLINE __declspec(noinline) + +#ifndef ARDUINOJSON_DEPRECATED +#define ARDUINOJSON_DEPRECATED(msg) __declspec(deprecated(msg)) +#endif + +#elif defined(__GNUC__) // GCC or Clang + +#define FORCE_INLINE __attribute__((always_inline)) +#define NO_INLINE __attribute__((noinline)) + +#ifndef ARDUINOJSON_DEPRECATED +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) +#define ARDUINOJSON_DEPRECATED(msg) __attribute__((deprecated(msg))) +#else +#define ARDUINOJSON_DEPRECATED(msg) __attribute__((deprecated)) +#endif +#endif + +#else // Other compilers + +#define FORCE_INLINE +#define NO_INLINE + +#ifndef ARDUINOJSON_DEPRECATED +#define ARDUINOJSON_DEPRECATED(msg) +#endif + +#endif + +#if __cplusplus >= 201103L +#define NOEXCEPT noexcept +#else +#define NOEXCEPT throw() +#endif + +#if defined(__has_attribute) +#if __has_attribute(no_sanitize) +#define ARDUINOJSON_NO_SANITIZE(check) __attribute__((no_sanitize(check))) +#else +#define ARDUINOJSON_NO_SANITIZE(check) +#endif +#else +#define ARDUINOJSON_NO_SANITIZE(check) +#endif diff --git a/include/lib/ArduinoJson/Polyfills/ctype.hpp b/include/lib/ArduinoJson/Polyfills/ctype.hpp new file mode 100644 index 0000000..bd7a8cc --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/ctype.hpp @@ -0,0 +1,20 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include + +namespace ARDUINOJSON_NAMESPACE { + +#ifndef isdigit +inline bool isdigit(char c) { + return '0' <= c && c <= '9'; +} +#endif + +inline bool issign(char c) { + return '-' == c || c == '+'; +} +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/integer.hpp b/include/lib/ArduinoJson/Polyfills/integer.hpp new file mode 100644 index 0000000..066c7b8 --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/integer.hpp @@ -0,0 +1,30 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include // int8_t, int16_t + +#include + +namespace ARDUINOJSON_NAMESPACE { + +template +struct int_t; + +template <> +struct int_t<8> { + typedef int8_t type; +}; + +template <> +struct int_t<16> { + typedef int16_t type; +}; + +template <> +struct int_t<32> { + typedef int32_t type; +}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/limits.hpp b/include/lib/ArduinoJson/Polyfills/limits.hpp new file mode 100644 index 0000000..8004828 --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/limits.hpp @@ -0,0 +1,45 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include "type_traits.hpp" + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4310) +#endif + +namespace ARDUINOJSON_NAMESPACE { + +// Differs from standard because we can't use the symbols "min" and "max" +template +struct numeric_limits; + +template +struct numeric_limits::value>::type> { + static T lowest() { + return 0; + } + static T highest() { + return T(-1); + } +}; + +template +struct numeric_limits< + T, typename enable_if::value && is_signed::value>::type> { + static T lowest() { + return T(T(1) << (sizeof(T) * 8 - 1)); + } + static T highest() { + return T(~lowest()); + } +}; + +} // namespace ARDUINOJSON_NAMESPACE + +#ifdef _MSC_VER +#pragma warning(pop) +#endif diff --git a/include/lib/ArduinoJson/Polyfills/math.hpp b/include/lib/ArduinoJson/Polyfills/math.hpp new file mode 100644 index 0000000..eff272a --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/math.hpp @@ -0,0 +1,27 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include + +namespace ARDUINOJSON_NAMESPACE { + +// Some libraries #define isnan() and isinf() so we need to check before +// using this name + +#ifndef isnan +template +bool isnan(T x) { + return x != x; +} +#endif + +#ifndef isinf +template +bool isinf(T x) { + return x != 0.0 && x * 2 == x; +} +#endif +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/mpl/max.hpp b/include/lib/ArduinoJson/Polyfills/mpl/max.hpp new file mode 100644 index 0000000..9ac47a5 --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/mpl/max.hpp @@ -0,0 +1,26 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include + +#include // for size_t + +namespace ARDUINOJSON_NAMESPACE { + +// A meta-function that returns the highest value +template Y)> +struct Max {}; + +template +struct Max { + static const size_t value = X; +}; + +template +struct Max { + static const size_t value = Y; +}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/pgmspace.hpp b/include/lib/ArduinoJson/Polyfills/pgmspace.hpp new file mode 100644 index 0000000..f253818 --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/pgmspace.hpp @@ -0,0 +1,79 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include +#include +#include + +namespace ARDUINOJSON_NAMESPACE { +// Wraps a const char* so that the our functions are picked only if the +// originals are missing +struct pgm_p { + pgm_p(const char* p) : address(p) {} + const char* address; +}; +} // namespace ARDUINOJSON_NAMESPACE + +#ifndef strlen_P +inline size_t strlen_P(ARDUINOJSON_NAMESPACE::pgm_p s) { + const char* p = s.address; + ARDUINOJSON_ASSERT(p != NULL); + while (pgm_read_byte(p)) p++; + return size_t(p - s.address); +} +#endif + +#ifndef strncmp_P +inline int strncmp_P(const char* a, ARDUINOJSON_NAMESPACE::pgm_p b, size_t n) { + const char* s1 = a; + const char* s2 = b.address; + ARDUINOJSON_ASSERT(s1 != NULL); + ARDUINOJSON_ASSERT(s2 != NULL); + while (n-- > 0) { + char c1 = *s1++; + char c2 = static_cast(pgm_read_byte(s2++)); + if (c1 < c2) + return -1; + if (c1 > c2) + return 1; + if (c1 == 0 /* and c2 as well */) + return 0; + } + return 0; +} +#endif + +#ifndef strcmp_P +inline int strcmp_P(const char* a, ARDUINOJSON_NAMESPACE::pgm_p b) { + const char* s1 = a; + const char* s2 = b.address; + ARDUINOJSON_ASSERT(s1 != NULL); + ARDUINOJSON_ASSERT(s2 != NULL); + for (;;) { + char c1 = *s1++; + char c2 = static_cast(pgm_read_byte(s2++)); + if (c1 < c2) + return -1; + if (c1 > c2) + return 1; + if (c1 == 0 /* and c2 as well */) + return 0; + } +} +#endif + +#ifndef memcpy_P +inline void* memcpy_P(void* dst, ARDUINOJSON_NAMESPACE::pgm_p src, size_t n) { + uint8_t* d = reinterpret_cast(dst); + const char* s = src.address; + ARDUINOJSON_ASSERT(d != NULL); + ARDUINOJSON_ASSERT(s != NULL); + while (n-- > 0) { + *d++ = pgm_read_byte(s++); + } + return dst; +} +#endif diff --git a/include/lib/ArduinoJson/Polyfills/pgmspace_generic.hpp b/include/lib/ArduinoJson/Polyfills/pgmspace_generic.hpp new file mode 100644 index 0000000..f5bbd85 --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/pgmspace_generic.hpp @@ -0,0 +1,32 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include +#include + +namespace ARDUINOJSON_NAMESPACE { + +template +typename enable_if::value, T>::type pgm_read(const void* p) { + return reinterpret_cast(pgm_read_ptr(p)); +} + +template +typename enable_if::value && + sizeof(T) == sizeof(float), // on AVR sizeof(double) == + // sizeof(float) + T>::type +pgm_read(const void* p) { + return pgm_read_float(p); +} + +template +typename enable_if::value, T>::type pgm_read( + const void* p) { + return pgm_read_dword(p); +} + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/preprocessor.hpp b/include/lib/ArduinoJson/Polyfills/preprocessor.hpp new file mode 100644 index 0000000..488654b --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/preprocessor.hpp @@ -0,0 +1,35 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#define ARDUINOJSON_EXPAND6(a, b, c, d, e, f) a, b, c, d, e, f +#define ARDUINOJSON_EXPAND9(a, b, c, d, e, f, g, h, i) a, b, c, d, e, f, g, h, i +#define ARDUINOJSON_EXPAND18(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, \ + q, r) \ + a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r + +#define ARDUINOJSON_CONCAT_(A, B) A##B +#define ARDUINOJSON_CONCAT2(A, B) ARDUINOJSON_CONCAT_(A, B) +#define ARDUINOJSON_CONCAT4(A, B, C, D) \ + ARDUINOJSON_CONCAT2(ARDUINOJSON_CONCAT2(A, B), ARDUINOJSON_CONCAT2(C, D)) + +#define ARDUINOJSON_HEX_DIGIT_0000() 0 +#define ARDUINOJSON_HEX_DIGIT_0001() 1 +#define ARDUINOJSON_HEX_DIGIT_0010() 2 +#define ARDUINOJSON_HEX_DIGIT_0011() 3 +#define ARDUINOJSON_HEX_DIGIT_0100() 4 +#define ARDUINOJSON_HEX_DIGIT_0101() 5 +#define ARDUINOJSON_HEX_DIGIT_0110() 6 +#define ARDUINOJSON_HEX_DIGIT_0111() 7 +#define ARDUINOJSON_HEX_DIGIT_1000() 8 +#define ARDUINOJSON_HEX_DIGIT_1001() 9 +#define ARDUINOJSON_HEX_DIGIT_1010() A +#define ARDUINOJSON_HEX_DIGIT_1011() B +#define ARDUINOJSON_HEX_DIGIT_1100() C +#define ARDUINOJSON_HEX_DIGIT_1101() D +#define ARDUINOJSON_HEX_DIGIT_1110() E +#define ARDUINOJSON_HEX_DIGIT_1111() F +#define ARDUINOJSON_HEX_DIGIT_(A, B, C, D) ARDUINOJSON_HEX_DIGIT_##A##B##C##D() +#define ARDUINOJSON_HEX_DIGIT(A, B, C, D) ARDUINOJSON_HEX_DIGIT_(A, B, C, D) diff --git a/include/lib/ArduinoJson/Polyfills/safe_strcmp.hpp b/include/lib/ArduinoJson/Polyfills/safe_strcmp.hpp new file mode 100644 index 0000000..e017b5d --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/safe_strcmp.hpp @@ -0,0 +1,32 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include + +#include // int8_t + +namespace ARDUINOJSON_NAMESPACE { + +inline int safe_strcmp(const char* a, const char* b) { + if (a == b) + return 0; + if (!a) + return -1; + if (!b) + return 1; + return strcmp(a, b); +} + +inline int safe_strncmp(const char* a, const char* b, size_t n) { + if (a == b) + return 0; + if (!a) + return -1; + if (!b) + return 1; + return strncmp(a, b, n); +} +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/static_array.hpp b/include/lib/ArduinoJson/Polyfills/static_array.hpp new file mode 100644 index 0000000..a877b4c --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/static_array.hpp @@ -0,0 +1,34 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include + +#if ARDUINOJSON_ENABLE_PROGMEM + +#include + +#ifndef ARDUINOJSON_DEFINE_STATIC_ARRAY +#define ARDUINOJSON_DEFINE_STATIC_ARRAY(type, name, value) \ + static type const name[] PROGMEM = value; +#endif + +#ifndef ARDUINOJSON_READ_STATIC_ARRAY +#define ARDUINOJSON_READ_STATIC_ARRAY(type, name, index) \ + pgm_read(name + index) +#endif + +#else // i.e. ARDUINOJSON_ENABLE_PROGMEM == 0 + +#ifndef ARDUINOJSON_DEFINE_STATIC_ARRAY +#define ARDUINOJSON_DEFINE_STATIC_ARRAY(type, name, value) \ + static type const name[] = value; +#endif + +#ifndef ARDUINOJSON_READ_STATIC_ARRAY +#define ARDUINOJSON_READ_STATIC_ARRAY(type, name, index) name[index] +#endif + +#endif diff --git a/include/lib/ArduinoJson/Polyfills/type_traits.hpp b/include/lib/ArduinoJson/Polyfills/type_traits.hpp new file mode 100644 index 0000000..4a8ff4b --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/type_traits.hpp @@ -0,0 +1,24 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include "type_traits/conditional.hpp" +#include "type_traits/enable_if.hpp" +#include "type_traits/integral_constant.hpp" +#include "type_traits/is_array.hpp" +#include "type_traits/is_base_of.hpp" +#include "type_traits/is_class.hpp" +#include "type_traits/is_const.hpp" +#include "type_traits/is_convertible.hpp" +#include "type_traits/is_enum.hpp" +#include "type_traits/is_floating_point.hpp" +#include "type_traits/is_integral.hpp" +#include "type_traits/is_pointer.hpp" +#include "type_traits/is_same.hpp" +#include "type_traits/is_signed.hpp" +#include "type_traits/is_unsigned.hpp" +#include "type_traits/make_unsigned.hpp" +#include "type_traits/remove_const.hpp" +#include "type_traits/remove_reference.hpp" diff --git a/include/lib/ArduinoJson/Polyfills/type_traits/conditional.hpp b/include/lib/ArduinoJson/Polyfills/type_traits/conditional.hpp new file mode 100644 index 0000000..e42d1bb --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/type_traits/conditional.hpp @@ -0,0 +1,20 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include + +namespace ARDUINOJSON_NAMESPACE { + +template +struct conditional { + typedef TrueType type; +}; + +template +struct conditional { + typedef FalseType type; +}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/type_traits/declval.hpp b/include/lib/ArduinoJson/Polyfills/type_traits/declval.hpp new file mode 100644 index 0000000..8708112 --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/type_traits/declval.hpp @@ -0,0 +1,14 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include + +namespace ARDUINOJSON_NAMESPACE { + +template +T declval(); + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/type_traits/enable_if.hpp b/include/lib/ArduinoJson/Polyfills/type_traits/enable_if.hpp new file mode 100644 index 0000000..cc29b33 --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/type_traits/enable_if.hpp @@ -0,0 +1,19 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include + +namespace ARDUINOJSON_NAMESPACE { + +// A meta-function that return the type T if Condition is true. +template +struct enable_if {}; + +template +struct enable_if { + typedef T type; +}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/type_traits/integral_constant.hpp b/include/lib/ArduinoJson/Polyfills/type_traits/integral_constant.hpp new file mode 100644 index 0000000..b53d711 --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/type_traits/integral_constant.hpp @@ -0,0 +1,19 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include + +namespace ARDUINOJSON_NAMESPACE { + +template +struct integral_constant { + static const T value = v; +}; + +typedef integral_constant true_type; +typedef integral_constant false_type; + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/type_traits/is_array.hpp b/include/lib/ArduinoJson/Polyfills/type_traits/is_array.hpp new file mode 100644 index 0000000..ee739a7 --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/type_traits/is_array.hpp @@ -0,0 +1,21 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include + +#include // size_t + +namespace ARDUINOJSON_NAMESPACE { + +template +struct is_array : false_type {}; + +template +struct is_array : true_type {}; + +template +struct is_array : true_type {}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/type_traits/is_base_of.hpp b/include/lib/ArduinoJson/Polyfills/type_traits/is_base_of.hpp new file mode 100644 index 0000000..32b41cd --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/type_traits/is_base_of.hpp @@ -0,0 +1,26 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include + +namespace ARDUINOJSON_NAMESPACE { + +// A meta-function that returns true if Derived inherits from TBase is an +// integral type. +template +class is_base_of { + protected: // <- to avoid GCC's "all member functions in class are private" + typedef char Yes[1]; + typedef char No[2]; + + static Yes &probe(const TBase *); + static No &probe(...); + + public: + static const bool value = + sizeof(probe(reinterpret_cast(0))) == sizeof(Yes); +}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/type_traits/is_class.hpp b/include/lib/ArduinoJson/Polyfills/type_traits/is_class.hpp new file mode 100644 index 0000000..a3808f3 --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/type_traits/is_class.hpp @@ -0,0 +1,26 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include "declval.hpp" + +namespace ARDUINOJSON_NAMESPACE { + +template +struct is_class { + protected: // <- to avoid GCC's "all member functions in class are private" + typedef char Yes[1]; + typedef char No[2]; + + template + static Yes &probe(void (U::*)(void)); + template + static No &probe(...); + + public: + static const bool value = sizeof(probe(0)) == sizeof(Yes); +}; + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/type_traits/is_const.hpp b/include/lib/ArduinoJson/Polyfills/type_traits/is_const.hpp new file mode 100644 index 0000000..32e758c --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/type_traits/is_const.hpp @@ -0,0 +1,17 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include "integral_constant.hpp" + +namespace ARDUINOJSON_NAMESPACE { + +// A meta-function that return the type T without the const modifier +template +struct is_const : false_type {}; + +template +struct is_const : true_type {}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/type_traits/is_convertible.hpp b/include/lib/ArduinoJson/Polyfills/type_traits/is_convertible.hpp new file mode 100644 index 0000000..847525a --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/type_traits/is_convertible.hpp @@ -0,0 +1,47 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include "declval.hpp" + +#ifdef _MSC_VER +#pragma warning(push) +// conversion from 'T' to 'To', possible loss of data +#pragma warning(disable : 4244) +#endif + +// clang-format off +#ifdef __ICCARM__ +// Suppress IAR Compiler Warning[Pa093]: implicit conversion from floating point to integer +#pragma diag_suppress=Pa093 +#endif +// clang-format on + +namespace ARDUINOJSON_NAMESPACE { + +template +struct is_convertible { + protected: // <- to avoid GCC's "all member functions in class are private" + typedef char Yes[1]; + typedef char No[2]; + + static Yes &probe(To); + static No &probe(...); + + public: + static const bool value = sizeof(probe(declval())) == sizeof(Yes); +}; + +} // namespace ARDUINOJSON_NAMESPACE + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +// clang-format off +#ifdef __ICCARM__ +#pragma diag_default=Pa093 +#endif +// clang-format on diff --git a/include/lib/ArduinoJson/Polyfills/type_traits/is_enum.hpp b/include/lib/ArduinoJson/Polyfills/type_traits/is_enum.hpp new file mode 100644 index 0000000..26aec1d --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/type_traits/is_enum.hpp @@ -0,0 +1,22 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include "is_class.hpp" +#include "is_convertible.hpp" +#include "is_floating_point.hpp" +#include "is_integral.hpp" +#include "is_same.hpp" + +namespace ARDUINOJSON_NAMESPACE { + +template +struct is_enum { + static const bool value = is_convertible::value && + !is_class::value && !is_integral::value && + !is_floating_point::value; +}; + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/type_traits/is_floating_point.hpp b/include/lib/ArduinoJson/Polyfills/type_traits/is_floating_point.hpp new file mode 100644 index 0000000..b7e9d3d --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/type_traits/is_floating_point.hpp @@ -0,0 +1,19 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include "integral_constant.hpp" + +namespace ARDUINOJSON_NAMESPACE { + +template +struct is_floating_point : false_type {}; + +template <> +struct is_floating_point : true_type {}; + +template <> +struct is_floating_point : true_type {}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/type_traits/is_integral.hpp b/include/lib/ArduinoJson/Polyfills/type_traits/is_integral.hpp new file mode 100644 index 0000000..26e895c --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/type_traits/is_integral.hpp @@ -0,0 +1,33 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include +#include "is_same.hpp" + +namespace ARDUINOJSON_NAMESPACE { + +// A meta-function that returns true if T is an integral type. +template +struct is_integral { + static const bool value = + is_same::value || is_same::value || + is_same::value || is_same::value || + is_same::value || is_same::value || + is_same::value || is_same::value || +#if ARDUINOJSON_HAS_LONG_LONG + is_same::value || + is_same::value || +#endif +#if ARDUINOJSON_HAS_INT64 + is_same::value || + is_same::value || +#endif + is_same::value || is_same::value; +}; + +template +struct is_integral : is_integral {}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/type_traits/is_pointer.hpp b/include/lib/ArduinoJson/Polyfills/type_traits/is_pointer.hpp new file mode 100644 index 0000000..a249539 --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/type_traits/is_pointer.hpp @@ -0,0 +1,16 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include "integral_constant.hpp" + +namespace ARDUINOJSON_NAMESPACE { + +template +struct is_pointer : false_type {}; + +template +struct is_pointer : true_type {}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/type_traits/is_same.hpp b/include/lib/ArduinoJson/Polyfills/type_traits/is_same.hpp new file mode 100644 index 0000000..db5da9b --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/type_traits/is_same.hpp @@ -0,0 +1,17 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include "integral_constant.hpp" + +namespace ARDUINOJSON_NAMESPACE { + +// A meta-function that returns true if types T and U are the same. +template +struct is_same : false_type {}; + +template +struct is_same : true_type {}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/type_traits/is_signed.hpp b/include/lib/ArduinoJson/Polyfills/type_traits/is_signed.hpp new file mode 100644 index 0000000..fbb701c --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/type_traits/is_signed.hpp @@ -0,0 +1,43 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include "integral_constant.hpp" +namespace ARDUINOJSON_NAMESPACE { + +template +struct is_signed : false_type {}; + +template <> +struct is_signed : true_type {}; + +template <> +struct is_signed : true_type {}; + +template <> +struct is_signed : true_type {}; + +template <> +struct is_signed : true_type {}; + +template <> +struct is_signed : true_type {}; + +template <> +struct is_signed : true_type {}; + +template <> +struct is_signed : true_type {}; + +#if ARDUINOJSON_HAS_LONG_LONG +template <> +struct is_signed : true_type {}; +#endif + +#if ARDUINOJSON_HAS_INT64 +template <> +struct is_signed : true_type {}; +#endif +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/type_traits/is_unsigned.hpp b/include/lib/ArduinoJson/Polyfills/type_traits/is_unsigned.hpp new file mode 100644 index 0000000..be26498 --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/type_traits/is_unsigned.hpp @@ -0,0 +1,37 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include "integral_constant.hpp" +namespace ARDUINOJSON_NAMESPACE { + +template +struct is_unsigned : false_type {}; + +template <> +struct is_unsigned : true_type {}; + +template <> +struct is_unsigned : true_type {}; + +template <> +struct is_unsigned : true_type {}; + +template <> +struct is_unsigned : true_type {}; + +template <> +struct is_unsigned : true_type {}; + +#if ARDUINOJSON_HAS_INT64 +template <> +struct is_unsigned : true_type {}; +#endif + +#if ARDUINOJSON_HAS_LONG_LONG +template <> +struct is_unsigned : true_type {}; +#endif +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/type_traits/make_unsigned.hpp b/include/lib/ArduinoJson/Polyfills/type_traits/make_unsigned.hpp new file mode 100644 index 0000000..4cf2d08 --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/type_traits/make_unsigned.hpp @@ -0,0 +1,49 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include "type_identity.hpp" +namespace ARDUINOJSON_NAMESPACE { + +template +struct make_unsigned; + +template <> +struct make_unsigned : type_identity {}; + +template <> +struct make_unsigned : type_identity {}; +template <> +struct make_unsigned : type_identity {}; + +template <> +struct make_unsigned : type_identity {}; +template <> +struct make_unsigned : type_identity {}; + +template <> +struct make_unsigned : type_identity {}; +template <> +struct make_unsigned : type_identity {}; + +template <> +struct make_unsigned : type_identity {}; +template <> +struct make_unsigned : type_identity {}; + +#if ARDUINOJSON_HAS_LONG_LONG +template <> +struct make_unsigned : type_identity {}; +template <> +struct make_unsigned : type_identity {}; +#endif + +#if ARDUINOJSON_HAS_INT64 +template <> +struct make_unsigned : type_identity {}; +template <> +struct make_unsigned : type_identity {}; +#endif +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/type_traits/remove_const.hpp b/include/lib/ArduinoJson/Polyfills/type_traits/remove_const.hpp new file mode 100644 index 0000000..5a19eb1 --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/type_traits/remove_const.hpp @@ -0,0 +1,20 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include + +namespace ARDUINOJSON_NAMESPACE { + +// A meta-function that return the type T without the const modifier +template +struct remove_const { + typedef T type; +}; +template +struct remove_const { + typedef T type; +}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/type_traits/remove_reference.hpp b/include/lib/ArduinoJson/Polyfills/type_traits/remove_reference.hpp new file mode 100644 index 0000000..1812850 --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/type_traits/remove_reference.hpp @@ -0,0 +1,20 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include + +namespace ARDUINOJSON_NAMESPACE { + +// A meta-function that return the type T without the reference modifier. +template +struct remove_reference { + typedef T type; +}; +template +struct remove_reference { + typedef T type; +}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/type_traits/type_identity.hpp b/include/lib/ArduinoJson/Polyfills/type_traits/type_identity.hpp new file mode 100644 index 0000000..c464a47 --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/type_traits/type_identity.hpp @@ -0,0 +1,15 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include "integral_constant.hpp" + +namespace ARDUINOJSON_NAMESPACE { + +template +struct type_identity { + typedef T type; +}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/include/lib/ArduinoJson/Polyfills/utility.hpp b/include/lib/ArduinoJson/Polyfills/utility.hpp new file mode 100644 index 0000000..c99bc99 --- /dev/null +++ b/include/lib/ArduinoJson/Polyfills/utility.hpp @@ -0,0 +1,28 @@ +// ArduinoJson - https://arduinojson.org +// Copyright Benoit Blanchon 2014-2021 +// MIT License + +#pragma once + +#include "type_traits.hpp" + +namespace ARDUINOJSON_NAMESPACE { +template +inline void swap(T& a, T& b) { + T t(a); + a = b; + b = t; +} + +#if ARDUINOJSON_HAS_RVALUE_REFERENCES +template +typename remove_reference::type&& move(T&& t) { + return static_cast::type&&>(t); +} +#else +template +T& move(T& t) { + return t; +} +#endif +} // namespace ARDUINOJSON_NAMESPACE -- cgit v1.2.3