blob: a76f07f33a0c98cfc6a6d98f494dee31655972b3 (
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
|
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
#pragma once
#include <stddef.h> // size_t
#include <string.h> // strcmp
#include "lib/ArduinoJson/Polyfills/safe_strcmp.hpp"
#include "lib/ArduinoJson/Strings/IsString.hpp"
#include "lib/ArduinoJson/Strings/StoragePolicy.hpp"
namespace ARDUINOJSON_NAMESPACE {
class ConstRamStringAdapter {
public:
ConstRamStringAdapter(const char* str = 0) : _str(str) {}
int compare(const char* other) const {
return safe_strcmp(_str, other);
}
bool equals(const char* expected) const {
return compare(expected) == 0;
}
bool isNull() const {
return !_str;
}
size_t size() const {
if (!_str)
return 0;
return strlen(_str);
}
const char* data() const {
return _str;
}
const char* begin() const {
return _str;
}
typedef storage_policies::store_by_address storage_policy;
protected:
const char* _str;
};
template <>
struct IsString<const char*> : true_type {};
template <int TN>
struct IsString<const char[TN]> : true_type {};
inline ConstRamStringAdapter adaptString(const char* str) {
return ConstRamStringAdapter(str);
}
} // namespace ARDUINOJSON_NAMESPACE
|