diff --git a/plugins/core-plugin.cc b/plugins/core-plugin.cc index 0881d85..55580bc 100644 --- a/plugins/core-plugin.cc +++ b/plugins/core-plugin.cc @@ -119,6 +119,9 @@ namespace clap { ClapOStream os(stream); yas::binary_oarchive ar(os); ar & _parameters; + + std::vector extra = stateSaveExtra(); + ar & extra; } catch (...) { return false; } @@ -138,6 +141,11 @@ namespace clap { #endif yas::binary_iarchive ar(is); ar & _parameters; + + std::vector extra; + ar & extra; + if (!stateLoadExtra(extra)) + return false; } catch (...) { return false; } diff --git a/plugins/core-plugin.hh b/plugins/core-plugin.hh index 7752183..59648f9 100644 --- a/plugins/core-plugin.hh +++ b/plugins/core-plugin.hh @@ -3,6 +3,9 @@ #include #include +#include +#include + #include #include #include @@ -148,6 +151,9 @@ namespace clap { bool stateSave(const clap_ostream *stream) noexcept override; bool stateLoad(const clap_istream *stream) noexcept override; + virtual std::vector stateSaveExtra() noexcept { return {}; } + virtual bool stateLoadExtra(const std::vector& data) noexcept { return true; } + #ifndef CLAP_PLUGINS_HEADLESS //-----------------// // clap_plugin_gui // diff --git a/plugins/plugs/undo-test/undo-test.cc b/plugins/plugs/undo-test/undo-test.cc index 1f6802d..04e8841 100644 --- a/plugins/plugs/undo-test/undo-test.cc +++ b/plugins/plugs/undo-test/undo-test.cc @@ -132,4 +132,16 @@ namespace clap { super::onGuiInvoke(method, args); } #endif + + std::vector UndoTest::stateSaveExtra() noexcept { + return std::vector((const uint8_t *)&_state, (const uint8_t *)(&_state + 1)); + } + + bool UndoTest::stateLoadExtra(const std::vector &data) noexcept { + if (data.size() != sizeof(_state)) + return false; + _state = *(const uint32_t *)data.data(); + return true; + } + } // namespace clap diff --git a/plugins/plugs/undo-test/undo-test.hh b/plugins/plugs/undo-test/undo-test.hh index d3f923a..914ce50 100644 --- a/plugins/plugs/undo-test/undo-test.hh +++ b/plugins/plugs/undo-test/undo-test.hh @@ -17,6 +17,9 @@ namespace clap { bool init() noexcept override; + std::vector stateSaveExtra() noexcept override; + bool stateLoadExtra(const std::vector &data) noexcept override; + bool implementsUndo() const noexcept override; void undoGetDeltaProperties(clap_undo_delta_properties_t *properties) noexcept override; bool undoCanUseDeltaFormatVersion(clap_id format_version) noexcept override;