From 32ad5ff14a03cdf049903523603c6b7a83dd7a5a Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 1 Apr 2017 13:58:10 +0200 Subject: Store new setting in the plugin. --- plugin/drumgizmo_plugin.cc | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/plugin/drumgizmo_plugin.cc b/plugin/drumgizmo_plugin.cc index d6dd371..9b1c46d 100644 --- a/plugin/drumgizmo_plugin.cc +++ b/plugin/drumgizmo_plugin.cc @@ -28,6 +28,7 @@ #include #include +#include #include @@ -463,6 +464,13 @@ std::string bool2str(bool a) return a?"true":"false"; } +std::string int2str(int a) +{ + char buf[256]; + snprintf(buf, sizeof(buf) - 1, "%d", a); + return buf; +} + float str2float(std::string a) { if(a == "") @@ -473,6 +481,18 @@ float str2float(std::string a) return atof_nol(a.c_str()); } +int str2int(std::string a) +{ + try + { + return std::stoi(a); + } + catch(...) + { + return 0; + } +} + } // end anonymous namespace DrumGizmoPlugin::ConfigStringIO::ConfigStringIO(Settings& settings) @@ -498,7 +518,9 @@ std::string DrumGizmoPlugin::ConfigStringIO::get() " " + float2str(settings.velocity_randomiser_weight.load()) + "\n" " " + - float2str(settings.disk_cache_upper_limit.load()) + "\n" + int2str(settings.disk_cache_upper_limit.load()) + "\n" + " " + + int2str(settings.disk_cache_chunk_size.load()) + "\n" " " + bool2str(settings.disk_cache_enable.load()) + "\n" ""; @@ -547,7 +569,12 @@ bool DrumGizmoPlugin::ConfigStringIO::set(std::string config_string) if(p.value("disk_cache_upper_limit") != "") { - settings.disk_cache_upper_limit.store(str2float(p.value("disk_cache_upper_limit"))); + settings.disk_cache_upper_limit.store(str2int(p.value("disk_cache_upper_limit"))); + } + + if(p.value("disk_cache_chunk_size") != "") + { + settings.disk_cache_chunk_size.store(str2int(p.value("disk_cache_chunk_size"))); } if(p.value("disk_cache_enable") != "") -- cgit v1.2.3