[core] Replace sqlite3.h dependency in offline database

This commit is contained in:
Bruno de Oliveira Abinader
2017-01-05 09:10:00 -04:00
parent b8863a6dca
commit eb772258cf
2 changed files with 9 additions and 4 deletions

View File

@@ -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);

View File

@@ -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;