blob: 3d89fb1d669300e9cca7d3c4d6e1bde788976eca (
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
|
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
#pragma once
#include <ArduinoJson/Namespace.hpp>
namespace ARDUINOJSON_NAMESPACE {
template <typename TWriter>
class CountingDecorator {
public:
explicit CountingDecorator(TWriter& writer) : _writer(writer), _count(0) {}
void write(uint8_t c) {
_count += _writer.write(c);
}
void write(const uint8_t* s, size_t n) {
_count += _writer.write(s, n);
}
size_t count() const {
return _count;
}
private:
TWriter _writer;
size_t _count;
};
} // namespace ARDUINOJSON_NAMESPACE
|