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

bblanchon / ArduinoJson / 13696030297

06 Mar 2025 10:00AM CUT coverage: 99.309%. Remained the same
13696030297

push

github

bblanchon
Fix CLang Tidy error

4023 of 4051 relevant lines covered (99.31%)

10751.08 hits per line

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

81.82
/src/ArduinoJson/Polyfills/pgmspace_generic.hpp
1
// ArduinoJson - https://arduinojson.org
2
// Copyright © 2014-2025, Benoit BLANCHON
3
// MIT License
4

5
#pragma once
6

7
#include <ArduinoJson/Namespace.hpp>
8

9
#if ARDUINOJSON_ENABLE_PROGMEM
10
#  include <ArduinoJson/Polyfills/pgmspace.hpp>
11
#  include <ArduinoJson/Polyfills/type_traits.hpp>
12
#endif
13

14
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
15

16
#if ARDUINOJSON_ENABLE_PROGMEM
17

18
#  ifndef ARDUINOJSON_DEFINE_PROGMEM_ARRAY
19
#    define ARDUINOJSON_DEFINE_PROGMEM_ARRAY(type, name, ...) \
20
      static type const name[] PROGMEM = __VA_ARGS__;
21
#  endif
22

23
template <typename T>
24
inline const T* pgm_read(const T* const* p) {
6✔
25
  return reinterpret_cast<const T*>(pgm_read_ptr(p));
6✔
26
}
27

28
inline uint32_t pgm_read(const uint32_t* p) {
29
  return pgm_read_dword(p);
30
}
31

32
inline double pgm_read(const double* p) {
×
33
  return pgm_read_double(p);
×
34
}
35

36
inline float pgm_read(const float* p) {
2✔
37
  return pgm_read_float(p);
2✔
38
}
39

40
#else
41

42
#  ifndef ARDUINOJSON_DEFINE_PROGMEM_ARRAY
43
#    define ARDUINOJSON_DEFINE_PROGMEM_ARRAY(type, name, ...) \
44
      static type const name[] = __VA_ARGS__;
45
#  endif
46

47
template <typename T>
48
inline T pgm_read(const T* p) {
424✔
49
  return *p;
424✔
50
}
51

52
#endif
53

54
template <typename T>
55
class pgm_ptr {
56
 public:
57
  explicit pgm_ptr(const T* ptr) : ptr_(ptr) {}
338✔
58

59
  T operator[](intptr_t index) const {
426✔
60
    return pgm_read(ptr_ + index);
426✔
61
  }
62

63
 private:
64
  const T* ptr_;
65
};
66

67
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