update open, close and clear API
This commit is contained in:
@@ -51,9 +51,9 @@ namespace sourcetrail
|
||||
const std::string& getLastError() const;
|
||||
void clearLastError();
|
||||
|
||||
bool openProject(const std::string& projectDirectory, const std::string& projectName);
|
||||
bool closeProject();
|
||||
bool clearProject();
|
||||
bool open(const std::string& databaseFilePath);
|
||||
bool close();
|
||||
bool clear();
|
||||
|
||||
bool isEmpty() const;
|
||||
bool isCompatible() const;
|
||||
@@ -101,8 +101,8 @@ namespace sourcetrail
|
||||
int addEdge(int sourceId, int targetId, EdgeKind edgeKind);
|
||||
void addSourceLocation(int elementId, const SourceRange& location, LocationKind kind);
|
||||
|
||||
std::string m_projectDirectory;
|
||||
std::string m_projectName;
|
||||
std::string m_projectFilePath;
|
||||
std::string m_databaseFilePath;
|
||||
std::shared_ptr<DatabaseStorage> m_storage;
|
||||
mutable std::string m_lastError;
|
||||
};
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "SourcetrailDBWriter.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
@@ -62,10 +63,17 @@ namespace sourcetrail
|
||||
m_lastError.clear();
|
||||
}
|
||||
|
||||
bool SourcetrailDBWriter::openProject(const std::string& projectDirectory, const std::string& projectName)
|
||||
bool SourcetrailDBWriter::open(const std::string& databaseFilePath)
|
||||
{
|
||||
m_projectDirectory = projectDirectory;
|
||||
m_projectName = projectName;
|
||||
m_databaseFilePath = databaseFilePath;
|
||||
|
||||
m_projectFilePath = databaseFilePath;
|
||||
const size_t pos = m_projectFilePath.rfind('.');
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
m_projectFilePath = m_projectFilePath.substr(0, pos);
|
||||
}
|
||||
m_projectFilePath += ".srctrlprj";
|
||||
|
||||
try
|
||||
{
|
||||
@@ -90,7 +98,7 @@ namespace sourcetrail
|
||||
{
|
||||
bool projectFileExists = false;
|
||||
{
|
||||
std::ifstream f(getProjectFilePath().c_str());
|
||||
std::ifstream f(m_projectFilePath.c_str());
|
||||
projectFileExists = f.good();
|
||||
f.close();
|
||||
}
|
||||
@@ -111,7 +119,7 @@ namespace sourcetrail
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SourcetrailDBWriter::closeProject()
|
||||
bool SourcetrailDBWriter::close()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -126,7 +134,7 @@ namespace sourcetrail
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SourcetrailDBWriter::clearProject()
|
||||
bool SourcetrailDBWriter::clear()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -582,15 +590,6 @@ namespace sourcetrail
|
||||
return serialized;
|
||||
}
|
||||
|
||||
std::string SourcetrailDBWriter::getProjectFilePath() const
|
||||
{
|
||||
return m_projectDirectory + "/" + m_projectName + ".srctrlprj";
|
||||
}
|
||||
std::string SourcetrailDBWriter::getDatabaseFilePath() const
|
||||
{
|
||||
return m_projectDirectory + "/" + m_projectName + ".srctrldb";
|
||||
}
|
||||
|
||||
void SourcetrailDBWriter::openDatabase()
|
||||
{
|
||||
if (m_storage)
|
||||
@@ -600,7 +599,7 @@ namespace sourcetrail
|
||||
|
||||
try
|
||||
{
|
||||
m_storage = DatabaseStorage::openDatabase(getDatabaseFilePath());
|
||||
m_storage = DatabaseStorage::openDatabase(m_databaseFilePath);
|
||||
}
|
||||
catch (CppSQLite3Exception e)
|
||||
{
|
||||
@@ -641,7 +640,7 @@ namespace sourcetrail
|
||||
try
|
||||
{
|
||||
std::ofstream fileStream;
|
||||
fileStream.open(getProjectFilePath(), std::ios::out);
|
||||
fileStream.open(m_projectFilePath, std::ios::out);
|
||||
fileStream << std::string(
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
|
||||
"<config>\n"
|
||||
|
||||
@@ -56,11 +56,11 @@ std::string getLastError();
|
||||
|
||||
void clearLastError();
|
||||
|
||||
bool openProject(std::string projectDirectory, std::string projectName);
|
||||
bool open(std::string databaseFilePath);
|
||||
|
||||
bool closeProject();
|
||||
bool close();
|
||||
|
||||
bool clearProject();
|
||||
bool clear();
|
||||
|
||||
bool isEmpty();
|
||||
|
||||
|
||||
@@ -88,19 +88,19 @@ void clearLastError()
|
||||
dbWriter.clearLastError();
|
||||
}
|
||||
|
||||
bool openProject(std::string projectDirectory, std::string projectName)
|
||||
bool open(std::string databaseFilePath)
|
||||
{
|
||||
return dbWriter.openProject(projectDirectory, projectName);
|
||||
return dbWriter.open(databaseFilePath);
|
||||
}
|
||||
|
||||
bool closeProject()
|
||||
bool close()
|
||||
{
|
||||
return dbWriter.closeProject();
|
||||
return dbWriter.close();
|
||||
}
|
||||
|
||||
bool clearProject()
|
||||
bool clear()
|
||||
{
|
||||
return dbWriter.clearProject();
|
||||
return dbWriter.clear();
|
||||
}
|
||||
|
||||
bool isEmpty()
|
||||
|
||||
Reference in New Issue
Block a user