From bff6aeb4da41dee1f5f1cfa0be81b6c257257253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 4 Dec 2014 16:32:49 +0100 Subject: [PATCH] switch to plain file streams rather than JSON --- platform/default/settings_json.cpp | 42 ++++++++++++------------------ 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/platform/default/settings_json.cpp b/platform/default/settings_json.cpp index f81c75115..9b2ae654a 100644 --- a/platform/default/settings_json.cpp +++ b/platform/default/settings_json.cpp @@ -1,40 +1,30 @@ #include -#include -#include -#include -#include +#include 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 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() {