FastLED 3.10.6
Loading...
Searching...
No Matches

◆ crgbJsonMatches()

bool fl::anonymous_namespace{crgb_json.cpp.hpp}::crgbJsonMatches ( const json & document,
span< const CRGB > pixels )

Definition at line 34 of file crgb_json.cpp.hpp.

35 {
36 if (!document.is_object() || document.size() != 2) {
37 return false;
38 }
39
40 const json versionJson = document["version"];
41 const optional<i64> version = versionJson.as<i64>();
42 if (!versionJson.is_int() || versionJson.is_bool() || !version ||
43 *version != 1) {
44 return false;
45 }
46
47 const json encodedPixels = document["pixels"];
48 if (!encodedPixels.is_array() || encodedPixels.size() != pixels.size()) {
49 return false;
50 }
51
52 for (size i = 0; i < encodedPixels.size(); ++i) {
53 const optional<CRGB> decoded = crgbJsonPixel(encodedPixels[i]);
54 if (!decoded || *decoded != pixels[i]) {
55 return false;
56 }
57 }
58 return true;
59}
bool is_object() const FL_NO_EXCEPT
Definition json.h:391
size_t size() const FL_NO_EXCEPT
Definition json.h:798
bool is_int() const FL_NO_EXCEPT
Definition json.h:383
bool is_bool() const FL_NO_EXCEPT
Definition json.h:382
fl::optional< T > as() const FL_NO_EXCEPT
Definition json.h:490
constexpr fl::size size() const FL_NO_EXCEPT
Definition span.h:483
optional< CRGB > crgbJsonPixel(const json &value) FL_NO_EXCEPT
Optional< T > optional
Definition optional.h:16
fl::i64 i64
Definition stdint.h:221

References fl::json::as(), crgbJsonMatches(), crgbJsonPixel(), fl::FL_NO_EXCEPT, fl::json::is_array(), fl::json::is_bool(), fl::json::is_int(), and fl::json::size().

Referenced by crgbJsonMatches().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: