• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

bblanchon / ArduinoJson / 9401199389

06 Jun 2024 12:50PM CUT coverage: 99.563% (+0.2%) from 99.362%
9401199389

push

github

bblanchon
Rewrite fromJson

15 of 15 new or added lines in 1 file covered. (100.0%)

3876 of 3893 relevant lines covered (99.56%)

10740.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.44
/src/ArduinoJson/Array/ArrayData.hpp
1
// ArduinoJson - https://arduinojson.org
2
// Copyright © 2014-2024, Benoit BLANCHON
3
// MIT License
4

5
#pragma once
6

7
#include <ArduinoJson/Collection/CollectionData.hpp>
8

9
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
10

11
class ArrayData : public CollectionData {
12
 public:
13
  VariantData* addElement(ResourceManager* resources) {
2,764✔
14
    return addSlot(resources).data();
2,764✔
15
  }
16

17
  static VariantData* addElement(ArrayData* array, ResourceManager* resources) {
222✔
18
    if (!array)
222✔
19
      return nullptr;
×
20
    return array->addElement(resources);
222✔
21
  }
22

23
  template <typename T>
24
  bool addValue(T&& value, ResourceManager* resources);
25

26
  template <typename T>
27
  static bool addValue(ArrayData* array, T&& value,
66,289✔
28
                       ResourceManager* resources) {
29
    if (!array)
66,289✔
30
      return false;
3✔
31
    return array->addValue(value, resources);
66,286✔
32
  }
33

34
  VariantData* getOrAddElement(size_t index, ResourceManager* resources);
35

36
  VariantData* getElement(size_t index, const ResourceManager* resources) const;
37

38
  static VariantData* getElement(const ArrayData* array, size_t index,
455✔
39
                                 const ResourceManager* resources) {
40
    if (!array)
455✔
41
      return nullptr;
15✔
42
    return array->getElement(index, resources);
440✔
43
  }
44

45
  void removeElement(size_t index, ResourceManager* resources);
46

47
  static void removeElement(ArrayData* array, size_t index,
15✔
48
                            ResourceManager* resources) {
49
    if (!array)
15✔
50
      return;
1✔
51
    array->removeElement(index, resources);
14✔
52
  }
53

54
  bool copyFrom(const ArrayData& src, ResourceManager* resources);
55

56
  static bool copy(ArrayData* dst, const ArrayData* src,
57
                   ResourceManager* resources) {
58
    if (!dst || !src)
59
      return false;
60

61
    return dst->copyFrom(*src, resources);
62
  }
63

64
 private:
65
  iterator at(size_t index, const ResourceManager* resources) const;
66
};
67

68
ARDUINOJSON_END_PRIVATE_NAMESPACE
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc