MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ get_float()

std::optional< float > MayaFlux::Core::InputValue::OSCMessage::get_float ( size_t  index = 0) const
noexcept

Extract a float argument by index.

int32_t arguments are widened to float.

Parameters
indexArgument index (0-based).
Returns
Float value, or std::nullopt if out of range or wrong type.

Definition at line 115 of file InputBinding.cpp.

116{
117 if (index >= arguments.size())
118 return std::nullopt;
119 return std::visit([](const auto& v) -> std::optional<float> {
120 using T = std::decay_t<decltype(v)>;
121 if constexpr (std::is_same_v<T, float>)
122 return v;
123 if constexpr (std::is_same_v<T, int32_t>)
124 return static_cast<float>(v);
125 return std::nullopt;
126 },
127 arguments[index]);
128}
std::vector< OSCArg > arguments
Typed arguments.