mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-01 16:14:05 +01:00
Renamed JsonKey to JsonString
This commit is contained in:
@@ -8,9 +8,9 @@
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
|
||||
class ArduinoString {
|
||||
class ArduinoStringWrapper {
|
||||
public:
|
||||
ArduinoString(const ::String& str) : _str(&str) {}
|
||||
ArduinoStringWrapper(const ::String& str) : _str(&str) {}
|
||||
|
||||
char* save(MemoryPool* pool) const {
|
||||
if (isNull()) return NULL;
|
||||
@@ -50,8 +50,8 @@ struct IsString< ::String> : true_type {};
|
||||
template <>
|
||||
struct IsString< ::StringSumHelper> : true_type {};
|
||||
|
||||
inline ArduinoString makeString(const ::String& str) {
|
||||
return ArduinoString(str);
|
||||
inline ArduinoStringWrapper wrapString(const ::String& str) {
|
||||
return ArduinoStringWrapper(str);
|
||||
}
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
@@ -9,9 +9,9 @@
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
|
||||
class ZeroTerminatedRamStringConst {
|
||||
class ConstRamStringWrapper {
|
||||
public:
|
||||
ZeroTerminatedRamStringConst(const char* str = 0) : _str(str) {}
|
||||
ConstRamStringWrapper(const char* str = 0) : _str(str) {}
|
||||
|
||||
bool equals(const char* expected) const {
|
||||
const char* actual = _str;
|
||||
@@ -40,8 +40,8 @@ class ZeroTerminatedRamStringConst {
|
||||
const char* _str;
|
||||
};
|
||||
|
||||
inline ZeroTerminatedRamStringConst makeString(const char* str) {
|
||||
return ZeroTerminatedRamStringConst(str);
|
||||
inline ConstRamStringWrapper wrapString(const char* str) {
|
||||
return ConstRamStringWrapper(str);
|
||||
}
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
|
||||
class ZeroTerminatedFlashString {
|
||||
class FlashStringWrapper {
|
||||
public:
|
||||
ZeroTerminatedFlashString(const __FlashStringHelper* str) : _str(str) {}
|
||||
FlashStringWrapper(const __FlashStringHelper* str) : _str(str) {}
|
||||
|
||||
bool equals(const char* expected) const {
|
||||
const char* actual = reinterpret_cast<const char*>(_str);
|
||||
@@ -36,8 +36,8 @@ class ZeroTerminatedFlashString {
|
||||
const __FlashStringHelper* _str;
|
||||
};
|
||||
|
||||
inline ZeroTerminatedFlashString makeString(const __FlashStringHelper* str) {
|
||||
return ZeroTerminatedFlashString(str);
|
||||
inline FlashStringWrapper wrapString(const __FlashStringHelper* str) {
|
||||
return FlashStringWrapper(str);
|
||||
}
|
||||
|
||||
template <>
|
||||
@@ -4,14 +4,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ZeroTerminatedRamStringConst.hpp"
|
||||
#include "ConstRamStringWrapper.hpp"
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
|
||||
class ZeroTerminatedRamString : public ZeroTerminatedRamStringConst {
|
||||
class RamStringWrapper : public ConstRamStringWrapper {
|
||||
public:
|
||||
ZeroTerminatedRamString(const char* str)
|
||||
: ZeroTerminatedRamStringConst(str) {}
|
||||
RamStringWrapper(const char* str) : ConstRamStringWrapper(str) {}
|
||||
|
||||
char* save(MemoryPool* pool) const {
|
||||
if (!_str) return NULL;
|
||||
@@ -23,12 +22,12 @@ class ZeroTerminatedRamString : public ZeroTerminatedRamStringConst {
|
||||
};
|
||||
|
||||
template <typename TChar>
|
||||
inline ZeroTerminatedRamString makeString(const TChar* str) {
|
||||
return ZeroTerminatedRamString(reinterpret_cast<const char*>(str));
|
||||
inline RamStringWrapper wrapString(const TChar* str) {
|
||||
return RamStringWrapper(reinterpret_cast<const char*>(str));
|
||||
}
|
||||
|
||||
inline ZeroTerminatedRamString makeString(char* str) {
|
||||
return ZeroTerminatedRamString(str);
|
||||
inline RamStringWrapper wrapString(char* str) {
|
||||
return RamStringWrapper(str);
|
||||
}
|
||||
|
||||
template <typename TChar>
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
|
||||
class FixedSizeFlashString {
|
||||
class SizedFlashStringWrapper {
|
||||
public:
|
||||
FixedSizeFlashString(const __FlashStringHelper* str, size_t sz)
|
||||
SizedFlashStringWrapper(const __FlashStringHelper* str, size_t sz)
|
||||
: _str(str), _size(sz) {}
|
||||
|
||||
bool equals(const char* expected) const {
|
||||
@@ -37,8 +37,8 @@ class FixedSizeFlashString {
|
||||
size_t _size;
|
||||
};
|
||||
|
||||
inline FixedSizeFlashString makeString(const __FlashStringHelper* str,
|
||||
size_t sz) {
|
||||
return FixedSizeFlashString(str, sz);
|
||||
inline SizedFlashStringWrapper wrapString(const __FlashStringHelper* str,
|
||||
size_t sz) {
|
||||
return SizedFlashStringWrapper(str, sz);
|
||||
}
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
|
||||
class FixedSizeRamString {
|
||||
class SizedRamStringWrapper {
|
||||
public:
|
||||
FixedSizeRamString(const char* str, size_t n) : _str(str), _size(n) {}
|
||||
SizedRamStringWrapper(const char* str, size_t n) : _str(str), _size(n) {}
|
||||
|
||||
bool equals(const char* expected) const {
|
||||
const char* actual = reinterpret_cast<const char*>(_str);
|
||||
@@ -39,8 +39,8 @@ class FixedSizeRamString {
|
||||
};
|
||||
|
||||
template <typename TChar>
|
||||
inline FixedSizeRamString makeString(const TChar* str, size_t size) {
|
||||
return FixedSizeRamString(reinterpret_cast<const char*>(str), size);
|
||||
inline SizedRamStringWrapper wrapString(const TChar* str, size_t size) {
|
||||
return SizedRamStringWrapper(reinterpret_cast<const char*>(str), size);
|
||||
}
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
|
||||
class StlString {
|
||||
class StlStringWrapper {
|
||||
public:
|
||||
StlString(const std::string& str) : _str(&str) {}
|
||||
StlStringWrapper(const std::string& str) : _str(&str) {}
|
||||
|
||||
char* save(MemoryPool* pool) const {
|
||||
size_t n = _str->length() + 1;
|
||||
@@ -43,8 +43,8 @@ class StlString {
|
||||
template <>
|
||||
struct IsString<std::string> : true_type {};
|
||||
|
||||
inline StlString makeString(const std::string& str) {
|
||||
return StlString(str);
|
||||
inline StlStringWrapper wrapString(const std::string& str) {
|
||||
return StlStringWrapper(str);
|
||||
}
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
32
src/ArduinoJson/Strings/String.hpp
Normal file
32
src/ArduinoJson/Strings/String.hpp
Normal file
@@ -0,0 +1,32 @@
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
|
||||
class String {
|
||||
public:
|
||||
String() : _data(0) {}
|
||||
String(const char* slot) : _data(slot) {}
|
||||
|
||||
const char* c_str() const {
|
||||
return _data;
|
||||
}
|
||||
|
||||
bool isNull() const {
|
||||
return !_data;
|
||||
}
|
||||
|
||||
friend bool operator==(String lhs, String rhs) {
|
||||
if (lhs._data == rhs._data) return true;
|
||||
if (!lhs._data) return false;
|
||||
if (!rhs._data) return false;
|
||||
return strcmp(lhs._data, rhs._data) == 0;
|
||||
}
|
||||
|
||||
private:
|
||||
const char* _data;
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
@@ -18,19 +18,19 @@ template <typename T>
|
||||
struct IsString<T&> : IsString<T> {};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
#include "FixedSizeRamString.hpp"
|
||||
#include "ZeroTerminatedRamString.hpp"
|
||||
#include "ZeroTerminatedRamStringConst.hpp"
|
||||
#include "ConstRamStringWrapper.hpp"
|
||||
#include "RamStringWrapper.hpp"
|
||||
#include "SizedRamStringWrapper.hpp"
|
||||
|
||||
#if ARDUINOJSON_ENABLE_STD_STRING
|
||||
#include "StlString.hpp"
|
||||
#include "StlStringWrapper.hpp"
|
||||
#endif
|
||||
|
||||
#if ARDUINOJSON_ENABLE_ARDUINO_STRING
|
||||
#include "ArduinoString.hpp"
|
||||
#include "ArduinoStringWrapper.hpp"
|
||||
#endif
|
||||
|
||||
#if ARDUINOJSON_ENABLE_PROGMEM
|
||||
#include "FixedSizeFlashString.hpp"
|
||||
#include "ZeroTerminatedFlashString.hpp"
|
||||
#include "FlashStringWrapper.hpp"
|
||||
#include "SizedFlashStringWrapper.hpp"
|
||||
#endif
|
||||
Reference in New Issue
Block a user