diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-04-30 13:47:03 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-04-30 13:47:03 +0200 |
commit | 9bbdba9eab28c2ba44002bada4b3bb1c0962bd90 (patch) | |
tree | 4a56a077b8597395dd0f38c5ab9cb0c87862afa1 /common/settings_json.cpp | |
parent | e95ece83335b85ed063f8ea903acc71d5a2fb995 (diff) | |
download | qtlocation-mapboxgl-9bbdba9eab28c2ba44002bada4b3bb1c0962bd90.tar.gz |
remove concept of settings object from library
Diffstat (limited to 'common/settings_json.cpp')
-rw-r--r-- | common/settings_json.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/common/settings_json.cpp b/common/settings_json.cpp new file mode 100644 index 0000000000..771d89e1a2 --- /dev/null +++ b/common/settings_json.cpp @@ -0,0 +1,46 @@ +#include "settings_json.hpp" +#include <rapidjson/prettywriter.h> +#include <rapidjson/filestream.h> +#include <rapidjson/document.h> +#include <stdio.h> + +using namespace llmr; + +Settings_JSON::Settings_JSON() { load(); } + +void Settings_JSON::load() { + FILE *settingsFile = fopen("/tmp/llmr-native.json", "r"); + if (settingsFile != NULL) { + rapidjson::FileStream is(settingsFile); + rapidjson::Document document; + document.ParseStream<0>(is); + if (document.IsArray()) { + longitude = document[rapidjson::SizeType(0)].GetDouble(); + latitude = document[1].GetDouble(); + zoom = document[2].GetDouble(); + angle = document[3].GetDouble(); + debug = document[4].GetBool(); + } + } +} + +void Settings_JSON::save() { + + rapidjson::FileStream s(fopen("/tmp/llmr-native.json", "w")); + rapidjson::PrettyWriter<rapidjson::FileStream> writer(s); + writer.StartArray(); + writer.Double(longitude); + writer.Double(latitude); + writer.Double(zoom); + writer.Double(angle); + writer.Bool(debug); + writer.EndArray(); +} + +void Settings_JSON::clear() { + longitude = 0; + latitude = 0; + zoom = 0; + angle = 0; + debug = false; +} |