build: Fixed clang errors and warnings, incremented storage version

This commit is contained in:
Eberhard Graether
2017-02-13 00:32:52 +01:00
parent 97fd40fe9b
commit 17d9c87a5d
9 changed files with 70 additions and 165 deletions
+4 -93
View File
@@ -9,7 +9,7 @@
#include "utility/text/TextAccess.h"
#include "utility/Version.h"
const size_t SqliteStorage::STORAGE_VERSION = 8;
const size_t SqliteStorage::STORAGE_VERSION = 9;
SqliteStorage::SqliteStorage(const FilePath& dbFilePath)
: m_dbFilePath(dbFilePath.canonical())
@@ -340,35 +340,6 @@ Id SqliteStorage::addNodeBookmark(const NodeBookmark& bookmark)
/*tokenName = utility::replace(tokenName, "\\", "/");
comment = utility::replace(comment, "\\", "/");*/
// for backwards compatibility
m_database.execDML(
"CREATE TABLE IF NOT EXISTS nodeBookmark("
"id INTEGER NOT NULL, "
"name TEXT, "
"comment TEXT, "
"timestamp TEXT, "
"category INTEGER, "
"PRIMARY KEY(id), "
"FOREIGN KEY(category) REFERENCES bookmarkCategory(id));"
);
m_database.execDML(
"CREATE TABLE IF NOT EXISTS nodeBookmarkToken("
"id INTEGER NOT NULL, "
"bookmarkId INTEGER NOT NULL, "
"name TEXT, "
"type INTEGER, "
"PRIMARY KEY(id), "
"FOREIGN KEY(bookmarkId) REFERENCES nodeBookmark(id) ON DELETE CASCADE);"
);
m_database.execDML(
"CREATE TABLE IF NOT EXISTS bookmarkCategory("
"id INTEGER NOT NULL, "
"name TEXT, "
"PRIMARY KEY(id));"
);
std::string statement = "INSERT INTO nodeBookmark(name, comment, timestamp, category) "
"VALUES (?, ?, ?, ?);";
@@ -397,7 +368,7 @@ Id SqliteStorage::addNodeBookmark(const NodeBookmark& bookmark)
stmt.execDML();
}
return id;
}
@@ -410,46 +381,6 @@ Id SqliteStorage::addEdgeBookmark(const EdgeBookmark& bookmark)
tokenName = utility::replace(tokenName, "'", "''");
comment = utility::replace(comment, "'", "''");
// for backwards compatibility
m_database.execDML(
"CREATE TABLE IF NOT EXISTS edgeBookmark("
"id INTEGER NOT NULL, "
"name TEXT, "
"comment TEXT, "
"timestamp TEXT, "
"category INTEGER, "
"PRIMARY KEY(id), "
"FOREIGN KEY(category) REFERENCES bookmarkCategory(id));"
);
m_database.execDML(
"CREATE TABLE IF NOT EXISTS edgeBookmarkToken("
"id INTEGER NOT NULL, "
"bookmarkId INTEGER NOT NULL, "
"name TEXT, "
"type INTEGER, "
"PRIMARY KEY(id), "
"FOREIGN KEY(bookmarkId) REFERENCES edgeBookmark(id) ON DELETE CASCADE);"
);
m_database.execDML(
"CREATE TABLE IF NOT EXISTS edgeBaseBookmark("
"id INTEGER NOT NULL, "
"edgeId INTEGER, "
"PRIMARY KEY(id), "
"FOREIGN KEY(edgeId) REFERENCES edgeBookmark(id) ON DELETE CASCADE);"
);
m_database.execDML(
"CREATE TABLE IF NOT EXISTS edgeBaseBookmarkToken("
"id INTEGER NOT NULL, "
"bookmarkId INTEGER NOT NULL, "
"name TEXT, "
"type INTEGER, "
"PRIMARY KEY(id), "
"FOREIGN KEY(bookmarkId) REFERENCES edgeBaseBookmark(id) ON DELETE CASCADE);"
);
std::string statement = "INSERT INTO edgeBookmark(name, comment, timestamp, category) "
"VALUES (?, ?, ?, ?);";
@@ -487,9 +418,6 @@ Id SqliteStorage::addEdgeBookmark(const EdgeBookmark& bookmark)
for (unsigned int i = 0; i < bookmark.getTokenNames().size(); i++)
{
std::string name = bookmark.getTokenNames()[i];
int type = bookmark.getTokenTypes()[i];
statement = "INSERT INTO edgeBaseBookmarkToken(bookmarkId, name, type) "
"VALUES (" + std::to_string(baseId) + ", ?, " + std::to_string(bookmark.getTokenTypes()[i]) + ");";
@@ -504,14 +432,6 @@ Id SqliteStorage::addEdgeBookmark(const EdgeBookmark& bookmark)
Id SqliteStorage::addBookmarkCategory(const std::string& name)
{
// for backwards compatibility
m_database.execDML(
"CREATE TABLE IF NOT EXISTS bookmarkCategory("
"id INTEGER NOT NULL, "
"name TEXT, "
"PRIMARY KEY(id));"
);
std::string statement = "INSERT INTO bookmarkCategory(name) "
"VALUES (?);";
@@ -1064,7 +984,7 @@ bool SqliteStorage::checkNodeBookmarkExistsByNames(const std::vector<std::string
insert = false;
}
return true;
}
@@ -1262,15 +1182,6 @@ void SqliteStorage::removeBookmarkCategory(Id id)
);
}
Id SqliteStorage::getTokenIdByName(const std::string& name) const
{
/*CppSQLite3Query q = m_database.execQuery((
"SELECT id FROM bookmark WHERE " + " foo " + ";"
).c_str());*/
return -1;
}
int SqliteStorage::getNodeCount() const
{
return executeScalar("SELECT COUNT(*) FROM node;");
@@ -1521,7 +1432,7 @@ void SqliteStorage::setupTables()
{
LOG_ERROR(std::to_string(e.errorCode()) + ": " + e.errorMessage());
throw(std::exception("fail"));
throw(std::exception());
// todo: cancel project creation and destroy created files, display message
}
-2
View File
@@ -150,8 +150,6 @@ public:
bool checkBookmarkCategoryExists(const std::string& name) const;
void removeBookmarkCategory(Id id);
Id getTokenIdByName(const std::string& name) const;
template <typename ResultType>
ResultType getFirstById(const Id id) const
{
@@ -63,6 +63,8 @@ StorageEdge StorageAccessProxy::getEdgeById(Id edgeId) const
{
return m_subject->getEdgeById(edgeId);
}
return StorageEdge();
}
bool StorageAccessProxy::checkEdgeExists(Id edgeId) const
+1 -1
View File
@@ -86,7 +86,7 @@ public:
virtual void removeEdgeBookmark(Id id);
virtual void editEdgeBookmark(const EdgeBookmark& bookmark);
virtual virtual std::vector<BookmarkCategory> getAllBookmarkCategories() const;
virtual std::vector<BookmarkCategory> getAllBookmarkCategories() const;
virtual bool checkBookmarkCategoryExists(const std::string& name) const;
virtual void removeBookmarkCategory(Id id);