forked from bblanchon/ArduinoJson
Rename Float
to JsonFloat
This commit is contained in:
@ -49,7 +49,7 @@
|
|||||||
namespace ArduinoJson {
|
namespace ArduinoJson {
|
||||||
using ARDUINOJSON_NAMESPACE::JsonArray;
|
using ARDUINOJSON_NAMESPACE::JsonArray;
|
||||||
using ARDUINOJSON_NAMESPACE::JsonArrayConst;
|
using ARDUINOJSON_NAMESPACE::JsonArrayConst;
|
||||||
typedef ARDUINOJSON_NAMESPACE::Float JsonFloat;
|
using ARDUINOJSON_NAMESPACE::JsonFloat;
|
||||||
typedef ARDUINOJSON_NAMESPACE::Integer JsonInteger;
|
typedef ARDUINOJSON_NAMESPACE::Integer JsonInteger;
|
||||||
using ARDUINOJSON_NAMESPACE::JsonObject;
|
using ARDUINOJSON_NAMESPACE::JsonObject;
|
||||||
using ARDUINOJSON_NAMESPACE::JsonObjectConst;
|
using ARDUINOJSON_NAMESPACE::JsonObjectConst;
|
||||||
|
@ -58,7 +58,7 @@ class JsonSerializer : public Visitor<size_t> {
|
|||||||
return bytesWritten();
|
return bytesWritten();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t visitFloat(Float value) {
|
size_t visitFloat(JsonFloat value) {
|
||||||
_formatter.writeFloat(value);
|
_formatter.writeFloat(value);
|
||||||
return bytesWritten();
|
return bytesWritten();
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
namespace ARDUINOJSON_NAMESPACE {
|
namespace ARDUINOJSON_NAMESPACE {
|
||||||
|
|
||||||
#if ARDUINOJSON_USE_DOUBLE
|
#if ARDUINOJSON_USE_DOUBLE
|
||||||
typedef double Float;
|
typedef double JsonFloat;
|
||||||
#else
|
#else
|
||||||
typedef float Float;
|
typedef float JsonFloat;
|
||||||
#endif
|
#endif
|
||||||
} // namespace ARDUINOJSON_NAMESPACE
|
} // namespace ARDUINOJSON_NAMESPACE
|
@ -14,8 +14,8 @@
|
|||||||
# pragma GCC diagnostic ignored "-Wconversion"
|
# pragma GCC diagnostic ignored "-Wconversion"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <ArduinoJson/Numbers/Float.hpp>
|
|
||||||
#include <ArduinoJson/Numbers/FloatTraits.hpp>
|
#include <ArduinoJson/Numbers/FloatTraits.hpp>
|
||||||
|
#include <ArduinoJson/Numbers/JsonFloat.hpp>
|
||||||
#include <ArduinoJson/Polyfills/limits.hpp>
|
#include <ArduinoJson/Polyfills/limits.hpp>
|
||||||
#include <ArduinoJson/Polyfills/type_traits.hpp>
|
#include <ArduinoJson/Polyfills/type_traits.hpp>
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ template <typename A, typename B>
|
|||||||
struct choose_largest : conditional<(sizeof(A) > sizeof(B)), A, B> {};
|
struct choose_largest : conditional<(sizeof(A) > sizeof(B)), A, B> {};
|
||||||
|
|
||||||
inline bool parseNumber(const char* s, VariantData& result) {
|
inline bool parseNumber(const char* s, VariantData& result) {
|
||||||
typedef FloatTraits<Float> traits;
|
typedef FloatTraits<JsonFloat> traits;
|
||||||
typedef choose_largest<traits::mantissa_type, UInt>::type mantissa_t;
|
typedef choose_largest<traits::mantissa_type, UInt>::type mantissa_t;
|
||||||
typedef traits::exponent_type exponent_t;
|
typedef traits::exponent_type exponent_t;
|
||||||
|
|
||||||
@ -136,8 +136,8 @@ inline bool parseNumber(const char* s, VariantData& result) {
|
|||||||
if (*s != '\0')
|
if (*s != '\0')
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Float final_result =
|
JsonFloat final_result =
|
||||||
traits::make_float(static_cast<Float>(mantissa), exponent);
|
traits::make_float(static_cast<JsonFloat>(mantissa), exponent);
|
||||||
|
|
||||||
result.setFloat(is_negative ? -final_result : final_result);
|
result.setFloat(is_negative ? -final_result : final_result);
|
||||||
return true;
|
return true;
|
||||||
|
@ -101,7 +101,7 @@ struct Converter<T, typename enable_if<is_floating_point<T>::value>::type>
|
|||||||
static void toJson(T src, VariantRef dst) {
|
static void toJson(T src, VariantRef dst) {
|
||||||
VariantData* data = getData(dst);
|
VariantData* data = getData(dst);
|
||||||
if (data)
|
if (data)
|
||||||
data->setFloat(static_cast<Float>(src));
|
data->setFloat(static_cast<JsonFloat>(src));
|
||||||
}
|
}
|
||||||
|
|
||||||
static T fromJson(VariantConstRef src) {
|
static T fromJson(VariantConstRef src) {
|
||||||
|
@ -52,7 +52,7 @@ struct Comparer<T, typename enable_if<is_integral<T>::value ||
|
|||||||
|
|
||||||
explicit Comparer(T value) : rhs(value) {}
|
explicit Comparer(T value) : rhs(value) {}
|
||||||
|
|
||||||
CompareResult visitFloat(Float lhs) {
|
CompareResult visitFloat(JsonFloat lhs) {
|
||||||
return arithmeticCompare(lhs, rhs);
|
return arithmeticCompare(lhs, rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,8 +142,8 @@ struct VariantComparer : ComparerBase {
|
|||||||
return accept(comparer);
|
return accept(comparer);
|
||||||
}
|
}
|
||||||
|
|
||||||
CompareResult visitFloat(Float lhs) {
|
CompareResult visitFloat(JsonFloat lhs) {
|
||||||
Comparer<Float> comparer(lhs);
|
Comparer<JsonFloat> 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/Float.hpp>
|
|
||||||
#include <ArduinoJson/Numbers/Integer.hpp>
|
#include <ArduinoJson/Numbers/Integer.hpp>
|
||||||
|
#include <ArduinoJson/Numbers/JsonFloat.hpp>
|
||||||
|
|
||||||
namespace ARDUINOJSON_NAMESPACE {
|
namespace ARDUINOJSON_NAMESPACE {
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ struct RawData {
|
|||||||
};
|
};
|
||||||
|
|
||||||
union VariantContent {
|
union VariantContent {
|
||||||
Float asFloat;
|
JsonFloat asFloat;
|
||||||
bool asBoolean;
|
bool asBoolean;
|
||||||
UInt asUnsignedInteger;
|
UInt asUnsignedInteger;
|
||||||
Integer asSignedInteger;
|
Integer asSignedInteger;
|
||||||
|
@ -172,7 +172,7 @@ class VariantData {
|
|||||||
_content.asBoolean = value;
|
_content.asBoolean = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setFloat(Float value) {
|
void setFloat(JsonFloat value) {
|
||||||
setType(VALUE_IS_FLOAT);
|
setType(VALUE_IS_FLOAT);
|
||||||
_content.asFloat = value;
|
_content.asFloat = value;
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <ArduinoJson/Collection/CollectionData.hpp>
|
#include <ArduinoJson/Collection/CollectionData.hpp>
|
||||||
#include <ArduinoJson/Numbers/Float.hpp>
|
|
||||||
#include <ArduinoJson/Numbers/Integer.hpp>
|
#include <ArduinoJson/Numbers/Integer.hpp>
|
||||||
|
#include <ArduinoJson/Numbers/JsonFloat.hpp>
|
||||||
|
|
||||||
namespace ARDUINOJSON_NAMESPACE {
|
namespace ARDUINOJSON_NAMESPACE {
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ struct Visitor {
|
|||||||
return TResult();
|
return TResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
TResult visitFloat(Float) {
|
TResult visitFloat(JsonFloat) {
|
||||||
return TResult();
|
return TResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user