mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
LV2: Use std::optional in more places
This commit is contained in:
parent
fcf1971122
commit
0ba96f15a0
2 changed files with 9 additions and 9 deletions
|
|
@ -346,12 +346,12 @@ public:
|
||||||
const auto numerator = parser.parseNumericAtom<float> (atomBeatsPerBar);
|
const auto numerator = parser.parseNumericAtom<float> (atomBeatsPerBar);
|
||||||
const auto denominator = parser.parseNumericAtom<int32_t> (atomBeatUnit);
|
const auto denominator = parser.parseNumericAtom<int32_t> (atomBeatUnit);
|
||||||
|
|
||||||
if (numerator.hasValue() && denominator.hasValue())
|
if (numerator.has_value() && denominator.has_value())
|
||||||
info->setTimeSignature (TimeSignature { (int) *numerator, (int) *denominator });
|
info->setTimeSignature (TimeSignature { (int) *numerator, (int) *denominator });
|
||||||
|
|
||||||
info->setBpm (parser.parseNumericAtom<float> (atomBeatsPerMinute));
|
info->setBpm (parser.parseNumericAtom<float> (atomBeatsPerMinute));
|
||||||
info->setPpqPosition (parser.parseNumericAtom<double> (atomBeat));
|
info->setPpqPosition (parser.parseNumericAtom<double> (atomBeat));
|
||||||
info->setIsPlaying (! approximatelyEqual (parser.parseNumericAtom<float> (atomSpeed).orFallback (0.0f), 0.0f));
|
info->setIsPlaying (! approximatelyEqual (parser.parseNumericAtom<float> (atomSpeed).value_or (0.0f), 0.0f));
|
||||||
info->setBarCount (parser.parseNumericAtom<int64_t> (atomBar));
|
info->setBarCount (parser.parseNumericAtom<int64_t> (atomBar));
|
||||||
|
|
||||||
if (const auto parsed = parser.parseNumericAtom<int64_t> (atomFrame))
|
if (const auto parsed = parser.parseNumericAtom<int64_t> (atomFrame))
|
||||||
|
|
@ -1451,7 +1451,7 @@ LV2_SYMBOL_EXPORT const LV2_Descriptor* lv2_descriptor (uint32_t index)
|
||||||
const auto blockLengthUrid = mapFeature->map (mapFeature->handle, LV2_BUF_SIZE__maxBlockLength);
|
const auto blockLengthUrid = mapFeature->map (mapFeature->handle, LV2_BUF_SIZE__maxBlockLength);
|
||||||
const auto blockSize = parser.parseNumericOption<int64_t> (findMatchingOption (options, blockLengthUrid));
|
const auto blockSize = parser.parseNumericOption<int64_t> (findMatchingOption (options, blockLengthUrid));
|
||||||
|
|
||||||
if (! blockSize.hasValue())
|
if (! blockSize.has_value())
|
||||||
{
|
{
|
||||||
// The host doesn't specify a maximum block size
|
// The host doesn't specify a maximum block size
|
||||||
jassertfalse;
|
jassertfalse;
|
||||||
|
|
|
||||||
|
|
@ -151,13 +151,13 @@ struct NumericAtomParser
|
||||||
template <typename T> struct Tag { LV2_URID urid; };
|
template <typename T> struct Tag { LV2_URID urid; };
|
||||||
|
|
||||||
template <typename Target, typename... Types>
|
template <typename Target, typename... Types>
|
||||||
static Optional<Target> tryParse (const LV2_Atom&, const void*)
|
static std::optional<Target> tryParse (const LV2_Atom&, const void*)
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Target, typename Head, typename... Tail>
|
template <typename Target, typename Head, typename... Tail>
|
||||||
static Optional<Target> tryParse (const LV2_Atom& atom, const void* data, Tag<Head> head, Tag<Tail>... tail)
|
static std::optional<Target> tryParse (const LV2_Atom& atom, const void* data, Tag<Head> head, Tag<Tail>... tail)
|
||||||
{
|
{
|
||||||
if (atom.type == head.urid && atom.size == sizeof (Head))
|
if (atom.type == head.urid && atom.size == sizeof (Head))
|
||||||
return static_cast<Target> (*reinterpret_cast<const Head*> (data));
|
return static_cast<Target> (*reinterpret_cast<const Head*> (data));
|
||||||
|
|
@ -166,7 +166,7 @@ struct NumericAtomParser
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Target>
|
template <typename Target>
|
||||||
Optional<Target> parseNumericAtom (const LV2_Atom* atom, const void* data) const
|
std::optional<Target> parseNumericAtom (const LV2_Atom* atom, const void* data) const
|
||||||
{
|
{
|
||||||
if (atom == nullptr)
|
if (atom == nullptr)
|
||||||
return {};
|
return {};
|
||||||
|
|
@ -181,13 +181,13 @@ struct NumericAtomParser
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Target>
|
template <typename Target>
|
||||||
Optional<Target> parseNumericAtom (const LV2_Atom* atom) const
|
std::optional<Target> parseNumericAtom (const LV2_Atom* atom) const
|
||||||
{
|
{
|
||||||
return parseNumericAtom<Target> (atom, atom + 1);
|
return parseNumericAtom<Target> (atom, atom + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Target>
|
template <typename Target>
|
||||||
Optional<Target> parseNumericOption (const LV2_Options_Option* option) const
|
std::optional<Target> parseNumericOption (const LV2_Options_Option* option) const
|
||||||
{
|
{
|
||||||
if (option != nullptr)
|
if (option != nullptr)
|
||||||
{
|
{
|
||||||
|
|
@ -278,7 +278,7 @@ struct PatchSetHelper
|
||||||
|
|
||||||
const auto parseResult = parser.parseNumericAtom<float> (value);
|
const auto parseResult = parser.parseNumericAtom<float> (value);
|
||||||
|
|
||||||
if (! parseResult.hasValue())
|
if (! parseResult.has_value())
|
||||||
{
|
{
|
||||||
// Didn't understand the type of this atom.
|
// Didn't understand the type of this atom.
|
||||||
jassertfalse;
|
jassertfalse;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue