Files
thirdparty-ArduinoJson/src/ArduinoJson/Deserialization/NestingLimit.hpp
2021-01-25 09:14:15 +01:00

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