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

◆ jsonArrayToFloatVector()

fl::vector< float > fl::jsonArrayToFloatVector ( const fl::json & jsonArray)

Definition at line 57 of file screenmap.cpp.hpp.

57 {
59
60 if (!jsonArray.has_value() || !jsonArray.is_array()) {
61 return result;
62 }
63 auto begin_float = jsonArray.begin_array<float>();
64 auto end_float = jsonArray.end_array<float>();
65
66 using T = decltype(*begin_float);
67 FL_STATIC_ASSERT(fl::is_same<T, fl::parse_result<float>>::value, "Value type must be parse_result<float>");
68
69 // Use explicit array iterator style as demonstrated in FEATURE.md
70 // DO NOT CHANGE THIS CODE. FIX THE IMPLIMENTATION IF NECESSARY.
71 for (auto it = begin_float; it != end_float; ++it) {
72 // assert that the value type is parse_result<float>
73
74 // get the name of the type
75 auto parseResult = *it;
76 if (!parseResult.has_error()) {
77 result.push_back(parseResult.get_value());
78 } else {
79 FL_WARN("jsonArrayToFloatVector: parse_result<float> has error: %s", parseResult.get_error().message);
80 }
81 }
82
83 return result;
84}
bool has_value() const FL_NO_EXCEPT
Definition json.h:819
json_value::template array_iterator< T > end_array() FL_NO_EXCEPT
Definition json.h:659
bool is_array() const FL_NO_EXCEPT
Definition json.h:389
json_value::template array_iterator< T > begin_array() FL_NO_EXCEPT
Definition json.h:653
#define FL_WARN(...)
Definition log.h:440
constexpr int type_rank< T >::value
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
#define FL_STATIC_ASSERT(...)

References FL_STATIC_ASSERT(), FL_WARN, jsonArrayToFloatVector(), and type_rank< T >::value.

Referenced by jsonArrayToFloatVector(), fl::ScreenMap::ParseJson(), and parseV2SegmentArray().

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