mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-18 21:12:25 +02:00
Rename Integer
to JsonInteger
This commit is contained in:
@ -13,7 +13,7 @@ TEST_CASE("Test unsigned integer overflow") {
|
|||||||
second.init();
|
second.init();
|
||||||
|
|
||||||
// Avoids MSVC warning C4127 (conditional expression is constant)
|
// Avoids MSVC warning C4127 (conditional expression is constant)
|
||||||
size_t integerSize = sizeof(Integer);
|
size_t integerSize = sizeof(JsonInteger);
|
||||||
|
|
||||||
if (integerSize == 8) {
|
if (integerSize == 8) {
|
||||||
parseNumber("18446744073709551615", first);
|
parseNumber("18446744073709551615", first);
|
||||||
@ -33,7 +33,7 @@ TEST_CASE("Test signed integer overflow") {
|
|||||||
second.init();
|
second.init();
|
||||||
|
|
||||||
// Avoids MSVC warning C4127 (conditional expression is constant)
|
// Avoids MSVC warning C4127 (conditional expression is constant)
|
||||||
size_t integerSize = sizeof(Integer);
|
size_t integerSize = sizeof(JsonInteger);
|
||||||
|
|
||||||
if (integerSize == 8) {
|
if (integerSize == 8) {
|
||||||
parseNumber("-9223372036854775808", first);
|
parseNumber("-9223372036854775808", first);
|
||||||
|
@ -50,7 +50,7 @@ namespace ArduinoJson {
|
|||||||
using ARDUINOJSON_NAMESPACE::JsonArray;
|
using ARDUINOJSON_NAMESPACE::JsonArray;
|
||||||
using ARDUINOJSON_NAMESPACE::JsonArrayConst;
|
using ARDUINOJSON_NAMESPACE::JsonArrayConst;
|
||||||
using ARDUINOJSON_NAMESPACE::JsonFloat;
|
using ARDUINOJSON_NAMESPACE::JsonFloat;
|
||||||
typedef ARDUINOJSON_NAMESPACE::Integer JsonInteger;
|
using ARDUINOJSON_NAMESPACE::JsonInteger;
|
||||||
using ARDUINOJSON_NAMESPACE::JsonObject;
|
using ARDUINOJSON_NAMESPACE::JsonObject;
|
||||||
using ARDUINOJSON_NAMESPACE::JsonObjectConst;
|
using ARDUINOJSON_NAMESPACE::JsonObjectConst;
|
||||||
using ARDUINOJSON_NAMESPACE::JsonPair;
|
using ARDUINOJSON_NAMESPACE::JsonPair;
|
||||||
|
@ -78,7 +78,7 @@ class JsonSerializer : public Visitor<size_t> {
|
|||||||
return bytesWritten();
|
return bytesWritten();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t visitSignedInteger(Integer value) {
|
size_t visitSignedInteger(JsonInteger value) {
|
||||||
_formatter.writeInteger(value);
|
_formatter.writeInteger(value);
|
||||||
return bytesWritten();
|
return bytesWritten();
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include <ArduinoJson/Json/EscapeSequence.hpp>
|
#include <ArduinoJson/Json/EscapeSequence.hpp>
|
||||||
#include <ArduinoJson/Numbers/FloatParts.hpp>
|
#include <ArduinoJson/Numbers/FloatParts.hpp>
|
||||||
#include <ArduinoJson/Numbers/Integer.hpp>
|
#include <ArduinoJson/Numbers/JsonInteger.hpp>
|
||||||
#include <ArduinoJson/Polyfills/assert.hpp>
|
#include <ArduinoJson/Polyfills/assert.hpp>
|
||||||
#include <ArduinoJson/Polyfills/attributes.hpp>
|
#include <ArduinoJson/Polyfills/attributes.hpp>
|
||||||
#include <ArduinoJson/Polyfills/type_traits.hpp>
|
#include <ArduinoJson/Polyfills/type_traits.hpp>
|
||||||
|
@ -23,8 +23,8 @@ class MsgPackSerializer : public Visitor<size_t> {
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
typename enable_if<sizeof(T) == 4, size_t>::type visitFloat(T value32) {
|
typename enable_if<sizeof(T) == 4, size_t>::type visitFloat(T value32) {
|
||||||
if (canConvertNumber<Integer>(value32)) {
|
if (canConvertNumber<JsonInteger>(value32)) {
|
||||||
Integer truncatedValue = Integer(value32);
|
JsonInteger truncatedValue = JsonInteger(value32);
|
||||||
if (value32 == T(truncatedValue))
|
if (value32 == T(truncatedValue))
|
||||||
return visitSignedInteger(truncatedValue);
|
return visitSignedInteger(truncatedValue);
|
||||||
}
|
}
|
||||||
@ -107,7 +107,7 @@ class MsgPackSerializer : public Visitor<size_t> {
|
|||||||
return bytesWritten();
|
return bytesWritten();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t visitSignedInteger(Integer value) {
|
size_t visitSignedInteger(JsonInteger value) {
|
||||||
if (value > 0) {
|
if (value > 0) {
|
||||||
visitUnsignedInteger(static_cast<UInt>(value));
|
visitUnsignedInteger(static_cast<UInt>(value));
|
||||||
} else if (value >= -0x20) {
|
} else if (value >= -0x20) {
|
||||||
|
@ -12,10 +12,10 @@
|
|||||||
namespace ARDUINOJSON_NAMESPACE {
|
namespace ARDUINOJSON_NAMESPACE {
|
||||||
|
|
||||||
#if ARDUINOJSON_USE_LONG_LONG
|
#if ARDUINOJSON_USE_LONG_LONG
|
||||||
typedef int64_t Integer;
|
typedef int64_t JsonInteger;
|
||||||
typedef uint64_t UInt;
|
typedef uint64_t UInt;
|
||||||
#else
|
#else
|
||||||
typedef long Integer;
|
typedef long JsonInteger;
|
||||||
typedef unsigned long UInt;
|
typedef unsigned long UInt;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ typedef unsigned long UInt;
|
|||||||
|
|
||||||
#if ARDUINOJSON_HAS_LONG_LONG && !ARDUINOJSON_USE_LONG_LONG
|
#if ARDUINOJSON_HAS_LONG_LONG && !ARDUINOJSON_USE_LONG_LONG
|
||||||
# define ARDUINOJSON_ASSERT_INTEGER_TYPE_IS_SUPPORTED(T) \
|
# define ARDUINOJSON_ASSERT_INTEGER_TYPE_IS_SUPPORTED(T) \
|
||||||
static_assert(sizeof(T) <= sizeof(ARDUINOJSON_NAMESPACE::Integer), \
|
static_assert(sizeof(T) <= sizeof(ARDUINOJSON_NAMESPACE::JsonInteger), \
|
||||||
"To use 64-bit integers with ArduinoJson, you must set " \
|
"To use 64-bit integers with ArduinoJson, you must set " \
|
||||||
"ARDUINOJSON_USE_LONG_LONG to 1. See " \
|
"ARDUINOJSON_USE_LONG_LONG to 1. See " \
|
||||||
"https://arduinojson.org/v6/api/config/use_long_long/");
|
"https://arduinojson.org/v6/api/config/use_long_long/");
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <ArduinoJson/Numbers/Integer.hpp>
|
#include <ArduinoJson/Numbers/JsonInteger.hpp>
|
||||||
#include <ArduinoJson/Polyfills/type_traits.hpp>
|
#include <ArduinoJson/Polyfills/type_traits.hpp>
|
||||||
|
|
||||||
namespace ARDUINOJSON_NAMESPACE {
|
namespace ARDUINOJSON_NAMESPACE {
|
||||||
|
@ -71,9 +71,9 @@ inline bool parseNumber(const char* s, VariantData& result) {
|
|||||||
if (*s == '\0') {
|
if (*s == '\0') {
|
||||||
if (is_negative) {
|
if (is_negative) {
|
||||||
const mantissa_t sintMantissaMax = mantissa_t(1)
|
const mantissa_t sintMantissaMax = mantissa_t(1)
|
||||||
<< (sizeof(Integer) * 8 - 1);
|
<< (sizeof(JsonInteger) * 8 - 1);
|
||||||
if (mantissa <= sintMantissaMax) {
|
if (mantissa <= sintMantissaMax) {
|
||||||
result.setInteger(Integer(~mantissa + 1));
|
result.setInteger(JsonInteger(~mantissa + 1));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -62,7 +62,7 @@ template <typename T>
|
|||||||
struct Converter<T, typename enable_if<is_enum<T>::value>::type>
|
struct Converter<T, typename enable_if<is_enum<T>::value>::type>
|
||||||
: private VariantAttorney {
|
: private VariantAttorney {
|
||||||
static void toJson(T src, VariantRef dst) {
|
static void toJson(T src, VariantRef dst) {
|
||||||
dst.set(static_cast<Integer>(src));
|
dst.set(static_cast<JsonInteger>(src));
|
||||||
}
|
}
|
||||||
|
|
||||||
static T fromJson(VariantConstRef src) {
|
static T fromJson(VariantConstRef src) {
|
||||||
|
@ -56,7 +56,7 @@ struct Comparer<T, typename enable_if<is_integral<T>::value ||
|
|||||||
return arithmeticCompare(lhs, rhs);
|
return arithmeticCompare(lhs, rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
CompareResult visitSignedInteger(Integer lhs) {
|
CompareResult visitSignedInteger(JsonInteger lhs) {
|
||||||
return arithmeticCompare(lhs, rhs);
|
return arithmeticCompare(lhs, rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,8 +157,8 @@ struct VariantComparer : ComparerBase {
|
|||||||
return accept(comparer);
|
return accept(comparer);
|
||||||
}
|
}
|
||||||
|
|
||||||
CompareResult visitSignedInteger(Integer lhs) {
|
CompareResult visitSignedInteger(JsonInteger lhs) {
|
||||||
Comparer<Integer> comparer(lhs);
|
Comparer<JsonInteger> comparer(lhs);
|
||||||
return accept(comparer);
|
return accept(comparer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
#include <stddef.h> // size_t
|
#include <stddef.h> // size_t
|
||||||
|
|
||||||
#include <ArduinoJson/Collection/CollectionData.hpp>
|
#include <ArduinoJson/Collection/CollectionData.hpp>
|
||||||
#include <ArduinoJson/Numbers/Integer.hpp>
|
|
||||||
#include <ArduinoJson/Numbers/JsonFloat.hpp>
|
#include <ArduinoJson/Numbers/JsonFloat.hpp>
|
||||||
|
#include <ArduinoJson/Numbers/JsonInteger.hpp>
|
||||||
|
|
||||||
namespace ARDUINOJSON_NAMESPACE {
|
namespace ARDUINOJSON_NAMESPACE {
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ union VariantContent {
|
|||||||
JsonFloat asFloat;
|
JsonFloat asFloat;
|
||||||
bool asBoolean;
|
bool asBoolean;
|
||||||
UInt asUnsignedInteger;
|
UInt asUnsignedInteger;
|
||||||
Integer asSignedInteger;
|
JsonInteger asSignedInteger;
|
||||||
CollectionData asCollection;
|
CollectionData asCollection;
|
||||||
struct {
|
struct {
|
||||||
const char* data;
|
const char* data;
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <ArduinoJson/Collection/CollectionData.hpp>
|
#include <ArduinoJson/Collection/CollectionData.hpp>
|
||||||
#include <ArduinoJson/Numbers/Integer.hpp>
|
|
||||||
#include <ArduinoJson/Numbers/JsonFloat.hpp>
|
#include <ArduinoJson/Numbers/JsonFloat.hpp>
|
||||||
|
#include <ArduinoJson/Numbers/JsonInteger.hpp>
|
||||||
|
|
||||||
namespace ARDUINOJSON_NAMESPACE {
|
namespace ARDUINOJSON_NAMESPACE {
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ struct Visitor {
|
|||||||
return TResult();
|
return TResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
TResult visitSignedInteger(Integer) {
|
TResult visitSignedInteger(JsonInteger) {
|
||||||
return TResult();
|
return TResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user