diff options
| author | Brian Potchik <brian@vector35.com> | 2019-08-29 16:50:12 -0400 |
|---|---|---|
| committer | Brian Potchik <brian@vector35.com> | 2019-08-29 16:50:12 -0400 |
| commit | 29c4896cda6e0933a5acb5402ff9ec4fb9ea7e90 (patch) | |
| tree | 6bfb03a6c579e8df31078253d6ad8cdbaa2ec626 /settings.cpp | |
| parent | 6b0c2d2c4c0af274743f12ee523703d624529383 (diff) | |
Add settings API to query keys and json stringified values.
Diffstat (limited to 'settings.cpp')
| -rw-r--r-- | settings.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/settings.cpp b/settings.cpp index fdc74335..46119905 100644 --- a/settings.cpp +++ b/settings.cpp @@ -58,6 +58,21 @@ bool Settings::IsEmpty() } +vector<string> Settings::Keys() +{ + size_t size = 0; + char** outBuffer = (char**)BNSettingsKeysList(m_object, &size); + + vector<string> result; + result.reserve(size); + for (size_t i = 0; i < size; i++) + result.emplace_back(outBuffer[i]); + + BNFreeStringList(outBuffer, size); + return result; +} + + template<> vector<string> Settings::QueryProperty<vector<string>>(const string& key, const string& property) { size_t size = 0; @@ -232,6 +247,15 @@ template<> vector<string> Settings::Get<vector<string>>(const string& key, Ref<B } +string Settings::GetJson(const string& key, Ref<BinaryView> view, BNSettingsScope* scope) +{ + char* tmpStr = BNSettingsGetJsonString(m_object, key.c_str(), view ? view->GetObject() : nullptr, scope); + string result(tmpStr); + BNFreeString(tmpStr); + return result; +} + + bool Settings::Set(const string& key, bool value, Ref<BinaryView> view, BNSettingsScope scope) { return BNSettingsSetBool(m_object, view ? view->GetObject() : nullptr, scope, key.c_str(), value); |
