mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-30 18:57:32 +02:00
VariantImpl: rename getResourceManager()
to resources()
This commit is contained in:
@ -52,7 +52,7 @@ class ElementProxy : public VariantRefBase<ElementProxy<TUpstream>>,
|
|||||||
|
|
||||||
VariantImpl getImpl() const {
|
VariantImpl getImpl() const {
|
||||||
auto impl = VariantAttorney::getImpl(upstream_);
|
auto impl = VariantAttorney::getImpl(upstream_);
|
||||||
return VariantImpl(impl.getElement(index_), impl.getResourceManager());
|
return VariantImpl(impl.getElement(index_), impl.resources());
|
||||||
}
|
}
|
||||||
|
|
||||||
VariantImpl getOrCreateImpl() const {
|
VariantImpl getOrCreateImpl() const {
|
||||||
@ -60,7 +60,7 @@ class ElementProxy : public VariantRefBase<ElementProxy<TUpstream>>,
|
|||||||
auto data = impl.data();
|
auto data = impl.data();
|
||||||
if (data)
|
if (data)
|
||||||
data->getOrCreateArray();
|
data->getOrCreateArray();
|
||||||
return VariantImpl(impl.getOrAddElement(index_), impl.getResourceManager());
|
return VariantImpl(impl.getOrAddElement(index_), impl.resources());
|
||||||
}
|
}
|
||||||
|
|
||||||
TUpstream upstream_;
|
TUpstream upstream_;
|
||||||
|
@ -52,7 +52,7 @@ class JsonArray : public detail::VariantOperators<JsonArray> {
|
|||||||
template <typename T, detail::enable_if_t<
|
template <typename T, detail::enable_if_t<
|
||||||
detail::is_same<T, JsonVariant>::value, int> = 0>
|
detail::is_same<T, JsonVariant>::value, int> = 0>
|
||||||
JsonVariant add() const {
|
JsonVariant add() const {
|
||||||
return JsonVariant(impl_.addElement(), impl_.getResourceManager());
|
return JsonVariant(impl_.addElement(), impl_.resources());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Appends a value to the array.
|
// Appends a value to the array.
|
||||||
|
@ -44,8 +44,7 @@ class JsonArrayConst : public detail::VariantOperators<JsonArrayConst> {
|
|||||||
template <typename T,
|
template <typename T,
|
||||||
detail::enable_if_t<detail::is_integral<T>::value, int> = 0>
|
detail::enable_if_t<detail::is_integral<T>::value, int> = 0>
|
||||||
JsonVariantConst operator[](T index) const {
|
JsonVariantConst operator[](T index) const {
|
||||||
return JsonVariantConst(impl_.getElement(size_t(index)),
|
return JsonVariantConst(impl_.getElement(size_t(index)), impl_.resources());
|
||||||
impl_.getResourceManager());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the element at the specified index.
|
// Returns the element at the specified index.
|
||||||
|
@ -25,7 +25,7 @@ class CollectionIterator {
|
|||||||
void next() {
|
void next() {
|
||||||
ARDUINOJSON_ASSERT(!done());
|
ARDUINOJSON_ASSERT(!done());
|
||||||
auto nextId = value_.data()->next;
|
auto nextId = value_.data()->next;
|
||||||
auto resources = value_.getResourceManager();
|
auto resources = value_.resources();
|
||||||
value_ = VariantImpl(resources->getVariant(nextId), resources);
|
value_ = VariantImpl(resources->getVariant(nextId), resources);
|
||||||
currentId_ = nextId;
|
currentId_ = nextId;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ DeserializationError doDeserialize(TDestination&& dst, TReader reader,
|
|||||||
auto impl = VariantAttorney::getOrCreateImpl(dst);
|
auto impl = VariantAttorney::getOrCreateImpl(dst);
|
||||||
if (impl.isUnbound())
|
if (impl.isUnbound())
|
||||||
return DeserializationError::NoMemory;
|
return DeserializationError::NoMemory;
|
||||||
auto resources = impl.getResourceManager();
|
auto resources = impl.resources();
|
||||||
dst.clear();
|
dst.clear();
|
||||||
auto err = TDeserializer<TReader>(resources, reader)
|
auto err = TDeserializer<TReader>(resources, reader)
|
||||||
.parse(impl.data(), options.filter, options.nestingLimit);
|
.parse(impl.data(), options.filter, options.nestingLimit);
|
||||||
|
@ -29,7 +29,7 @@ struct Converter<MsgPackBinary> : private detail::VariantAttorney {
|
|||||||
auto data = impl.data();
|
auto data = impl.data();
|
||||||
if (!data)
|
if (!data)
|
||||||
return;
|
return;
|
||||||
auto resources = impl.getResourceManager();
|
auto resources = impl.resources();
|
||||||
impl.clear();
|
impl.clear();
|
||||||
if (src.data()) {
|
if (src.data()) {
|
||||||
size_t headerSize = src.size() >= 0x10000 ? 5
|
size_t headerSize = src.size() >= 0x10000 ? 5
|
||||||
|
@ -33,7 +33,7 @@ struct Converter<MsgPackExtension> : private detail::VariantAttorney {
|
|||||||
static void toJson(MsgPackExtension src, JsonVariant dst) {
|
static void toJson(MsgPackExtension src, JsonVariant dst) {
|
||||||
auto impl = getImpl(dst);
|
auto impl = getImpl(dst);
|
||||||
auto data = impl.data();
|
auto data = impl.data();
|
||||||
auto resources = impl.getResourceManager();
|
auto resources = impl.resources();
|
||||||
if (!data)
|
if (!data)
|
||||||
return;
|
return;
|
||||||
impl.clear();
|
impl.clear();
|
||||||
|
@ -96,7 +96,7 @@ class JsonObjectConst : public detail::VariantOperators<JsonObjectConst> {
|
|||||||
detail::enable_if_t<detail::IsString<TString>::value, int> = 0>
|
detail::enable_if_t<detail::IsString<TString>::value, int> = 0>
|
||||||
JsonVariantConst operator[](const TString& key) const {
|
JsonVariantConst operator[](const TString& key) const {
|
||||||
return JsonVariantConst(impl_.getMember(detail::adaptString(key)),
|
return JsonVariantConst(impl_.getMember(detail::adaptString(key)),
|
||||||
impl_.getResourceManager());
|
impl_.resources());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the member with specified key.
|
// Gets the member with specified key.
|
||||||
@ -107,7 +107,7 @@ class JsonObjectConst : public detail::VariantOperators<JsonObjectConst> {
|
|||||||
int> = 0>
|
int> = 0>
|
||||||
JsonVariantConst operator[](TChar* key) const {
|
JsonVariantConst operator[](TChar* key) const {
|
||||||
return JsonVariantConst(impl_.getMember(detail::adaptString(key)),
|
return JsonVariantConst(impl_.getMember(detail::adaptString(key)),
|
||||||
impl_.getResourceManager());
|
impl_.resources());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the member with specified key.
|
// Gets the member with specified key.
|
||||||
|
@ -53,7 +53,7 @@ class MemberProxy
|
|||||||
|
|
||||||
VariantImpl getImpl() const {
|
VariantImpl getImpl() const {
|
||||||
auto impl = VariantAttorney::getImpl(upstream_);
|
auto impl = VariantAttorney::getImpl(upstream_);
|
||||||
return VariantImpl(impl.getMember(key_), impl.getResourceManager());
|
return VariantImpl(impl.getMember(key_), impl.resources());
|
||||||
}
|
}
|
||||||
|
|
||||||
VariantImpl getOrCreateImpl() const {
|
VariantImpl getOrCreateImpl() const {
|
||||||
@ -61,7 +61,7 @@ class MemberProxy
|
|||||||
auto data = impl.data();
|
auto data = impl.data();
|
||||||
if (data)
|
if (data)
|
||||||
data->getOrCreateObject();
|
data->getOrCreateObject();
|
||||||
return VariantImpl(impl.getOrAddMember(key_), impl.getResourceManager());
|
return VariantImpl(impl.getOrAddMember(key_), impl.resources());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -12,7 +12,7 @@ template <template <typename> class TSerializer>
|
|||||||
size_t measure(ArduinoJson::JsonVariantConst source) {
|
size_t measure(ArduinoJson::JsonVariantConst source) {
|
||||||
DummyWriter dp;
|
DummyWriter dp;
|
||||||
auto impl = VariantAttorney::getImpl(source);
|
auto impl = VariantAttorney::getImpl(source);
|
||||||
TSerializer<DummyWriter> serializer(dp, impl.getResourceManager());
|
TSerializer<DummyWriter> serializer(dp, impl.resources());
|
||||||
return impl.accept(serializer);
|
return impl.accept(serializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
|||||||
template <template <typename> class TSerializer, typename TWriter>
|
template <template <typename> class TSerializer, typename TWriter>
|
||||||
size_t doSerialize(ArduinoJson::JsonVariantConst source, TWriter writer) {
|
size_t doSerialize(ArduinoJson::JsonVariantConst source, TWriter writer) {
|
||||||
auto impl = VariantAttorney::getImpl(source);
|
auto impl = VariantAttorney::getImpl(source);
|
||||||
TSerializer<TWriter> serializer(writer, impl.getResourceManager());
|
TSerializer<TWriter> serializer(writer, impl.resources());
|
||||||
return impl.accept(serializer);
|
return impl.accept(serializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ inline void convertToJson(const ::Printable& src, JsonVariant dst) {
|
|||||||
if (impl.isUnbound())
|
if (impl.isUnbound())
|
||||||
return;
|
return;
|
||||||
impl.clear();
|
impl.clear();
|
||||||
detail::StringBuilderPrint print(impl.getResourceManager());
|
detail::StringBuilderPrint print(impl.resources());
|
||||||
src.printTo(print);
|
src.printTo(print);
|
||||||
if (print.overflowed())
|
if (print.overflowed())
|
||||||
return;
|
return;
|
||||||
|
@ -107,8 +107,7 @@ class JsonVariantConst : public detail::VariantTag,
|
|||||||
template <typename T,
|
template <typename T,
|
||||||
detail::enable_if_t<detail::is_integral<T>::value, int> = 0>
|
detail::enable_if_t<detail::is_integral<T>::value, int> = 0>
|
||||||
JsonVariantConst operator[](T index) const {
|
JsonVariantConst operator[](T index) const {
|
||||||
return JsonVariantConst(impl_.getElement(size_t(index)),
|
return JsonVariantConst(impl_.getElement(size_t(index)), impl_.resources());
|
||||||
impl_.getResourceManager());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets object's member with specified key.
|
// Gets object's member with specified key.
|
||||||
@ -117,7 +116,7 @@ class JsonVariantConst : public detail::VariantTag,
|
|||||||
detail::enable_if_t<detail::IsString<TString>::value, int> = 0>
|
detail::enable_if_t<detail::IsString<TString>::value, int> = 0>
|
||||||
JsonVariantConst operator[](const TString& key) const {
|
JsonVariantConst operator[](const TString& key) const {
|
||||||
return JsonVariantConst(impl_.getMember(detail::adaptString(key)),
|
return JsonVariantConst(impl_.getMember(detail::adaptString(key)),
|
||||||
impl_.getResourceManager());
|
impl_.resources());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets object's member with specified key.
|
// Gets object's member with specified key.
|
||||||
@ -128,7 +127,7 @@ class JsonVariantConst : public detail::VariantTag,
|
|||||||
int> = 0>
|
int> = 0>
|
||||||
JsonVariantConst operator[](TChar* key) const {
|
JsonVariantConst operator[](TChar* key) const {
|
||||||
return JsonVariantConst(impl_.getMember(detail::adaptString(key)),
|
return JsonVariantConst(impl_.getMember(detail::adaptString(key)),
|
||||||
impl_.getResourceManager());
|
impl_.resources());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets object's member with specified key or the array's element at the
|
// Gets object's member with specified key or the array's element at the
|
||||||
|
@ -31,7 +31,7 @@ class VariantImpl {
|
|||||||
return data_;
|
return data_;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceManager* getResourceManager() const {
|
ResourceManager* resources() const {
|
||||||
return resources_;
|
return resources_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ template <typename TDerived>
|
|||||||
template <typename T, enable_if_t<is_same<T, JsonVariant>::value, int>>
|
template <typename T, enable_if_t<is_same<T, JsonVariant>::value, int>>
|
||||||
inline T VariantRefBase<TDerived>::add() const {
|
inline T VariantRefBase<TDerived>::add() const {
|
||||||
auto impl = getOrCreateArray();
|
auto impl = getOrCreateArray();
|
||||||
return JsonVariant(impl.addElement(), impl.getResourceManager());
|
return JsonVariant(impl.addElement(), impl.resources());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename TDerived>
|
template <typename TDerived>
|
||||||
@ -130,7 +130,7 @@ template <typename TConverter, typename T>
|
|||||||
inline bool VariantRefBase<TDerived>::doSet(const T& value, false_type) const {
|
inline bool VariantRefBase<TDerived>::doSet(const T& value, false_type) const {
|
||||||
auto impl = getOrCreateImpl();
|
auto impl = getOrCreateImpl();
|
||||||
TConverter::toJson(value, JsonVariant(impl));
|
TConverter::toJson(value, JsonVariant(impl));
|
||||||
auto resources = impl.getResourceManager();
|
auto resources = impl.resources();
|
||||||
return resources && !resources->overflowed();
|
return resources && !resources->overflowed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user