Compare commits

..

No commits in common. "1e8c4eac5f0a3cf5624df39c83b74941454f6d6b" and "0104e72997e852342daef6ddfc5645b4799d1933" have entirely different histories.

5 changed files with 1 additions and 117 deletions

View file

@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 3.8)
project(KIMA2)
set(CMAKE_MODULE_PATH "${CMAKE_HOME_DIRECTORY}/cmake" ${CMAKE_MODULE_PATH})
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

View file

@ -1,66 +0,0 @@
#ckwg +4
# Copyright 2010 by Kitware, Inc. All Rights Reserved. Please refer to
# KITWARE_LICENSE.TXT for licensing information, or contact General Counsel,
# Kitware, Inc., 28 Corporate Drive, Clifton Park, NY 12065.
# Locate the system installed SQLite3
# The following variables will be set:
#
# SQLite3_FOUND - Set to true if SQLite3 can be found
# SQLite3_INCLUDE_DIR - The path to the SQLite3 header files
# SQLite3_LIBRARY - The full path to the SQLite3 library
if( SQLite3_DIR )
if( SQLite3_FIND_VERSION )
find_package( SQLite3 ${SQLite3_FIND_VERSION} NO_MODULE)
else()
find_package( SQLite3 NO_MODULE)
endif()
elseif( NOT SQLite3_FOUND )
message(STATUS "Searching for sqlite3.h")
find_path( SQLite3_INCLUDE_DIR sqlite3.h )
message(STATUS "Searching for sqlite3.h - ${SQLite3_INCLUDE_DIR}")
message(STATUS "Searching for libsqlite3")
find_library( SQLite3_LIBRARY sqlite3 )
message(STATUS "Searching for libsqlite3 - ${SQLite3_LIBRARY}")
include( FindPackageHandleStandardArgs )
FIND_PACKAGE_HANDLE_STANDARD_ARGS( SQLite3 SQLite3_INCLUDE_DIR SQLite3_LIBRARY )
if( SQLITE3_FOUND )
# Determine the SQLite version found
file( READ ${SQLite3_INCLUDE_DIR}/sqlite3.h SQLite3_INCLUDE_FILE )
string( REGEX REPLACE
".*# *define *SQLITE_VERSION *\\\"([0-9\\.]+)\\\".*" "\\1"
SQLite3_VERSION "${SQLite3_INCLUDE_FILE}" )
string( REGEX REPLACE
"([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1"
SQLite3_VERSION_MAJOR "${SQLite3_VERSION}" )
string( REGEX REPLACE
"[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1"
SQLite3_VERSION_MINOR "${SQLite3_VERSION}" )
string( REGEX REPLACE
"[0-9]+\\.[0-9]+\\.([0-9])+" "\\1"
SQLite3_VERSION_PATCH "${SQLite3_VERSION}" )
# Determine version compatibility
if( SQLite3_FIND_VERSION )
if( SQLite3_FIND_VERSION_EXACT )
if( SQLite3_FIND_VERSION VERSION_EQUAL SQLite3_VERSION )
message( STATUS "SQLite3 version: ${SQLite3_VERSION}" )
set( SQLite3_FOUND TRUE )
endif()
else()
if( (SQLite3_FIND_VERSION VERSION_LESS SQLite3_VERSION) OR
(SQLite3_FIND_VERSION VERSION_EQUAL SQLite3_VERSION) )
message( STATUS "SQLite3 version: ${SQLite3_VERSION}" )
set( SQLite3_FOUND TRUE )
endif()
endif()
else()
message( STATUS "SQLite3 version: ${SQLite3_VERSION}" )
set( SQLite3_FOUND TRUE )
endif()
unset( SQLITE3_FOUND )
endif()
endif()

View file

@ -1,17 +1,13 @@
find_package(Boost 1.62 REQUIRED)
find_package(SQLite3 REQUIRED)
set(CORE_HEADERS
entity.h
database.h
)
set(CORE_SOURCES
entity.cpp
database.cpp
)
add_library(core STATIC ${CORE_SOURCES})
target_link_libraries(core Boost::boost)
target_link_libraries(core sqlite3)
target_link_libraries(core Boost::boost)

View file

@ -1,24 +0,0 @@
#include "database.h"
#include <stdexcept>
Database::Database(const std::string& dbname) : db(nullptr)
{
const int errCode = sqlite3_open(dbname.c_str(), &db);
if(errCode) {
throw std::runtime_error("Could not open database file.");
}
}
Database::~Database()
{
sqlite3_close(db);
}
void Database::exec(const std::string& sql)
{
const int errCode = sqlite3_exec(db, sql.c_str(), nullptr, nullptr, nullptr);
if(errCode) {
throw std::runtime_error("Error in SQL execution.");
}
}

View file

@ -1,20 +0,0 @@
#ifndef DATABASE_H
#define DATABASE_H
#include <string>
#include <sqlite3.h>
class Database
{
public:
Database(const std::string& dbname);
~Database();
Database(const Database&) = delete;
Database& operator=(const Database&) = delete;
void exec(const std::string& sql);
private:
sqlite3 *db;
};
#endif // DATABASE_H