diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/djinterop/enginelibrary.cpp | 23 | ||||
-rw-r--r-- | src/djinterop/enginelibrary/el_storage.hpp | 4 | ||||
-rw-r--r-- | src/meson.build | 15 |
3 files changed, 27 insertions, 15 deletions
diff --git a/src/djinterop/enginelibrary.cpp b/src/djinterop/enginelibrary.cpp index 562b0f6..1c941e4 100644 --- a/src/djinterop/enginelibrary.cpp +++ b/src/djinterop/enginelibrary.cpp @@ -16,6 +16,7 @@ */ #include <cmath> +#include <fstream> #include <string> #include <djinterop/djinterop.hpp> @@ -41,6 +42,28 @@ database create_database( return database{std::make_shared<el_database_impl>(storage)}; } +database create_database_from_scripts( + const std::string& db_directory, const std::string& script_directory) +{ + std::string stmt; + + std::ifstream m_db_script{script_directory + "/m.db.sql"}; + sqlite::database m_db{db_directory + "/m.db"}; + while (std::getline(m_db_script, stmt)) + { + m_db << stmt; + } + + std::ifstream p_db_script{script_directory + "/p.db.sql"}; + sqlite::database p_db{db_directory + "/p.db"}; + while (std::getline(p_db_script, stmt)) + { + p_db << stmt; + } + + return load_database(db_directory); +} + database create_or_load_database( const std::string& directory, const semantic_version& schema_version, bool& created) diff --git a/src/djinterop/enginelibrary/el_storage.hpp b/src/djinterop/enginelibrary/el_storage.hpp index 8b9fdf6..b819fed 100644 --- a/src/djinterop/enginelibrary/el_storage.hpp +++ b/src/djinterop/enginelibrary/el_storage.hpp @@ -39,10 +39,10 @@ public: const std::string directory; // TODO - don't expose mutable SQLite connection - allow txn guard to be // obtained from el_storage by other EL classes. - mutable sqlite::database db; + sqlite::database db; const semantic_version version; - std::unique_ptr<schema::schema_creator_validator> schema_creator_validator; + const std::unique_ptr<schema::schema_creator_validator> schema_creator_validator; int64_t last_savepoint = 0; }; diff --git a/src/meson.build b/src/meson.build index 5c21f34..8424192 100644 --- a/src/meson.build +++ b/src/meson.build @@ -30,29 +30,18 @@ sources = [ ] # Dependencies required by the main library. -core_deps = [thread_dep, dl_dep, sqlite3_dep, zlib_dep, sqlite_modern_cpp_dep] - -# Used by unit tests to reference internal classes. -internal_inc = include_directories('.') +core_deps = [thread_dep, dl_dep, zlib_dep, sqlite3_dep, sqlite_modern_cpp_dep] # Set a compile-time definition that we are building the libdjinterop source. # This information is needed in `config.hpp` to determine whether public symbols # ought to be exported or imported. building_library_args = ['-DDJINTEROP_SOURCE'] -# Set hidden visibility arguments as required. -hidden_visibility_args = [] -if get_option('default_library') != 'static' - if cpp_compiler.has_argument('-fvisibility=hidden') - hidden_visibility_args = ['-fvisibility=hidden'] - endif -endif - djinterop_lib = library( 'djinterop', sources: sources, include_directories: inc, dependencies: core_deps, install: true, - cpp_args: building_library_args + hidden_visibility_args) + cpp_args: building_library_args) |