Coverage Report

Created: 2024-09-08 06:19

/src/arduinojson/src/ArduinoJson/Deserialization/NestingLimit.hpp
Line
Count
Source
1
// ArduinoJson - https://arduinojson.org
2
// Copyright © 2014-2024, Benoit BLANCHON
3
// MIT License
4
5
#pragma once
6
7
#include <ArduinoJson/Namespace.hpp>
8
#include <ArduinoJson/Polyfills/assert.hpp>
9
10
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
11
12
namespace DeserializationOption {
13
class NestingLimit {
14
 public:
15
1.46k
  NestingLimit() : value_(ARDUINOJSON_DEFAULT_NESTING_LIMIT) {}
16
13.2k
  explicit NestingLimit(uint8_t n) : value_(n) {}
17
18
13.2k
  NestingLimit decrement() const {
19
13.2k
    ARDUINOJSON_ASSERT(value_ > 0);
20
13.2k
    return NestingLimit(static_cast<uint8_t>(value_ - 1));
21
13.2k
  }
22
23
4.25k
  bool reached() const {
24
4.25k
    return value_ == 0;
25
4.25k
  }
26
27
 private:
28
  uint8_t value_;
29
};
30
}  // namespace DeserializationOption
31
32
ARDUINOJSON_END_PUBLIC_NAMESPACE