Files
Sourcetrail/src/lib/data/storage/sqlite/SqliteDatabaseIndex.cpp
T
malte_langkabel cad595a32c logic: add storage transformation to merge anonymous types and the respective typedef
* moved storage related classes to data/storage folder
* implemented recording c++ unions as NODE_UNION instead of just using NODE_TYPE
* added transformation to merge anonymous classes/structs/enums/unions and typedef nodes
* added tests for this transformation
* added setting for enabling/disabling this transformation
2017-07-18 15:14:43 +02:00

44 lines
1.0 KiB
C++

#include "data/storage/sqlite/SqliteDatabaseIndex.h"
#include "utility/logging/logging.h"
SqliteDatabaseIndex::SqliteDatabaseIndex(const std::string& indexName, const std::string& indexTarget)
: m_indexName(indexName)
, m_indexTarget(indexTarget)
{
}
SqliteDatabaseIndex::~SqliteDatabaseIndex()
{
}
void SqliteDatabaseIndex::createOnDatabase(CppSQLite3DB& database)
{
try
{
LOG_INFO_STREAM(<< "Creating database index \"" << m_indexName << "\"");
database.execDML((
"CREATE INDEX IF NOT EXISTS " + m_indexName + " ON " + m_indexTarget + ";"
).c_str());
}
catch (CppSQLite3Exception e)
{
LOG_ERROR(std::to_string(e.errorCode()) + ": " + e.errorMessage());
}
}
void SqliteDatabaseIndex::removeFromDatabase(CppSQLite3DB& database)
{
try
{
LOG_INFO_STREAM(<< "Removing database index \"" << m_indexName << "\"");
database.execDML((
"DROP INDEX IF EXISTS main." + m_indexName + ";"
).c_str());
}
catch (CppSQLite3Exception e)
{
LOG_ERROR(std::to_string(e.errorCode()) + ": " + e.errorMessage());
}
}