MIDI plugins -- partial implemetnation, temporarily disabled.
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
#include <chrono>
|
||||
#include <optional>
|
||||
|
||||
#define DECLARE_JSON_MAP(CLASSNAME) \
|
||||
static pipedal::json_map::storage_type<CLASSNAME> jmap
|
||||
@@ -592,6 +593,17 @@ namespace pipedal
|
||||
write(obj.get());
|
||||
}
|
||||
}
|
||||
template <typename T>
|
||||
void write(const std::optional<T> &obj)
|
||||
{
|
||||
if (!obj) {
|
||||
write_raw("null");
|
||||
} else {
|
||||
write(obj.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
void write(const std::weak_ptr<T> &obj)
|
||||
{
|
||||
@@ -883,6 +895,20 @@ namespace pipedal
|
||||
}
|
||||
}
|
||||
template <typename T>
|
||||
void read(std::optional<T> *pOptional)
|
||||
{
|
||||
if (peek() == 'n')
|
||||
{
|
||||
consumeToken("null", "Expecting '{' or 'null'.");
|
||||
*pOptional = std::optional<T>();
|
||||
|
||||
} else {
|
||||
T value;
|
||||
read(&value);
|
||||
*pOptional = std::move(value);
|
||||
}
|
||||
}
|
||||
template <typename T>
|
||||
void read(std::weak_ptr<T> *pUniquePtr)
|
||||
{
|
||||
throw std::domain_error("Can't read std::weak_ptr");
|
||||
|
||||
Reference in New Issue
Block a user