blob: 7426d3bbfdb793fbfc2862305c0b0b39d70a8f37 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
#pragma once
#include "lib/ArduinoJson/Namespace.hpp"
namespace ARDUINOJSON_NAMESPACE {
class Filter {
public:
explicit Filter(VariantConstRef v) : _variant(v) {}
bool allow() const {
return _variant;
}
bool allowArray() const {
return _variant == true || _variant.is<ArrayConstRef>();
}
bool allowObject() const {
return _variant == true || _variant.is<ObjectConstRef>();
}
bool allowValue() const {
return _variant == true;
}
template <typename TKey>
Filter operator[](const TKey& key) const {
if (_variant == true) // "true" means "allow recursively"
return *this;
else
return Filter(_variant[key] | _variant["*"]);
}
private:
VariantConstRef _variant;
};
struct AllowAllFilter {
bool allow() const {
return true;
}
bool allowArray() const {
return true;
}
bool allowObject() const {
return true;
}
bool allowValue() const {
return true;
}
template <typename TKey>
AllowAllFilter operator[](const TKey&) const {
return AllowAllFilter();
}
};
} // namespace ARDUINOJSON_NAMESPACE
|