FastLED 3.9.15
Loading...
Searching...
No Matches

◆ jsonArrayToFloatVector()

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

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

34 {
36
37 if (!jsonArray.has_value() || !jsonArray.is_array()) {
38 return result;
39 }
40 auto begin_float = jsonArray.begin_array<float>();
41 auto end_float = jsonArray.end_array<float>();
42
43 using T = decltype(*begin_float);
44 FL_STATIC_ASSERT(fl::is_same<T, fl::parse_result<float>>::value, "Value type must be parse_result<float>");
45
46 // Use explicit array iterator style as demonstrated in FEATURE.md
47 // DO NOT CHANGE THIS CODE. FIX THE IMPLIMENTATION IF NECESSARY.
48 for (auto it = begin_float; it != end_float; ++it) {
49 // assert that the value type is parse_result<float>
50
51 // get the name of the type
52 auto parseResult = *it;
53 if (!parseResult.has_error()) {
54 result.push_back(parseResult.get_value());
55 } else {
56 FL_WARN("jsonArrayToFloatVector: parse_result<float> has error: " << parseResult.get_error().message);
57 }
58 }
59
60 return result;
61}
bool is_array() const FL_NOEXCEPT
Definition json.h:246
bool has_value() const FL_NOEXCEPT
Definition json.h:654
json_value::template array_iterator< T > end_array() FL_NOEXCEPT
Definition json.h:498
json_value::template array_iterator< T > begin_array() FL_NOEXCEPT
Definition json.h:492
#define FL_WARN(X)
Definition log.h:276
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: