summaryrefslogtreecommitdiff
path: root/settings.cpp
diff options
context:
space:
mode:
authorBrian Potchik <brian@vector35.com>2019-08-29 16:50:12 -0400
committerBrian Potchik <brian@vector35.com>2019-08-29 16:50:12 -0400
commit29c4896cda6e0933a5acb5402ff9ec4fb9ea7e90 (patch)
tree6bfb03a6c579e8df31078253d6ad8cdbaa2ec626 /settings.cpp
parent6b0c2d2c4c0af274743f12ee523703d624529383 (diff)
Add settings API to query keys and json stringified values.
Diffstat (limited to 'settings.cpp')
-rw-r--r--settings.cpp24
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);