mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-06-25 01:11:35 +02:00
Replace typedef
with using
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
|
||||
#include "Literals.hpp"
|
||||
|
||||
typedef ArduinoJson::detail::ElementProxy<JsonDocument&> ElementProxy;
|
||||
using ElementProxy = ArduinoJson::detail::ElementProxy<JsonDocument&>;
|
||||
|
||||
TEST_CASE("ElementProxy::add()") {
|
||||
JsonDocument doc;
|
||||
|
@ -14,8 +14,8 @@
|
||||
using ArduinoJson::detail::sizeofArray;
|
||||
using ArduinoJson::detail::sizeofObject;
|
||||
|
||||
typedef ArduinoJson::detail::MemberProxy<JsonDocument&, const char*>
|
||||
MemberProxy;
|
||||
using MemberProxy =
|
||||
ArduinoJson::detail::MemberProxy<JsonDocument&, const char*>;
|
||||
|
||||
TEST_CASE("MemberProxy::add()") {
|
||||
JsonDocument doc;
|
||||
|
@ -99,7 +99,7 @@ TEST_CASE("vector<int>") {
|
||||
}
|
||||
|
||||
TEST_CASE("array<int, 2>") {
|
||||
typedef std::array<int, 2> array_type;
|
||||
using array_type = std::array<int, 2>;
|
||||
|
||||
SECTION("toJson") {
|
||||
array_type v;
|
||||
|
@ -8,4 +8,4 @@
|
||||
|
||||
struct custom_char_traits : std::char_traits<char> {};
|
||||
|
||||
typedef std::basic_string<char, custom_char_traits> custom_string;
|
||||
using custom_string = std::basic_string<char, custom_char_traits>;
|
||||
|
@ -17,7 +17,7 @@ class JsonArray : public detail::VariantOperators<JsonArray> {
|
||||
friend class detail::VariantAttorney;
|
||||
|
||||
public:
|
||||
typedef JsonArrayIterator iterator;
|
||||
using iterator = JsonArrayIterator;
|
||||
|
||||
// Constructs an unbound reference.
|
||||
JsonArray() : data_(0), resources_(0) {}
|
||||
|
@ -19,7 +19,7 @@ class JsonArrayConst : public detail::VariantOperators<JsonArrayConst> {
|
||||
friend class detail::VariantAttorney;
|
||||
|
||||
public:
|
||||
typedef JsonArrayConstIterator iterator;
|
||||
using iterator = JsonArrayConstIterator;
|
||||
|
||||
// Returns an iterator to the first element of the array.
|
||||
// https://arduinojson.org/v7/api/jsonarrayconst/begin/
|
||||
|
@ -13,7 +13,7 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename TWriter>
|
||||
class PrettyJsonSerializer : public JsonSerializer<TWriter> {
|
||||
typedef JsonSerializer<TWriter> base;
|
||||
using base = JsonSerializer<TWriter>;
|
||||
|
||||
public:
|
||||
PrettyJsonSerializer(TWriter writer, const ResourceManager* resources)
|
||||
|
@ -105,7 +105,7 @@ class TextFormatter {
|
||||
|
||||
template <typename T>
|
||||
enable_if_t<is_signed<T>::value> writeInteger(T value) {
|
||||
typedef make_unsigned_t<T> unsigned_type;
|
||||
using unsigned_type = make_unsigned_t<T>;
|
||||
unsigned_type unsigned_value;
|
||||
if (value < 0) {
|
||||
writeRaw('-');
|
||||
|
@ -20,7 +20,7 @@ struct FloatParts {
|
||||
|
||||
template <typename TFloat>
|
||||
inline int16_t normalize(TFloat& value) {
|
||||
typedef FloatTraits<TFloat> traits;
|
||||
using traits = FloatTraits<TFloat>;
|
||||
int16_t powersOf10 = 0;
|
||||
|
||||
int8_t index = sizeof(TFloat) == 8 ? 8 : 5;
|
||||
|
@ -21,12 +21,12 @@ struct FloatTraits {};
|
||||
|
||||
template <typename T>
|
||||
struct FloatTraits<T, 8 /*64bits*/> {
|
||||
typedef uint64_t mantissa_type;
|
||||
using mantissa_type = uint64_t;
|
||||
static const short mantissa_bits = 52;
|
||||
static const mantissa_type mantissa_max =
|
||||
(mantissa_type(1) << mantissa_bits) - 1;
|
||||
|
||||
typedef int16_t exponent_type;
|
||||
using exponent_type = int16_t;
|
||||
static const exponent_type exponent_max = 308;
|
||||
|
||||
static pgm_ptr<T> positiveBinaryPowersOfTen() {
|
||||
@ -105,12 +105,12 @@ struct FloatTraits<T, 8 /*64bits*/> {
|
||||
|
||||
template <typename T>
|
||||
struct FloatTraits<T, 4 /*32bits*/> {
|
||||
typedef uint32_t mantissa_type;
|
||||
using mantissa_type = uint32_t;
|
||||
static const short mantissa_bits = 23;
|
||||
static const mantissa_type mantissa_max =
|
||||
(mantissa_type(1) << mantissa_bits) - 1;
|
||||
|
||||
typedef int8_t exponent_type;
|
||||
using exponent_type = int8_t;
|
||||
static const exponent_type exponent_max = 38;
|
||||
|
||||
static pgm_ptr<T> positiveBinaryPowersOfTen() {
|
||||
|
@ -10,9 +10,9 @@
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
#if ARDUINOJSON_USE_DOUBLE
|
||||
typedef double JsonFloat;
|
||||
using JsonFloat = double;
|
||||
#else
|
||||
typedef float JsonFloat;
|
||||
using JsonFloat = float;
|
||||
#endif
|
||||
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
@ -12,11 +12,11 @@
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
#if ARDUINOJSON_USE_LONG_LONG
|
||||
typedef int64_t JsonInteger;
|
||||
typedef uint64_t JsonUInt;
|
||||
using JsonInteger = int64_t;
|
||||
using JsonUInt = uint64_t;
|
||||
#else
|
||||
typedef long JsonInteger;
|
||||
typedef unsigned long JsonUInt;
|
||||
using JsonInteger = long;
|
||||
using JsonUInt = unsigned long;
|
||||
#endif
|
||||
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
@ -103,9 +103,9 @@ class Number {
|
||||
};
|
||||
|
||||
inline Number parseNumber(const char* s) {
|
||||
typedef FloatTraits<JsonFloat> traits;
|
||||
typedef largest_type<traits::mantissa_type, JsonUInt> mantissa_t;
|
||||
typedef traits::exponent_type exponent_t;
|
||||
using traits = FloatTraits<JsonFloat>;
|
||||
using mantissa_t = largest_type<traits::mantissa_type, JsonUInt>;
|
||||
using exponent_t = traits::exponent_type;
|
||||
|
||||
ARDUINOJSON_ASSERT(s != 0);
|
||||
|
||||
|
@ -17,7 +17,7 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
|
||||
friend class detail::VariantAttorney;
|
||||
|
||||
public:
|
||||
typedef JsonObjectIterator iterator;
|
||||
using iterator = JsonObjectIterator;
|
||||
|
||||
// Creates an unbound reference.
|
||||
JsonObject() : data_(0), resources_(0) {}
|
||||
|
@ -16,7 +16,7 @@ class JsonObjectConst : public detail::VariantOperators<JsonObjectConst> {
|
||||
friend class detail::VariantAttorney;
|
||||
|
||||
public:
|
||||
typedef JsonObjectConstIterator iterator;
|
||||
using iterator = JsonObjectConstIterator;
|
||||
|
||||
// Creates an unbound reference.
|
||||
JsonObjectConst() : data_(0), resources_(0) {}
|
||||
|
@ -15,17 +15,17 @@ struct uint_;
|
||||
|
||||
template <>
|
||||
struct uint_<8> {
|
||||
typedef uint8_t type;
|
||||
using type = uint8_t;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct uint_<16> {
|
||||
typedef uint16_t type;
|
||||
using type = uint16_t;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct uint_<32> {
|
||||
typedef uint32_t type;
|
||||
using type = uint32_t;
|
||||
};
|
||||
|
||||
template <int Bits>
|
||||
|
@ -10,12 +10,12 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <bool Condition, class TrueType, class FalseType>
|
||||
struct conditional {
|
||||
typedef TrueType type;
|
||||
using type = TrueType;
|
||||
};
|
||||
|
||||
template <class TrueType, class FalseType>
|
||||
struct conditional<false, TrueType, FalseType> {
|
||||
typedef FalseType type;
|
||||
using type = FalseType;
|
||||
};
|
||||
|
||||
template <bool Condition, class TrueType, class FalseType>
|
||||
|
@ -14,7 +14,7 @@ struct enable_if {};
|
||||
|
||||
template <typename T>
|
||||
struct enable_if<true, T> {
|
||||
typedef T type;
|
||||
using type = T;
|
||||
};
|
||||
|
||||
template <bool Condition, typename T = void>
|
||||
|
@ -11,11 +11,11 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
// A meta-function that return the type T without the const modifier
|
||||
template <typename T>
|
||||
struct remove_const {
|
||||
typedef T type;
|
||||
using type = T;
|
||||
};
|
||||
template <typename T>
|
||||
struct remove_const<const T> {
|
||||
typedef T type;
|
||||
using type = T;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
@ -10,19 +10,19 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename T>
|
||||
struct remove_cv {
|
||||
typedef T type;
|
||||
using type = T;
|
||||
};
|
||||
template <typename T>
|
||||
struct remove_cv<const T> {
|
||||
typedef T type;
|
||||
using type = T;
|
||||
};
|
||||
template <typename T>
|
||||
struct remove_cv<volatile T> {
|
||||
typedef T type;
|
||||
using type = T;
|
||||
};
|
||||
template <typename T>
|
||||
struct remove_cv<const volatile T> {
|
||||
typedef T type;
|
||||
using type = T;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
@ -11,11 +11,11 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
// A meta-function that return the type T without the reference modifier.
|
||||
template <typename T>
|
||||
struct remove_reference {
|
||||
typedef T type;
|
||||
using type = T;
|
||||
};
|
||||
template <typename T>
|
||||
struct remove_reference<T&> {
|
||||
typedef T type;
|
||||
using type = T;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
@ -10,7 +10,7 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename T>
|
||||
struct type_identity {
|
||||
typedef T type;
|
||||
using type = T;
|
||||
};
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
@ -74,7 +74,7 @@ class FlashString {
|
||||
|
||||
template <>
|
||||
struct StringAdapter<const __FlashStringHelper*, void> {
|
||||
typedef FlashString AdaptedString;
|
||||
using AdaptedString = FlashString;
|
||||
|
||||
static AdaptedString adapt(const __FlashStringHelper* s) {
|
||||
return AdaptedString(s, s ? strlen_P(reinterpret_cast<const char*>(s)) : 0);
|
||||
@ -83,7 +83,7 @@ struct StringAdapter<const __FlashStringHelper*, void> {
|
||||
|
||||
template <>
|
||||
struct SizedStringAdapter<const __FlashStringHelper*, void> {
|
||||
typedef FlashString AdaptedString;
|
||||
using AdaptedString = FlashString;
|
||||
|
||||
static AdaptedString adapt(const __FlashStringHelper* s, size_t n) {
|
||||
return AdaptedString(s, n);
|
||||
|
@ -25,7 +25,7 @@ class JsonStringAdapter : public SizedRamString {
|
||||
|
||||
template <>
|
||||
struct StringAdapter<JsonString> {
|
||||
typedef JsonStringAdapter AdaptedString;
|
||||
using AdaptedString = JsonStringAdapter;
|
||||
|
||||
static AdaptedString adapt(const JsonString& s) {
|
||||
return AdaptedString(s);
|
||||
|
@ -63,7 +63,7 @@ class ZeroTerminatedRamString {
|
||||
|
||||
template <typename TChar>
|
||||
struct StringAdapter<TChar*, enable_if_t<IsChar<TChar>::value>> {
|
||||
typedef ZeroTerminatedRamString AdaptedString;
|
||||
using AdaptedString = ZeroTerminatedRamString;
|
||||
|
||||
static AdaptedString adapt(const TChar* p) {
|
||||
return AdaptedString(reinterpret_cast<const char*>(p));
|
||||
@ -72,7 +72,7 @@ struct StringAdapter<TChar*, enable_if_t<IsChar<TChar>::value>> {
|
||||
|
||||
template <typename TChar, size_t N>
|
||||
struct StringAdapter<TChar[N], enable_if_t<IsChar<TChar>::value>> {
|
||||
typedef ZeroTerminatedRamString AdaptedString;
|
||||
using AdaptedString = ZeroTerminatedRamString;
|
||||
|
||||
static AdaptedString adapt(const TChar* p) {
|
||||
return AdaptedString(reinterpret_cast<const char*>(p));
|
||||
@ -90,7 +90,7 @@ class StaticStringAdapter : public ZeroTerminatedRamString {
|
||||
|
||||
template <>
|
||||
struct StringAdapter<const char*, void> {
|
||||
typedef StaticStringAdapter AdaptedString;
|
||||
using AdaptedString = StaticStringAdapter;
|
||||
|
||||
static AdaptedString adapt(const char* p) {
|
||||
return AdaptedString(p);
|
||||
@ -132,7 +132,7 @@ class SizedRamString {
|
||||
|
||||
template <typename TChar>
|
||||
struct SizedStringAdapter<TChar*, enable_if_t<IsChar<TChar>::value>> {
|
||||
typedef SizedRamString AdaptedString;
|
||||
using AdaptedString = SizedRamString;
|
||||
|
||||
static AdaptedString adapt(const TChar* p, size_t n) {
|
||||
return AdaptedString(reinterpret_cast<const char*>(p), n);
|
||||
|
@ -15,7 +15,7 @@ struct StringAdapter<
|
||||
T,
|
||||
enable_if_t<(string_traits<T>::has_cstr || string_traits<T>::has_data) &&
|
||||
(string_traits<T>::has_length || string_traits<T>::has_size)>> {
|
||||
typedef SizedRamString AdaptedString;
|
||||
using AdaptedString = SizedRamString;
|
||||
|
||||
static AdaptedString adapt(const T& s) {
|
||||
return AdaptedString(get_data(s), get_size(s));
|
||||
|
@ -11,7 +11,7 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
class JsonVariantCopier {
|
||||
public:
|
||||
typedef bool result_type;
|
||||
using result_type = bool;
|
||||
|
||||
JsonVariantCopier(JsonVariant dst) : dst_(dst) {}
|
||||
|
||||
|
@ -13,7 +13,7 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename TResult>
|
||||
struct JsonVariantVisitor {
|
||||
typedef TResult result_type;
|
||||
using result_type = TResult;
|
||||
|
||||
template <typename T>
|
||||
TResult visit(const T&) {
|
||||
|
@ -13,7 +13,7 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename TResult>
|
||||
struct VariantDataVisitor {
|
||||
typedef TResult result_type;
|
||||
using result_type = TResult;
|
||||
|
||||
template <typename T>
|
||||
TResult visit(const T&) {
|
||||
|
@ -20,15 +20,15 @@ struct VariantTo {};
|
||||
|
||||
template <>
|
||||
struct VariantTo<JsonArray> {
|
||||
typedef JsonArray type;
|
||||
using type = JsonArray;
|
||||
};
|
||||
template <>
|
||||
struct VariantTo<JsonObject> {
|
||||
typedef JsonObject type;
|
||||
using type = JsonObject;
|
||||
};
|
||||
template <>
|
||||
struct VariantTo<JsonVariant> {
|
||||
typedef JsonVariant type;
|
||||
using type = JsonVariant;
|
||||
};
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
Reference in New Issue
Block a user