FastLED 3.10.8
Loading...
Searching...
No Matches

◆ clone_array()

fl::optional< json_array > fl::json_value::clone_array ( ) const
inline

Definition at line 1096 of file types.h.

1096 {
1097 auto ptr = data.ptr<json_array>();
1098 if (ptr) return fl::optional<json_array>(*ptr);
1099 // Handle specialized array types by converting them to regular json_array
1100 if (data.is<fl::vector<i16>>()) {
1101 auto audioPtr = data.ptr<fl::vector<i16>>();
1103 for (const auto& item : *audioPtr) {
1104 result.push_back(fl::make_shared<json_value>(static_cast<i64>(item)));
1105 }
1107 }
1108 if (data.is<fl::vector<u8>>()) {
1109 auto bytePtr = data.ptr<fl::vector<u8>>();
1111 for (const auto& item : *bytePtr) {
1112 result.push_back(fl::make_shared<json_value>(static_cast<i64>(item)));
1113 }
1115 }
1116 if (data.is<fl::vector<float>>()) {
1117 auto floatPtr = data.ptr<fl::vector<float>>();
1119 for (const auto& item : *floatPtr) {
1120 result.push_back(fl::make_shared<json_value>(item));
1121 }
1123 }
1124 return fl::nullopt;
1125 }
shared_ptr< T > make_shared(Args &&... args) FL_NO_EXCEPT
Definition shared_ptr.h:423
Optional< T > optional
Definition optional.h:16
fl::vector< fl::shared_ptr< json_value > > json_array
Definition types.h:54
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
constexpr nullopt_t nullopt
Definition optional.h:13
fl::i64 i64
Definition stdint.h:221
variant_t data
Definition types.h:760

References data, fl::FL_NO_EXCEPT, fl::adl_barrier::make_shared(), and fl::nullopt.

Referenced by operator[]().

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