summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-12-04 16:32:49 +0100
committerKonstantin Käfer <mail@kkaefer.com>2014-12-04 20:00:41 +0100
commitbff6aeb4da41dee1f5f1cfa0be81b6c257257253 (patch)
tree15d3ab4018ddd19851da4e065c7fd381ba1bc6be
parent97d7f065d60fa7cf7d36bc6015a11dccd99d64ab (diff)
downloadqtlocation-mapboxgl-bff6aeb4da41dee1f5f1cfa0be81b6c257257253.tar.gz
switch to plain file streams rather than JSON
-rw-r--r--platform/default/settings_json.cpp42
1 files changed, 16 insertions, 26 deletions
diff --git a/platform/default/settings_json.cpp b/platform/default/settings_json.cpp
index f81c75115e..9b2ae654a5 100644
--- a/platform/default/settings_json.cpp
+++ b/platform/default/settings_json.cpp
@@ -1,40 +1,30 @@
#include <mbgl/platform/default/settings_json.hpp>
-#include <rapidjson/prettywriter.h>
-#include <rapidjson/filestream.h>
-#include <rapidjson/document.h>
-#include <stdio.h>
+#include <fstream>
using namespace mbgl;
Settings_JSON::Settings_JSON() { load(); }
void Settings_JSON::load() {
- FILE *settingsFile = fopen("/tmp/mbgl-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();
- bearing = document[3].GetDouble();
- debug = document[4].GetBool();
- }
+ std::ifstream file("/tmp/mbgl-native.cfg");
+ if (file) {
+ file >> longitude;
+ file >> latitude;
+ file >> zoom;
+ file >> bearing;
+ file >> debug;
}
}
void Settings_JSON::save() {
-
- rapidjson::FileStream s(fopen("/tmp/mbgl-native.json", "w"));
- rapidjson::PrettyWriter<rapidjson::FileStream> writer(s);
- writer.StartArray();
- writer.Double(longitude);
- writer.Double(latitude);
- writer.Double(zoom);
- writer.Double(bearing);
- writer.Bool(debug);
- writer.EndArray();
+ std::ofstream file("/tmp/mbgl-native.cfg");
+ if (file) {
+ file << longitude << std::endl;
+ file << latitude << std::endl;
+ file << zoom << std::endl;
+ file << bearing << std::endl;
+ file << debug << std::endl;
+ }
}
void Settings_JSON::clear() {