mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-01 16:14:05 +01:00
30 lines
622 B
C++
30 lines
622 B
C++
// ArduinoJson - arduinojson.org
|
|
// Copyright Benoit Blanchon 2014-2021
|
|
// MIT License
|
|
|
|
#pragma once
|
|
|
|
#include <ArduinoJson/Namespace.hpp>
|
|
#include <ArduinoJson/Polyfills/assert.hpp>
|
|
|
|
namespace ARDUINOJSON_NAMESPACE {
|
|
|
|
class NestingLimit {
|
|
public:
|
|
NestingLimit() : _value(ARDUINOJSON_DEFAULT_NESTING_LIMIT) {}
|
|
explicit NestingLimit(uint8_t n) : _value(n) {}
|
|
|
|
NestingLimit decrement() const {
|
|
ARDUINOJSON_ASSERT(_value > 0);
|
|
return NestingLimit(static_cast<uint8_t>(_value - 1));
|
|
}
|
|
|
|
bool reached() const {
|
|
return _value == 0;
|
|
}
|
|
|
|
private:
|
|
uint8_t _value;
|
|
};
|
|
} // namespace ARDUINOJSON_NAMESPACE
|