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

◆ as_fixed_point()

template<typename FP>
fl::enable_if< detail::is_fl_fixed_point< FP >::value, fl::optional< FP > >::type fl::json::as_fixed_point ( ) const
inline

Definition at line 427 of file json.h.

429 {
430 if (!mValue) return fl::nullopt;
431 if (auto raw = mValue->data.template ptr<i64>()) {
432 return FP::from_raw(static_cast<decltype(FP().raw())>(*raw));
433 }
434 if (auto f = mValue->data.template ptr<float>()) {
435 i64 raw = 0;
437 fl::bit_cast<u32>(*f), FP::FRAC_BITS, &raw)) {
438 return fl::nullopt;
439 }
440 return FP::from_raw(static_cast<decltype(FP().raw())>(raw));
441 }
fl::shared_ptr< json_value > mValue
Definition json.h:263
bool fixed_raw_from_ieee754_bits(u32 bits, int frac_bits, i64 *out) FL_NO_EXCEPT
Definition json.h:216
constexpr nullopt_t nullopt
Definition optional.h:13
To bit_cast(const From &from) FL_NO_EXCEPT
Definition bit_cast.h:48
fl::i64 i64
Definition stdint.h:221

References fl::bit_cast(), fl::detail::fixed_raw_from_ieee754_bits(), fl::FL_NO_EXCEPT, mValue, and fl::nullopt.

+ Here is the call graph for this function: