diff options
| author | Peter LaFosse <peter@vector35.com> | 2017-07-01 16:41:36 -0400 |
|---|---|---|
| committer | Peter LaFosse <peter@vector35.com> | 2017-07-02 16:57:30 -0400 |
| commit | 88ec179d9519221744240e347bc94da09bbc2157 (patch) | |
| tree | 4f9b5837340a0f87fae69a5c29fcf3467a15d775 /settings.cpp | |
| parent | 10c88f331e8d74e7c9aad3c67518fb4eb8386da9 (diff) | |
expose Settings 'Set' APIs to C++
Diffstat (limited to 'settings.cpp')
| -rw-r--r-- | settings.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/settings.cpp b/settings.cpp index b7e08793..a60b7e3a 100644 --- a/settings.cpp +++ b/settings.cpp @@ -96,3 +96,69 @@ bool Setting::IsDouble(const std::string& pluginName, const std::string& name) { return BNSettingIsDouble(pluginName.c_str(), name.c_str()); } + +bool Setting::Set(const std::string& settingGroup, + const std::string& name, + bool value, + bool autoFlush) +{ + return BNSettingSetBool(settingGroup.c_str(), name.c_str(), value, autoFlush); +} + +bool Setting::Set(const std::string& settingGroup, + const std::string& name, + uint64_t value, + bool autoFlush) +{ + return BNSettingSetInteger(settingGroup.c_str(), name.c_str(), value, autoFlush); +} + +bool Setting::Set(const std::string& settingGroup, + const std::string& name, + const std::string& value, + bool autoFlush) +{ + return BNSettingSetString(settingGroup.c_str(), name.c_str(), value.c_str(), autoFlush); +} + +bool Setting::Set(const std::string& settingGroup, + const std::string& name, + const std::vector<uint64_t>& value, + bool autoFlush) +{ + return BNSettingSetIntegerList(settingGroup.c_str(), name.c_str(), &value[0], value.size(), autoFlush); +} + +bool Setting::Set(const std::string& settingGroup, + const std::string& name, + const std::vector<std::string>& value, + bool autoFlush) +{ + char** buffer = new char*[value.size()]; + if (!buffer) + return false; + for (size_t i = 0; i < value.size(); i++) + buffer[i] = BNAllocString(value[i].c_str()); + + bool result = BNSettingSetStringList(settingGroup.c_str(), + name.c_str(), + (const char**)buffer, + value.size(), + autoFlush); + + BNFreeStringList(buffer, value.size()); + return result; +} + +bool Setting::Set(const std::string& settingGroup, + const std::string& name, + double value, + bool autoFlush) +{ + return BNSettingSetDouble(settingGroup.c_str(), name.c_str(), value, autoFlush); +} + +bool Setting::FlushSettings() +{ + return BNSettingFlushSettings(); +}
\ No newline at end of file |
