mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-01 16:14:05 +01:00
Remove Visitable
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Configuration.hpp>
|
||||
#include <ArduinoJson/Misc/Visitable.hpp>
|
||||
#include <ArduinoJson/Numbers/arithmeticCompare.hpp>
|
||||
#include <ArduinoJson/Polyfills/type_traits.hpp>
|
||||
#include <ArduinoJson/Strings/StringAdapters.hpp>
|
||||
@@ -128,12 +127,10 @@ struct RawComparer : ComparerBase {
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct Comparer<T, typename enable_if<IsVisitable<T>::value>::type>
|
||||
: ComparerBase {
|
||||
const T *rhs; // TODO: should be a VariantConstRef
|
||||
struct VariantComparer : ComparerBase {
|
||||
VariantConstRef rhs;
|
||||
|
||||
explicit Comparer(const T &value) : rhs(&value) {}
|
||||
explicit VariantComparer(VariantConstRef value) : rhs(value) {}
|
||||
|
||||
CompareResult visitArray(const CollectionData &lhs) {
|
||||
ArrayComparer comparer(lhs);
|
||||
@@ -183,7 +180,7 @@ struct Comparer<T, typename enable_if<IsVisitable<T>::value>::type>
|
||||
private:
|
||||
template <typename TComparer>
|
||||
CompareResult accept(TComparer &comparer) {
|
||||
CompareResult reversedResult = rhs->accept(comparer);
|
||||
CompareResult reversedResult = rhs.accept(comparer);
|
||||
switch (reversedResult) {
|
||||
case COMPARE_RESULT_GREATER:
|
||||
return COMPARE_RESULT_LESS;
|
||||
@@ -195,9 +192,17 @@ struct Comparer<T, typename enable_if<IsVisitable<T>::value>::type>
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
CompareResult compare(const T1 &lhs, const T2 &rhs) {
|
||||
Comparer<T2> comparer(rhs);
|
||||
template <typename T>
|
||||
struct Comparer<
|
||||
T, typename enable_if<is_convertible<T, VariantConstRef>::value>::type>
|
||||
: VariantComparer {
|
||||
explicit Comparer(const T &value)
|
||||
: VariantComparer(value.operator VariantConstRef()) {}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
CompareResult compare(VariantConstRef lhs, const T &rhs) {
|
||||
Comparer<T> comparer(rhs);
|
||||
return lhs.accept(comparer);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user