diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-01-05 09:10:00 -0400 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-01-23 19:06:53 +0200 |
commit | eb772258cfa1af3a530ce9ff750c86aff20f96cf (patch) | |
tree | f4d575824f38c319bb3d10543a0729391ca5220c /platform | |
parent | b8863a6dcaed22719b519e9a889ab97e42e63a50 (diff) | |
download | qtlocation-mapboxgl-eb772258cfa1af3a530ce9ff750c86aff20f96cf.tar.gz |
[core] Replace sqlite3.h dependency in offline database
Diffstat (limited to 'platform')
-rw-r--r-- | platform/default/mbgl/storage/offline_database.cpp | 5 | ||||
-rw-r--r-- | platform/default/sqlite3.hpp | 8 |
2 files changed, 9 insertions, 4 deletions
diff --git a/platform/default/mbgl/storage/offline_database.cpp b/platform/default/mbgl/storage/offline_database.cpp index cdbb940057..9f531bcac4 100644 --- a/platform/default/mbgl/storage/offline_database.cpp +++ b/platform/default/mbgl/storage/offline_database.cpp @@ -7,7 +7,6 @@ #include <mbgl/util/logging.hpp> #include "sqlite3.hpp" -#include <sqlite3.h> namespace mbgl { @@ -57,13 +56,13 @@ void OfflineDatabase::ensureSchema() { removeExisting(); connect(mapbox::sqlite::ReadWrite | mapbox::sqlite::Create); } catch (mapbox::sqlite::Exception& ex) { - if (ex.code != SQLITE_CANTOPEN && ex.code != SQLITE_NOTADB) { + if (ex.code != mapbox::sqlite::Exception::Code::CANTOPEN && ex.code != mapbox::sqlite::Exception::Code::NOTADB) { Log::Error(Event::Database, "Unexpected error connecting to database: %s", ex.what()); throw; } try { - if (ex.code == SQLITE_NOTADB) { + if (ex.code == mapbox::sqlite::Exception::Code::NOTADB) { removeExisting(); } connect(mapbox::sqlite::ReadWrite | mapbox::sqlite::Create); diff --git a/platform/default/sqlite3.hpp b/platform/default/sqlite3.hpp index e09193592e..2cbc3cf48b 100644 --- a/platform/default/sqlite3.hpp +++ b/platform/default/sqlite3.hpp @@ -20,9 +20,15 @@ enum OpenFlag : int { }; struct Exception : std::runtime_error { + enum Code : int { + OK = 0, + CANTOPEN = 14, + NOTADB = 26 + }; + Exception(int err, const char *msg) : std::runtime_error(msg), code(err) {} Exception(int err, const std::string& msg) : std::runtime_error(msg), code(err) {} - const int code = 0; + const int code = OK; }; class DatabaseImpl; |