From fc3fb39c90ab7fe5fccbe3f3bc0eb2645157bb96 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 13 Dec 2023 21:57:53 +0300 Subject: Switch to build2 --- libcommon/.gitignore | 3 + libcommon/Makefile.am | 5 - libcommon/buffer.hxx | 104 +++++++ libcommon/buildfile | 50 ++++ libcommon/common.cxx | 355 +++++++++++++++++++++++ libcommon/common.hxx | 47 ++++ libcommon/common.txx | 24 ++ libcommon/common/Makefile.am | 11 - libcommon/common/buffer.hxx | 104 ------- libcommon/common/common.cxx | 360 ------------------------ libcommon/common/common.hxx | 53 ---- libcommon/common/common.txx | 24 -- libcommon/common/concrete.hxx | 57 ---- libcommon/common/config-vc.h | 25 -- libcommon/common/config.h.in | 19 -- libcommon/common/config.hxx | 20 -- libcommon/common/export.hxx | 35 --- libcommon/common/libcommon-vc10.vcxproj | 174 ------------ libcommon/common/libcommon-vc10.vcxproj.filters | 19 -- libcommon/common/libcommon-vc11.vcxproj | 178 ------------ libcommon/common/libcommon-vc11.vcxproj.filters | 19 -- libcommon/common/libcommon-vc12.vcxproj | 182 ------------ libcommon/common/libcommon-vc12.vcxproj.filters | 19 -- libcommon/common/libcommon-vc8.vcproj | 352 ----------------------- libcommon/common/libcommon-vc9.vcproj | 359 ----------------------- libcommon/common/makefile | 166 ----------- libcommon/concrete.hxx | 57 ++++ libcommon/config.hxx.in | 14 + libcommon/export.hxx | 39 +++ libcommon/makefile | 31 -- 30 files changed, 693 insertions(+), 2212 deletions(-) create mode 100644 libcommon/.gitignore delete mode 100644 libcommon/Makefile.am create mode 100644 libcommon/buffer.hxx create mode 100644 libcommon/buildfile create mode 100644 libcommon/common.cxx create mode 100644 libcommon/common.hxx create mode 100644 libcommon/common.txx delete mode 100644 libcommon/common/Makefile.am delete mode 100644 libcommon/common/buffer.hxx delete mode 100644 libcommon/common/common.cxx delete mode 100644 libcommon/common/common.hxx delete mode 100644 libcommon/common/common.txx delete mode 100644 libcommon/common/concrete.hxx delete mode 100644 libcommon/common/config-vc.h delete mode 100644 libcommon/common/config.h.in delete mode 100644 libcommon/common/config.hxx delete mode 100644 libcommon/common/export.hxx delete mode 100644 libcommon/common/libcommon-vc10.vcxproj delete mode 100644 libcommon/common/libcommon-vc10.vcxproj.filters delete mode 100644 libcommon/common/libcommon-vc11.vcxproj delete mode 100644 libcommon/common/libcommon-vc11.vcxproj.filters delete mode 100644 libcommon/common/libcommon-vc12.vcxproj delete mode 100644 libcommon/common/libcommon-vc12.vcxproj.filters delete mode 100644 libcommon/common/libcommon-vc8.vcproj delete mode 100644 libcommon/common/libcommon-vc9.vcproj delete mode 100644 libcommon/common/makefile create mode 100644 libcommon/concrete.hxx create mode 100644 libcommon/config.hxx.in create mode 100644 libcommon/export.hxx delete mode 100644 libcommon/makefile (limited to 'libcommon') diff --git a/libcommon/.gitignore b/libcommon/.gitignore new file mode 100644 index 0000000..a994ddc --- /dev/null +++ b/libcommon/.gitignore @@ -0,0 +1,3 @@ +# Generated config header. +# +config.hxx diff --git a/libcommon/Makefile.am b/libcommon/Makefile.am deleted file mode 100644 index 18d287d..0000000 --- a/libcommon/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -# file : libcommon/Makefile.am -# license : GNU GPL v2; see accompanying LICENSE file - -SUBDIRS = __path__(dirs) -EXTRA_DIST = __file__(extra_dist) diff --git a/libcommon/buffer.hxx b/libcommon/buffer.hxx new file mode 100644 index 0000000..41b7e46 --- /dev/null +++ b/libcommon/buffer.hxx @@ -0,0 +1,104 @@ +// file : libcommon/buffer.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef LIBCOMMON_BUFFER_HXX +#define LIBCOMMON_BUFFER_HXX + +#include +#include // std::size_t +#include // std::{memcmp,memcpy} + +struct basic_buffer_base +{ + ~basic_buffer_base () + { + operator delete (data_); + } + + basic_buffer_base () + : data_ (0), size_ (0) + { + } + + basic_buffer_base (const void* data, std::size_t size) + : data_ (0), size_ (size) + { + data_ = operator new (size_); + std::memcpy (data_, data, size_); + } + + basic_buffer_base (const basic_buffer_base& y) + : data_ (0), size_ (0) + { + assign (y.data_, y.size_); + } + + basic_buffer_base& + operator= (const basic_buffer_base& y) + { + if (this != &y) + assign (y.data_, y.size_); + + return *this; + } + + void + assign (const void* data, std::size_t size) + { + if (size_ < size) + { + void *p (operator new (size)); + operator delete (data_); + data_ = p; + } + + std::memcpy (data_, data, size); + size_ = size; + } + + std::size_t + size () const + { + return size_; + } + + bool + operator== (const basic_buffer_base& y) const + { + return size_ == y.size_ && std::memcmp (data_, y.data_, size_) == 0; + } + +protected: + void* data_; + std::size_t size_; +}; + +template +struct basic_buffer: basic_buffer_base +{ + basic_buffer () + { + } + + basic_buffer (const T* data, std::size_t size) + : basic_buffer_base (data, size) + { + } + + T* + data () + { + return static_cast (data_); + } + + const T* + data () const + { + return static_cast (data_); + } +}; + +typedef basic_buffer buffer; +typedef basic_buffer ubuffer; + +#endif // LIBCOMMON_BUFFER_HXX diff --git a/libcommon/buildfile b/libcommon/buildfile new file mode 100644 index 0000000..eb61455 --- /dev/null +++ b/libcommon/buildfile @@ -0,0 +1,50 @@ +# file : libcommon/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import intf_libs = libodb%lib{odb} + +for db: $databases + import intf_libs += libodb-$db%lib{odb-$db} + +lib{common}: {hxx ixx txx cxx}{** -config} hxx{config} $intf_libs + +# Generated config file. +# +using autoconf + +hxx{config}: in{config} +{ + DATABASE_MYSQL = $mysql + DATABASE_SQLITE = $sqlite + DATABASE_PGSQL = $pgsql + DATABASE_ORACLE = $oracle + DATABASE_MSSQL = $mssql + MULTI_DATABASE = $multi +} + +# Build options. +# +cxx.poptions =+ "-I$out_root" "-I$src_root" + +{hbmia obja}{*}: cxx.poptions += -DLIBCOMMON_STATIC_BUILD +{hbmis objs}{*}: cxx.poptions += -DLIBCOMMON_SHARED_BUILD + +# Export options. +# +lib{common}: +{ + cxx.export.poptions = "-I$out_root" "-I$src_root" + cxx.export.libs = $intf_libs +} + +liba{common}: cxx.export.poptions += -DLIBCOMMON_STATIC +libs{common}: cxx.export.poptions += -DLIBCOMMON_SHARED + +# For pre-releases use the complete version to make sure they cannot +# be used in place of another pre-release or the final version. See +# the version module for details on the version.* variable values. +# +if $version.pre_release + lib{common}: bin.lib.version = "-$version.project_id" +else + lib{common}: bin.lib.version = "-$version.major.$version.minor" diff --git a/libcommon/common.cxx b/libcommon/common.cxx new file mode 100644 index 0000000..b3e4cfd --- /dev/null +++ b/libcommon/common.cxx @@ -0,0 +1,355 @@ +// file : libcommon/common.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +#include // std::exit +#include // std::move +#include + +#include + +#include +#include + +using namespace std; +using namespace odb::core; + + +// MySQL. +// +#if defined(DATABASE_MYSQL) + +#include +#include + +static unique_ptr +create_mysql_database (int& argc, char* argv[], bool, size_t max_connections) +{ + namespace mysql = odb::mysql; + + unique_ptr f; + + if (max_connections != 0) + f.reset (new mysql::connection_pool_factory (max_connections)); + + return unique_ptr ( + new mysql::database (argc, argv, false, "", 0, move (f))); +} +#endif // MySQL + + +// SQLite. +// +#if defined(DATABASE_SQLITE) + +#include +#include +#include +#include +#include + +static unique_ptr +create_sqlite_database (int& argc, + char* argv[], + bool schema, + size_t max_connections) +{ + namespace sqlite = odb::sqlite; + + unique_ptr f; + + if (max_connections != 0) + f.reset (new sqlite::connection_pool_factory (max_connections)); + + unique_ptr db ( + new sqlite::database ( + argc, argv, false, + SQLITE_OPEN_READWRITE + | SQLITE_OPEN_CREATE +#ifdef SQLITE_OPEN_URI + | SQLITE_OPEN_URI +#endif + , + true, + "", + move (f))); + + // Create the database schema. Due to bugs in SQLite foreign key + // support for DDL statements, we need to temporarily disable + // foreign keys. + // + if (schema) + { + connection_ptr c (db->connection ()); + + c->execute ("PRAGMA foreign_keys=OFF"); + + transaction t (c->begin ()); + schema_catalog::create_schema (*db); + t.commit (); + + c->execute ("PRAGMA foreign_keys=ON"); + } + + return db; +} +#endif // SQLite + + +// PostgreSQL. +// +#if defined(DATABASE_PGSQL) + +#include +#include + +static unique_ptr +create_pgsql_database (int& argc, char* argv[], bool, size_t max_connections) +{ + namespace pgsql = odb::pgsql; + + unique_ptr f; + + if (max_connections != 0) + f.reset (new pgsql::connection_pool_factory (max_connections)); + + return unique_ptr ( + new pgsql::database (argc, argv, false, "", move (f))); +} +#endif // PostgreSQL + + +// Oracle. +// +#if defined(DATABASE_ORACLE) + +#include +#include + +static unique_ptr +create_oracle_database (int& argc, char* argv[], bool, size_t max_connections) +{ + namespace oracle = odb::oracle; + + unique_ptr f; + + if (max_connections != 0) + f.reset (new oracle::connection_pool_factory (max_connections)); + + // Set client database character set and client national character set + // to UTF-8. + // + return unique_ptr ( + new oracle::database (argc, argv, false, 873, 873, 0, move (f))); +} +#endif // Oracle + +// SQL Server. +// +#if defined(DATABASE_MSSQL) + +#include +#include + +static unique_ptr +create_mssql_database (int& argc, char* argv[], bool, size_t max_connections) +{ + namespace mssql = odb::mssql; + + unique_ptr f; + + if (max_connections != 0) + f.reset (new mssql::connection_pool_factory (max_connections)); + + return unique_ptr ( + new mssql::database (argc, argv, false, "", + mssql::isolation_read_committed, 0, move (f))); +} +#endif // SQL Server + +// +// +unique_ptr +create_database (int argc, + char* argv[], + bool schema, + size_t max_connections, +#if defined(MULTI_DATABASE) + odb::database_id db +#else + odb::database_id +#endif +) +{ + char** argp = argv + 1; // Position of the next argument. Assignment for VC8. + int argn (argc - 1); // Number of arguments left. + +#if defined(MULTI_DATABASE) + // Figure out which database we are creating. We may be given the + // database name as a program argument or as an id. + // + if (db == odb::id_common && argn != 0) + { + string s (*argp); + + if (s == "mysql") + db = odb::id_mysql; + else if (s == "sqlite") + db = odb::id_sqlite; + else if (s == "pgsql") + db = odb::id_pgsql; + else if (s == "oracle") + db = odb::id_oracle; + else if (s == "mssql") + db = odb::id_mssql; + + if (db != odb::id_common) + { + argp++; + argn--; + } + } + + if (db == odb::id_common) + { + cerr << "Usage: " << argv[0] << " [options]" << endl; + exit (1); + } +#endif + + if (argn != 0 && *argp == string ("--help")) + { +#if defined(MULTI_DATABASE) + cout << "Usage: " << argv[0] << " [options]" << endl; +#else + cout << "Usage: " << argv[0] << " [options]" << endl; +#endif + + cout << "Options:" << endl; + +#if defined(MULTI_DATABASE) + switch (db) + { + case odb::id_mysql: +#if defined(DATABASE_MYSQL) + odb::mysql::database::print_usage (cout); +#else + assert (false); +#endif + break; + case odb::id_sqlite: +#if defined(DATABASE_SQLITE) + odb::sqlite::database::print_usage (cout); +#else + assert (false); +#endif + break; + case odb::id_pgsql: +#if defined(DATABASE_PGSQL) + odb::pgsql::database::print_usage (cout); +#else + assert (false); +#endif + break; + case odb::id_oracle: +#if defined(DATABASE_ORACLE) + odb::oracle::database::print_usage (cout); +#else + assert (false); +#endif + break; + case odb::id_mssql: +#if defined(DATABASE_MSSQL) + odb::mssql::database::print_usage (cout); +#else + assert (false); +#endif + break; + case odb::id_common: + assert (false); + } +#elif defined(DATABASE_MYSQL) + odb::mysql::database::print_usage (cout); +#elif defined(DATABASE_SQLITE) + odb::sqlite::database::print_usage (cout); +#elif defined(DATABASE_PGSQL) + odb::pgsql::database::print_usage (cout); +#elif defined(DATABASE_ORACLE) + odb::oracle::database::print_usage (cout); +#elif defined(DATABASE_MSSQL) + odb::mssql::database::print_usage (cout); +#else +# error unknown database +#endif + + exit (0); + } + +#if defined(MULTI_DATABASE) + switch (db) + { + case odb::id_mysql: +#if defined(DATABASE_MYSQL) + return create_mysql_database (argc, argv, schema, max_connections); +#else + assert (false); + break; +#endif + case odb::id_sqlite: +#if defined(DATABASE_SQLITE) + return create_sqlite_database (argc, argv, schema, max_connections); +#else + assert (false); + break; +#endif + case odb::id_pgsql: +#if defined(DATABASE_PGSQL) + return create_pgsql_database (argc, argv, schema, max_connections); +#else + assert (false); + break; +#endif + case odb::id_oracle: +#if defined(DATABASE_ORACLE) + return create_oracle_database (argc, argv, schema, max_connections); +#else + assert (false); + break; +#endif + case odb::id_mssql: +#if defined(DATABASE_MSSQL) + return create_mssql_database (argc, argv, schema, max_connections); +#else + assert (false); + break; +#endif + case odb::id_common: + assert (false); + } + return unique_ptr (); +#elif defined(DATABASE_MYSQL) + return create_mysql_database (argc, argv, schema, max_connections); +#elif defined(DATABASE_SQLITE) + return create_sqlite_database (argc, argv, schema, max_connections); +#elif defined(DATABASE_PGSQL) + return create_pgsql_database (argc, argv, schema, max_connections); +#elif defined(DATABASE_ORACLE) + return create_oracle_database (argc, argv, schema, max_connections); +#elif defined(DATABASE_MSSQL) + return create_mssql_database (argc, argv, schema, max_connections); +#else +# error unknown database +#endif +} + +bool +size_available () +{ +#if defined(MULTI_DATABASE) || \ + defined(DATABASE_SQLITE) || \ + defined(DATABASE_ORACLE) || \ + defined(DATABASE_MSSQL) + return false; +#else + return true; +#endif +} diff --git a/libcommon/common.hxx b/libcommon/common.hxx new file mode 100644 index 0000000..9ab978d --- /dev/null +++ b/libcommon/common.hxx @@ -0,0 +1,47 @@ +// file : libcommon/common.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef LIBCOMMON_COMMON_HXX +#define LIBCOMMON_COMMON_HXX + +#include // std::unique_ptr +#include // std::size_t + +#include +#include + +#include + +LIBCOMMON_SYMEXPORT std::unique_ptr +create_database (int argc, + char* argv[], + bool create_schema = true, + std::size_t max_connections = 0, + odb::database_id db = odb::id_common); + +template +std::unique_ptr +create_specific_database (int argc, + char* argv[], + bool create_schema = true, + std::size_t max_connections = 0) +{ + std::unique_ptr r ( + create_database (argc, argv, + create_schema, + max_connections, + T::database_id)); + + return std::unique_ptr (&dynamic_cast (*r.release ())); +} + +// This function returns an accurate result only if the result iterator +// hasn't been advanced and after the call the result is no longer valid. +// +template +std::size_t +size (odb::result); + +#include + +#endif // LIBCOMMON_COMMON_HXX diff --git a/libcommon/common.txx b/libcommon/common.txx new file mode 100644 index 0000000..caa7481 --- /dev/null +++ b/libcommon/common.txx @@ -0,0 +1,24 @@ +// file : libcommon/common.txx +// license : GNU GPL v2; see accompanying LICENSE file + +// We have to use this helper function instead of just checking which +// database is used because the DATABASE_* macro may not be defined +// in a project that includes this header. +// +LIBCOMMON_SYMEXPORT bool +size_available (); + +template +std::size_t +size (odb::result r) +{ + if (size_available ()) + return r.size (); + else + { + std::size_t n (0); + for (typename odb::result::iterator i (r.begin ()); i != r.end (); ++i) + n++; + return n; + } +} diff --git a/libcommon/common/Makefile.am b/libcommon/common/Makefile.am deleted file mode 100644 index 3ff50d5..0000000 --- a/libcommon/common/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -# file : libcommon/common/Makefile.am -# license : GNU GPL v2; see accompanying LICENSE file - -noinst_LTLIBRARIES = libcommon.la -libcommon_la_SOURCES = __path__(sources) __path__(headers) - -EXTRA_DIST = __file__(extra_dist) - -AM_CPPFLAGS = -I'$(top_builddir)/libcommon' -I'$(top_srcdir)/libcommon' -AM_CPPFLAGS += -DLIBCOMMON_DYNAMIC_LIB -AM_LDFLAGS = -no-undefined -rpath '$(libdir)' diff --git a/libcommon/common/buffer.hxx b/libcommon/common/buffer.hxx deleted file mode 100644 index 3d82915..0000000 --- a/libcommon/common/buffer.hxx +++ /dev/null @@ -1,104 +0,0 @@ -// file : libcommon/common/buffer.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef LIBCOMMON_COMMON_BUFFER_HXX -#define LIBCOMMON_COMMON_BUFFER_HXX - -#include -#include // std::size_t -#include // std::{memcmp,memcpy} - -struct basic_buffer_base -{ - ~basic_buffer_base () - { - operator delete (data_); - } - - basic_buffer_base () - : data_ (0), size_ (0) - { - } - - basic_buffer_base (const void* data, std::size_t size) - : data_ (0), size_ (size) - { - data_ = operator new (size_); - std::memcpy (data_, data, size_); - } - - basic_buffer_base (const basic_buffer_base& y) - : data_ (0), size_ (0) - { - assign (y.data_, y.size_); - } - - basic_buffer_base& - operator= (const basic_buffer_base& y) - { - if (this != &y) - assign (y.data_, y.size_); - - return *this; - } - - void - assign (const void* data, std::size_t size) - { - if (size_ < size) - { - void *p (operator new (size)); - operator delete (data_); - data_ = p; - } - - std::memcpy (data_, data, size); - size_ = size; - } - - std::size_t - size () const - { - return size_; - } - - bool - operator== (const basic_buffer_base& y) const - { - return size_ == y.size_ && std::memcmp (data_, y.data_, size_) == 0; - } - -protected: - void* data_; - std::size_t size_; -}; - -template -struct basic_buffer: basic_buffer_base -{ - basic_buffer () - { - } - - basic_buffer (const T* data, std::size_t size) - : basic_buffer_base (data, size) - { - } - - T* - data () - { - return static_cast (data_); - } - - const T* - data () const - { - return static_cast (data_); - } -}; - -typedef basic_buffer buffer; -typedef basic_buffer ubuffer; - -#endif // LIBCOMMON_COMMON_BUFFER_HXX diff --git a/libcommon/common/common.cxx b/libcommon/common/common.cxx deleted file mode 100644 index 4b8afe1..0000000 --- a/libcommon/common/common.cxx +++ /dev/null @@ -1,360 +0,0 @@ -// file : libcommon/common/common.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -#include // std::exit -#include // std::move -#include - -#include - -#include -#include - -using namespace std; -using namespace odb::core; - - -// MySQL. -// -#if defined(DATABASE_MYSQL) || defined(DATABASE_COMMON) - -#include -#include - -static auto_ptr -create_mysql_database (int& argc, char* argv[], bool, size_t max_connections) -{ - namespace mysql = odb::mysql; - -#ifdef HAVE_CXX11 - unique_ptr f; -#else - auto_ptr f; -#endif - - if (max_connections != 0) - f.reset (new mysql::connection_pool_factory (max_connections)); - - return auto_ptr ( - new mysql::database (argc, argv, false, "", 0, -#ifdef HAVE_CXX11 - move (f) -#else - f -#endif - )); -} -#endif // MySQL - - -// SQLite. -// -#if defined(DATABASE_SQLITE) || defined(DATABASE_COMMON) - -#include -#include -#include -#include -#include - -static auto_ptr -create_sqlite_database (int& argc, - char* argv[], - bool schema, - size_t max_connections) -{ - namespace sqlite = odb::sqlite; - -#ifdef HAVE_CXX11 - unique_ptr f; -#else - auto_ptr f; -#endif - - if (max_connections != 0) - f.reset (new sqlite::connection_pool_factory (max_connections)); - - auto_ptr db ( - new sqlite::database ( - argc, argv, false, - SQLITE_OPEN_READWRITE - | SQLITE_OPEN_CREATE -#ifdef SQLITE_OPEN_URI - | SQLITE_OPEN_URI -#endif - , - true, - "", -#ifdef HAVE_CXX11 - move (f) -#else - f -#endif - )); - - // Create the database schema. Due to bugs in SQLite foreign key - // support for DDL statements, we need to temporarily disable - // foreign keys. - // - if (schema) - { - connection_ptr c (db->connection ()); - - c->execute ("PRAGMA foreign_keys=OFF"); - - transaction t (c->begin ()); - schema_catalog::create_schema (*db); - t.commit (); - - c->execute ("PRAGMA foreign_keys=ON"); - } - - return db; -} -#endif // SQLite - - -// PostgreSQL. -// -#if defined(DATABASE_PGSQL) || defined(DATABASE_COMMON) - -#include -#include - -static auto_ptr -create_pgsql_database (int& argc, char* argv[], bool, size_t max_connections) -{ - namespace pgsql = odb::pgsql; - -#ifdef HAVE_CXX11 - unique_ptr f; -#else - auto_ptr f; -#endif - - if (max_connections != 0) - f.reset (new pgsql::connection_pool_factory (max_connections)); - - return auto_ptr ( - new pgsql::database (argc, argv, false, "", -#ifdef HAVE_CXX11 - move (f) -#else - f -#endif - )); -} -#endif // PostgreSQL - - -// Oracle. -// -#if defined(DATABASE_ORACLE) || defined(DATABASE_COMMON) - -#include -#include - -static auto_ptr -create_oracle_database (int& argc, char* argv[], bool, size_t max_connections) -{ - namespace oracle = odb::oracle; - -#ifdef HAVE_CXX11 - unique_ptr f; -#else - auto_ptr f; -#endif - - if (max_connections != 0) - f.reset (new oracle::connection_pool_factory (max_connections)); - - // Set client database character set and client national character set - // to UTF-8. - // - return auto_ptr ( - new oracle::database (argc, argv, false, 873, 873, 0, -#ifdef HAVE_CXX11 - move (f) -#else - f -#endif - )); -} -#endif // Oracle - -// SQL Server. -// -#if defined(DATABASE_MSSQL) || defined(DATABASE_COMMON) - -#include -#include - -static auto_ptr -create_mssql_database (int& argc, char* argv[], bool, size_t max_connections) -{ - namespace mssql = odb::mssql; - -#ifdef HAVE_CXX11 - unique_ptr f; -#else - auto_ptr f; -#endif - - if (max_connections != 0) - f.reset (new mssql::connection_pool_factory (max_connections)); - - return auto_ptr ( - new mssql::database (argc, argv, false, "", - mssql::isolation_read_committed, 0, - -#ifdef HAVE_CXX11 - move (f) -#else - f -#endif - )); -} -#endif // SQL Server - -// -// -auto_ptr -create_database (int argc, - char* argv[], - bool schema, - size_t max_connections, -#if defined(DATABASE_COMMON) - odb::database_id db -#else - odb::database_id -#endif -) -{ - char** argp = argv + 1; // Position of the next argument. Assignment for VC8. - int argn (argc - 1); // Number of arguments left. - -#if defined(DATABASE_COMMON) - // Figure out which database we are creating. We may be given the - // database name as a program argument or as an id. - // - if (db == odb::id_common && argn != 0) - { - string s (*argp); - - if (s == "mysql") - db = odb::id_mysql; - else if (s == "sqlite") - db = odb::id_sqlite; - else if (s == "pgsql") - db = odb::id_pgsql; - else if (s == "oracle") - db = odb::id_oracle; - else if (s == "mssql") - db = odb::id_mssql; - - if (db != odb::id_common) - { - argp++; - argn--; - } - } - - if (db == odb::id_common) - { - cerr << "Usage: " << argv[0] << " [options]" << endl; - exit (1); - } -#endif - - if (argn != 0 && *argp == string ("--help")) - { -#if defined(DATABASE_COMMON) - cout << "Usage: " << argv[0] << " [options]" << endl; -#else - cout << "Usage: " << argv[0] << " [options]" << endl; -#endif - - cout << "Options:" << endl; - -#if defined(DATABASE_MYSQL) - odb::mysql::database::print_usage (cout); -#elif defined(DATABASE_SQLITE) - odb::sqlite::database::print_usage (cout); -#elif defined(DATABASE_PGSQL) - odb::pgsql::database::print_usage (cout); -#elif defined(DATABASE_ORACLE) - odb::oracle::database::print_usage (cout); -#elif defined(DATABASE_MSSQL) - odb::mssql::database::print_usage (cout); -#elif defined(DATABASE_COMMON) - switch (db) - { - case odb::id_mysql: - odb::mysql::database::print_usage (cout); - break; - case odb::id_sqlite: - odb::sqlite::database::print_usage (cout); - break; - case odb::id_pgsql: - odb::pgsql::database::print_usage (cout); - break; - case odb::id_oracle: - odb::oracle::database::print_usage (cout); - break; - case odb::id_mssql: - odb::mssql::database::print_usage (cout); - break; - case odb::id_common: - assert (false); - } -#else -# error unknown database -#endif - - exit (0); - } - -#if defined(DATABASE_MYSQL) - return create_mysql_database (argc, argv, schema, max_connections); -#elif defined(DATABASE_SQLITE) - return create_sqlite_database (argc, argv, schema, max_connections); -#elif defined(DATABASE_PGSQL) - return create_pgsql_database (argc, argv, schema, max_connections); -#elif defined(DATABASE_ORACLE) - return create_oracle_database (argc, argv, schema, max_connections); -#elif defined(DATABASE_MSSQL) - return create_mssql_database (argc, argv, schema, max_connections); -#elif defined(DATABASE_COMMON) - switch (db) - { - case odb::id_mysql: - return create_mysql_database (argc, argv, schema, max_connections); - case odb::id_sqlite: - return create_sqlite_database (argc, argv, schema, max_connections); - case odb::id_pgsql: - return create_pgsql_database (argc, argv, schema, max_connections); - case odb::id_oracle: - return create_oracle_database (argc, argv, schema, max_connections); - case odb::id_mssql: - return create_mssql_database (argc, argv, schema, max_connections); - case odb::id_common: - assert (false); - } - return auto_ptr (); -#else -# error unknown database -#endif -} - -bool -size_available () -{ -#if defined(DATABASE_SQLITE) || \ - defined(DATABASE_ORACLE) || \ - defined(DATABASE_MSSQL) || \ - defined(DATABASE_COMMON) - return false; -#else - return true; -#endif -} diff --git a/libcommon/common/common.hxx b/libcommon/common/common.hxx deleted file mode 100644 index 21672b1..0000000 --- a/libcommon/common/common.hxx +++ /dev/null @@ -1,53 +0,0 @@ -// file : libcommon/common/common.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef LIBCOMMON_COMMON_COMMON_HXX -#define LIBCOMMON_COMMON_COMMON_HXX - -#include // std::auto_ptr -#include // std::size_t - -#include // odb::database -#include - -#include - -// Make sure assert() is not disabled. -// -#ifdef NDEBUG -# error ODB tests require enabled assert(); un-define the NDEBUG macro -#endif - -LIBCOMMON_EXPORT std::auto_ptr -create_database (int argc, - char* argv[], - bool create_schema = true, - std::size_t max_connections = 0, - odb::database_id db = odb::id_common); - -template -std::auto_ptr -create_specific_database (int argc, - char* argv[], - bool create_schema = true, - std::size_t max_connections = 0) -{ - std::auto_ptr r ( - create_database (argc, argv, - create_schema, - max_connections, - T::database_id)); - - return std::auto_ptr (&dynamic_cast (*r.release ())); -} - -// This function returns an accurate result only if the result iterator -// hasn't been advanced and after the call the result is no longer valid. -// -template -std::size_t -size (odb::result); - -#include - -#endif // LIBCOMMON_COMMON_COMMON_HXX diff --git a/libcommon/common/common.txx b/libcommon/common/common.txx deleted file mode 100644 index 9dd2a35..0000000 --- a/libcommon/common/common.txx +++ /dev/null @@ -1,24 +0,0 @@ -// file : libcommon/common/common.txx -// license : GNU GPL v2; see accompanying LICENSE file - -// We have to use this helper function instead of just checking which -// database is used because the DATABASE_* macro may not be defined -// in a project that includes this header. -// -LIBCOMMON_EXPORT bool -size_available (); - -template -std::size_t -size (odb::result r) -{ - if (size_available ()) - return r.size (); - else - { - std::size_t n (0); - for (typename odb::result::iterator i (r.begin ()); i != r.end (); ++i) - n++; - return n; - } -} diff --git a/libcommon/common/concrete.hxx b/libcommon/common/concrete.hxx deleted file mode 100644 index 2014b24..0000000 --- a/libcommon/common/concrete.hxx +++ /dev/null @@ -1,57 +0,0 @@ -// file : libcommon/common/concrete.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef LIBCOMMON_COMMON_CONCRETE_HXX -#define LIBCOMMON_COMMON_CONCRETE_HXX - -#include - -// Namespace alias for the concrete database namespace. -// -#if defined(DATABASE_MYSQL) - -#include -#include - -namespace odb_db = odb::mysql; - -#elif defined(DATABASE_SQLITE) - -#include -#include - -namespace odb_db = odb::sqlite; - -#elif defined(DATABASE_PGSQL) - -#include -#include - -namespace odb_db = odb::pgsql; - -#elif defined(DATABASE_ORACLE) - -#include -#include - -namespace odb_db = odb::oracle; - -#elif defined(DATABASE_MSSQL) - -#include -#include - -namespace odb_db = odb::mssql; - -#elif defined(DATABASE_COMMON) - -// Fallback to common interface. -// -#include -#include - -namespace odb_db = odb; - -#endif - -#endif // LIBCOMMON_COMMON_CONCRETE_HXX diff --git a/libcommon/common/config-vc.h b/libcommon/common/config-vc.h deleted file mode 100644 index 16d89a0..0000000 --- a/libcommon/common/config-vc.h +++ /dev/null @@ -1,25 +0,0 @@ -/* file : libcommon/common/config-vc.h - * license : GNU GPL v2; see accompanying LICENSE file - */ - -/* Configuration file for Windows/VC++. */ - -#ifndef LIBCOMMON_COMMON_CONFIG_VC_H -#define LIBCOMMON_COMMON_CONFIG_VC_H - -#define HAVE_TR1_MEMORY - -/* VC++10 and later has C++11 always enabled. - */ -#if (defined(_MSC_VER) && _MSC_VER >= 1600) || \ - (defined(ODB_MSC_VER) && ODB_MSC_VER >= 1600) -# define HAVE_CXX11 -// Strongly typed enums are supported starting from VC++11. -// -# if (defined(_MSC_VER) && _MSC_VER >= 1700) || \ - (defined(ODB_MSC_VER) && ODB_MSC_VER >= 1700) -# define HAVE_CXX11_ENUM -# endif -#endif - -#endif /* LIBCOMMON_COMMON_CONFIG_VC_H */ diff --git a/libcommon/common/config.h.in b/libcommon/common/config.h.in deleted file mode 100644 index 9d3e0fc..0000000 --- a/libcommon/common/config.h.in +++ /dev/null @@ -1,19 +0,0 @@ -/* file : libcommon/common/config.h.in - * license : GNU GPL v2; see accompanying LICENSE file - */ - -/* This file is automatically processed by configure. */ - -#ifndef LIBCOMMON_COMMON_CONFIG_H -#define LIBCOMMON_COMMON_CONFIG_H - -#undef DATABASE_MYSQL -#undef DATABASE_SQLITE -#undef DATABASE_PGSQL -#undef DATABASE_ORACLE -#undef DATABASE_MSSQL -#undef HAVE_TR1_MEMORY -#undef HAVE_CXX11 -#undef LIBCOMMON_STATIC_LIB - -#endif /* LIBCOMMON_COMMON_CONFIG_H */ diff --git a/libcommon/common/config.hxx b/libcommon/common/config.hxx deleted file mode 100644 index 5c6d938..0000000 --- a/libcommon/common/config.hxx +++ /dev/null @@ -1,20 +0,0 @@ -// file : libcommon/common/config.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef LIBCOMMON_COMMON_CONFIG_HXX -#define LIBCOMMON_COMMON_CONFIG_HXX - -#ifdef HAVE_CONFIG_VC_H -# include -#else -# include - -// GCC supports strongly typed enums from 4.4 (forward -- 4.6), -// Clang -- 2.9 (3.1). -// -# ifdef HAVE_CXX11 -# define HAVE_CXX11_ENUM -# endif -#endif - -#endif // LIBCOMMON_COMMON_CONFIG_HXX diff --git a/libcommon/common/export.hxx b/libcommon/common/export.hxx deleted file mode 100644 index 926d7a5..0000000 --- a/libcommon/common/export.hxx +++ /dev/null @@ -1,35 +0,0 @@ -// file : libcommon/common/export.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef LIBCOMMON_COMMON_EXPORT_HXX -#define LIBCOMMON_COMMON_EXPORT_HXX - -#include - -#ifdef LIBCOMMON_STATIC_LIB -# define LIBCOMMON_EXPORT -#else -# ifdef _WIN32 -# ifdef _MSC_VER -# ifdef LIBCOMMON_DYNAMIC_LIB -# define LIBCOMMON_EXPORT __declspec(dllexport) -# else -# define LIBCOMMON_EXPORT __declspec(dllimport) -# endif -# else -# ifdef LIBCOMMON_DYNAMIC_LIB -# ifdef DLL_EXPORT -# define LIBCOMMON_EXPORT __declspec(dllexport) -# else -# define LIBCOMMON_EXPORT -# endif -# else -# define LIBCOMMON_EXPORT __declspec(dllimport) -# endif -# endif -# else -# define LIBCOMMON_EXPORT -# endif -#endif - -#endif // LIBCOMMON_COMMON_EXPORT_HXX diff --git a/libcommon/common/libcommon-vc10.vcxproj b/libcommon/common/libcommon-vc10.vcxproj deleted file mode 100644 index a07a9a6..0000000 --- a/libcommon/common/libcommon-vc10.vcxproj +++ /dev/null @@ -1,174 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {019C2E51-BF41-4490-AB96-4156741B8CC9} - Win32Proj - libcommon - - - - DynamicLibrary - true - Unicode - - - DynamicLibrary - true - Unicode - - - DynamicLibrary - false - true - Unicode - - - DynamicLibrary - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - ..\bin\ - common-d - - - true - ..\bin64\ - common-d - - - false - ..\bin\ - common - - - false - ..\bin64\ - common - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;HAVE_CONFIG_VC_H;__upcase__(database_)__upcase__(__value__(database));LIBCOMMON_DYNAMIC_LIB;%(PreprocessorDefinitions) - .. - 4355;4800;4290;4251;%(DisableSpecificWarnings) - - - odb-__value__(database)-d.lib;odb-d.lib;%(AdditionalDependencies) - Windows - true - $(TargetPath) - ..\lib\common-d.lib - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;HAVE_CONFIG_VC_H;__upcase__(database_)__upcase__(__value__(database));LIBCOMMON_DYNAMIC_LIB;%(PreprocessorDefinitions) - .. - 4355;4800;4290;4251;%(DisableSpecificWarnings) - - - odb-__value__(database)-d.lib;odb-d.lib;%(AdditionalDependencies) - Windows - true - $(TargetPath) - ..\lib64\common-d.lib - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_WINDOWS;_USRDLL;HAVE_CONFIG_VC_H;__upcase__(database_)__upcase__(__value__(database));LIBCOMMON_DYNAMIC_LIB;%(PreprocessorDefinitions) - .. - 4355;4800;4290;4251;%(DisableSpecificWarnings) - - - odb-__value__(database).lib;odb.lib;%(AdditionalDependencies) - Windows - true - true - true - $(TargetPath) - ..\lib\common.lib - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_WINDOWS;_USRDLL;HAVE_CONFIG_VC_H;__upcase__(database_)__upcase__(__value__(database));LIBCOMMON_DYNAMIC_LIB;%(PreprocessorDefinitions) - .. - 4355;4800;4290;4251;%(DisableSpecificWarnings) - - - odb-__value__(database).lib;odb.lib;%(AdditionalDependencies) - Windows - true - true - true - $(TargetPath) - ..\lib64\common.lib - - - -__header_entries__(headers) - - -__source_entries__(sources) - - - - - diff --git a/libcommon/common/libcommon-vc10.vcxproj.filters b/libcommon/common/libcommon-vc10.vcxproj.filters deleted file mode 100644 index ecc3613..0000000 --- a/libcommon/common/libcommon-vc10.vcxproj.filters +++ /dev/null @@ -1,19 +0,0 @@ - - - - - {6B7BDACA-0BDC-48B2-B5BD-BEFC5826ABC9} - cxx - - - {F2B8743C-E39C-4FE0-AA8F-FF7FA2DA7191} - h;hxx;ixx;txx - - - -__header_filter_entries__(headers) - - -__source_filter_entries__(sources) - - diff --git a/libcommon/common/libcommon-vc11.vcxproj b/libcommon/common/libcommon-vc11.vcxproj deleted file mode 100644 index c5a6758..0000000 --- a/libcommon/common/libcommon-vc11.vcxproj +++ /dev/null @@ -1,178 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {019C2E51-BF41-4490-AB96-4156741B8CC9} - Win32Proj - libcommon - - - - DynamicLibrary - true - v110 - Unicode - - - DynamicLibrary - true - v110 - Unicode - - - DynamicLibrary - false - v110 - true - Unicode - - - DynamicLibrary - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - ..\bin\ - common-d - - - true - ..\bin64\ - common-d - - - false - ..\bin\ - common - - - false - ..\bin64\ - common - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;HAVE_CONFIG_VC_H;__upcase__(database_)__upcase__(__value__(database));LIBCOMMON_DYNAMIC_LIB;%(PreprocessorDefinitions) - .. - 4355;4800;4290;4251;%(DisableSpecificWarnings) - - - odb-__value__(database)-d.lib;odb-d.lib;%(AdditionalDependencies) - Windows - true - $(TargetPath) - ..\lib\common-d.lib - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;HAVE_CONFIG_VC_H;__upcase__(database_)__upcase__(__value__(database));LIBCOMMON_DYNAMIC_LIB;%(PreprocessorDefinitions) - .. - 4355;4800;4290;4251;%(DisableSpecificWarnings) - - - odb-__value__(database)-d.lib;odb-d.lib;%(AdditionalDependencies) - Windows - true - $(TargetPath) - ..\lib64\common-d.lib - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_WINDOWS;_USRDLL;HAVE_CONFIG_VC_H;__upcase__(database_)__upcase__(__value__(database));LIBCOMMON_DYNAMIC_LIB;%(PreprocessorDefinitions) - .. - 4355;4800;4290;4251;%(DisableSpecificWarnings) - - - odb-__value__(database).lib;odb.lib;%(AdditionalDependencies) - Windows - true - true - true - $(TargetPath) - ..\lib\common.lib - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_WINDOWS;_USRDLL;HAVE_CONFIG_VC_H;__upcase__(database_)__upcase__(__value__(database));LIBCOMMON_DYNAMIC_LIB;%(PreprocessorDefinitions) - .. - 4355;4800;4290;4251;%(DisableSpecificWarnings) - - - odb-__value__(database).lib;odb.lib;%(AdditionalDependencies) - Windows - true - true - true - $(TargetPath) - ..\lib64\common.lib - - - -__header_entries__(headers) - - -__source_entries__(sources) - - - - - diff --git a/libcommon/common/libcommon-vc11.vcxproj.filters b/libcommon/common/libcommon-vc11.vcxproj.filters deleted file mode 100644 index ecc3613..0000000 --- a/libcommon/common/libcommon-vc11.vcxproj.filters +++ /dev/null @@ -1,19 +0,0 @@ - - - - - {6B7BDACA-0BDC-48B2-B5BD-BEFC5826ABC9} - cxx - - - {F2B8743C-E39C-4FE0-AA8F-FF7FA2DA7191} - h;hxx;ixx;txx - - - -__header_filter_entries__(headers) - - -__source_filter_entries__(sources) - - diff --git a/libcommon/common/libcommon-vc12.vcxproj b/libcommon/common/libcommon-vc12.vcxproj deleted file mode 100644 index e577c79..0000000 --- a/libcommon/common/libcommon-vc12.vcxproj +++ /dev/null @@ -1,182 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {019C2E51-BF41-4490-AB96-4156741B8CC9} - Win32Proj - libcommon - - - - DynamicLibrary - true - v120 - Unicode - - - DynamicLibrary - true - v120 - Unicode - - - DynamicLibrary - false - v120 - true - Unicode - - - DynamicLibrary - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - ..\bin\ - common-d - - - true - ..\bin64\ - common-d - - - false - ..\bin\ - common - - - false - ..\bin64\ - common - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;HAVE_CONFIG_VC_H;__upcase__(database_)__upcase__(__value__(database));LIBCOMMON_DYNAMIC_LIB;%(PreprocessorDefinitions) - .. - 4355;4800;4290;4251;%(DisableSpecificWarnings) - true - - - odb-__value__(database)-d.lib;odb-d.lib;%(AdditionalDependencies) - Windows - true - $(TargetPath) - ..\lib\common-d.lib - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;HAVE_CONFIG_VC_H;__upcase__(database_)__upcase__(__value__(database));LIBCOMMON_DYNAMIC_LIB;%(PreprocessorDefinitions) - .. - 4355;4800;4290;4251;%(DisableSpecificWarnings) - true - - - odb-__value__(database)-d.lib;odb-d.lib;%(AdditionalDependencies) - Windows - true - $(TargetPath) - ..\lib64\common-d.lib - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_WINDOWS;_USRDLL;HAVE_CONFIG_VC_H;__upcase__(database_)__upcase__(__value__(database));LIBCOMMON_DYNAMIC_LIB;%(PreprocessorDefinitions) - .. - 4355;4800;4290;4251;%(DisableSpecificWarnings) - true - - - odb-__value__(database).lib;odb.lib;%(AdditionalDependencies) - Windows - true - true - true - $(TargetPath) - ..\lib\common.lib - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_WINDOWS;_USRDLL;HAVE_CONFIG_VC_H;__upcase__(database_)__upcase__(__value__(database));LIBCOMMON_DYNAMIC_LIB;%(PreprocessorDefinitions) - .. - 4355;4800;4290;4251;%(DisableSpecificWarnings) - true - - - odb-__value__(database).lib;odb.lib;%(AdditionalDependencies) - Windows - true - true - true - $(TargetPath) - ..\lib64\common.lib - - - -__header_entries__(headers) - - -__source_entries__(sources) - - - - - diff --git a/libcommon/common/libcommon-vc12.vcxproj.filters b/libcommon/common/libcommon-vc12.vcxproj.filters deleted file mode 100644 index ecc3613..0000000 --- a/libcommon/common/libcommon-vc12.vcxproj.filters +++ /dev/null @@ -1,19 +0,0 @@ - - - - - {6B7BDACA-0BDC-48B2-B5BD-BEFC5826ABC9} - cxx - - - {F2B8743C-E39C-4FE0-AA8F-FF7FA2DA7191} - h;hxx;ixx;txx - - - -__header_filter_entries__(headers) - - -__source_filter_entries__(sources) - - diff --git a/libcommon/common/libcommon-vc8.vcproj b/libcommon/common/libcommon-vc8.vcproj deleted file mode 100644 index ab5656a..0000000 --- a/libcommon/common/libcommon-vc8.vcproj +++ /dev/null @@ -1,352 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entries__(sources) - - -__file_entries__(headers) - - - - - diff --git a/libcommon/common/libcommon-vc9.vcproj b/libcommon/common/libcommon-vc9.vcproj deleted file mode 100644 index 49bfe21..0000000 --- a/libcommon/common/libcommon-vc9.vcproj +++ /dev/null @@ -1,359 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entries__(sources) - - -__file_entries__(headers) - - - - - diff --git a/libcommon/common/makefile b/libcommon/common/makefile deleted file mode 100644 index 2f6537f..0000000 --- a/libcommon/common/makefile +++ /dev/null @@ -1,166 +0,0 @@ -# file : libcommon/common/makefile -# license : GNU GPL v2; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make - -cxx_tun := common.cxx - -cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) -cxx_od := $(cxx_obj:.o=.o.d) - -common.l := $(out_base)/common.l -common.l.cpp-options := $(out_base)/common.l.cpp-options - -# Import. -# -$(call import,\ - $(scf_root)/import/libodb/stub.make,\ - l: odb.l,cpp-options: odb.l.cpp-options) - -ifdef db_id -ifneq ($(db_id),common) -$(call import,\ - $(scf_root)/import/libodb-$(db_id)/stub.make,\ - l: odb_db.l,cpp-options: odb_db.l.cpp-options) -else -# Import all database runtimes. -# -$(call import,\ - $(scf_root)/import/libodb-mysql/stub.make,\ - l: odb_mysql.l,cpp-options: odb_mysql.l.cpp-options) - -$(call import,\ - $(scf_root)/import/libodb-sqlite/stub.make,\ - l: odb_sqlite.l,cpp-options: odb_sqlite.l.cpp-options) - -$(call import,\ - $(scf_root)/import/libodb-pgsql/stub.make,\ - l: odb_pgsql.l,cpp-options: odb_pgsql.l.cpp-options) - -$(call import,\ - $(scf_root)/import/libodb-oracle/stub.make,\ - l: odb_oracle.l,cpp-options: odb_oracle.l.cpp-options) - -$(call import,\ - $(scf_root)/import/libodb-mssql/stub.make,\ - l: odb_mssql.l,cpp-options: odb_mssql.l.cpp-options) - -odb_db.l := \ -$(odb_mysql.l) \ -$(odb_sqlite.l) \ -$(odb_pgsql.l) \ -$(odb_oracle.l) \ -$(odb_mssql.l) - -odb_db.l.cpp-options := \ -$(odb_mysql.l.cpp-options) \ -$(odb_sqlite.l.cpp-options) \ -$(odb_pgsql.l.cpp-options) \ -$(odb_oracle.l.cpp-options) \ -$(odb_mssql.l.cpp-options) -endif -endif - -ifeq ($(odb_db.l.cpp-options),) -odb_db.l.cpp-options := $(out_base)/.unbuildable -endif - -# Build. -# -$(common.l): $(cxx_obj) $(odb.l) $(odb_db.l) - -$(cxx_obj) $(cxx_od): $(common.l.cpp-options) $(out_base)/config.h -$(common.l.cpp-options): value := -I$(out_root)/libcommon -I$(src_root)/libcommon -$(common.l.cpp-options): $(odb_db.l.cpp-options) $(odb.l.cpp-options) - -$(call include,$(bld_root)/cxx/standard.make) # cxx_standard - -ifdef db_id -ifdef cxx_standard -$(out_base)/config.h: | $(out_base)/. - @echo '/* file : libcommon/common/config.h' >$@ - @echo ' * note : automatically generated' >>$@ - @echo ' */' >>$@ - @echo '' >>$@ - @echo '#ifndef LIBCOMMON_COMMON_CONFIG_H' >>$@ - @echo '#define LIBCOMMON_COMMON_CONFIG_H' >>$@ - @echo '' >>$@ -ifeq ($(db_id),mysql) - @echo '#define DATABASE_MYSQL 1' >>$@ -else ifeq ($(db_id),sqlite) - @echo '#define DATABASE_SQLITE 1' >>$@ -else ifeq ($(db_id),pgsql) - @echo '#define DATABASE_PGSQL 1' >>$@ -else ifeq ($(db_id),oracle) - @echo '#define DATABASE_ORACLE 1' >>$@ -else ifeq ($(db_id),mssql) - @echo '#define DATABASE_MSSQL 1' >>$@ -else ifeq ($(db_id),common) - @echo '#define DATABASE_COMMON 1' >>$@ -endif -ifeq ($(cxx_standard),c++11) - @echo '#define HAVE_CXX11 1' >>$@ -endif - @echo '#define HAVE_TR1_MEMORY 1' >>$@ - @echo '' >>$@ - @echo '#endif /* LIBCOMMON_COMMON_CONFIG_H */' >>$@ -endif -endif - -$(call include-dep,$(cxx_od),$(cxx_obj),$(out_base)/config.h) - -# Convenience alias for default target. -# -$(out_base)/: $(common.l) - -# Dist. -# -$(dist): export sources := $(cxx_tun) -$(dist): export headers = $(subst $(src_base)/,,$(shell find $(src_base) \ --name '*.hxx' -o -name '*.ixx' -o -name '*.txx')) -$(dist): data_dist := config.h.in config-vc.h -$(dist): export extra_dist := $(data_dist) $(call vc8projs,libcommon) \ -$(call vc9projs,libcommon) $(call vc10projs,libcommon) \ -$(call vc11projs,libcommon) $(call vc12projs,libcommon) - -$(dist): - $(call dist-data,$(sources) $(headers) $(data_dist)) - $(call meta-automake) - $(call meta-vc8projs,libcommon) - $(call meta-vc9projs,libcommon) - $(call meta-vc10projs,libcommon) - $(call meta-vc11projs,libcommon) - $(call meta-vc12projs,libcommon) - -# Clean. -# -$(clean): $(common.l).o.clean \ - $(common.l.cpp-options).clean \ - $(addsuffix .cxx.clean,$(cxx_obj)) \ - $(addsuffix .cxx.clean,$(cxx_od)) - $(call message,rm $$1,rm -f $$1,$(out_base)/config.h) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(common.l): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := config.h -$(clean): $(out_base)/.gitignore.clean - -$(call include,$(bld_root)/git/gitignore.make) -endif - -# How to. -# -$(call include,$(bld_root)/dist.make) -$(call include,$(bld_root)/meta/vc8proj.make) -$(call include,$(bld_root)/meta/vc9proj.make) -$(call include,$(bld_root)/meta/vc10proj.make) -$(call include,$(bld_root)/meta/vc11proj.make) -$(call include,$(bld_root)/meta/vc12proj.make) -$(call include,$(bld_root)/meta/automake.make) - -$(call include,$(bld_root)/cxx/cxx-d.make) -$(call include,$(bld_root)/cxx/cxx-o.make) -$(call include,$(bld_root)/cxx/o-l.make) diff --git a/libcommon/concrete.hxx b/libcommon/concrete.hxx new file mode 100644 index 0000000..e0f64a5 --- /dev/null +++ b/libcommon/concrete.hxx @@ -0,0 +1,57 @@ +// file : libcommon/concrete.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef LIBCOMMON_CONCRETE_HXX +#define LIBCOMMON_CONCRETE_HXX + +#include + +// Namespace alias for the concrete database namespace. +// +#if defined(MULTI_DATABASE) + +// Fallback to common interface. +// +#include +#include + +namespace odb_db = odb; + +#elif defined(DATABASE_MYSQL) + +#include +#include + +namespace odb_db = odb::mysql; + +#elif defined(DATABASE_SQLITE) + +#include +#include + +namespace odb_db = odb::sqlite; + +#elif defined(DATABASE_PGSQL) + +#include +#include + +namespace odb_db = odb::pgsql; + +#elif defined(DATABASE_ORACLE) + +#include +#include + +namespace odb_db = odb::oracle; + +#elif defined(DATABASE_MSSQL) + +#include +#include + +namespace odb_db = odb::mssql; + +#endif + +#endif // LIBCOMMON_CONCRETE_HXX diff --git a/libcommon/config.hxx.in b/libcommon/config.hxx.in new file mode 100644 index 0000000..ff90e61 --- /dev/null +++ b/libcommon/config.hxx.in @@ -0,0 +1,14 @@ +// file : libcommon/config.hxx.in +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef LIBCOMMON_CONFIG_HXX +#define LIBCOMMON_CONFIG_HXX + +#undef DATABASE_MYSQL +#undef DATABASE_SQLITE +#undef DATABASE_PGSQL +#undef DATABASE_ORACLE +#undef DATABASE_MSSQL +#undef MULTI_DATABASE + +#endif // LIBCOMMON_CONFIG_HXX diff --git a/libcommon/export.hxx b/libcommon/export.hxx new file mode 100644 index 0000000..0de4565 --- /dev/null +++ b/libcommon/export.hxx @@ -0,0 +1,39 @@ +#pragma once + +// Normally we don't export class templates (but do complete specializations), +// inline functions, and classes with only inline member functions. Exporting +// classes that inherit from non-exported/imported bases (e.g., std::string) +// will end up badly. The only known workarounds are to not inherit or to not +// export. Also, MinGW GCC doesn't like seeing non-exported functions being +// used before their inline definition. The workaround is to reorder code. In +// the end it's all trial and error. + +#if defined(LIBCOMMON_STATIC) // Using static. +# define LIBCOMMON_SYMEXPORT +#elif defined(LIBCOMMON_STATIC_BUILD) // Building static. +# define LIBCOMMON_SYMEXPORT +#elif defined(LIBCOMMON_SHARED) // Using shared. +# ifdef _WIN32 +# define LIBCOMMON_SYMEXPORT __declspec(dllimport) +# else +# define LIBCOMMON_SYMEXPORT +# endif +#elif defined(LIBCOMMON_SHARED_BUILD) // Building shared. +# ifdef _WIN32 +# define LIBCOMMON_SYMEXPORT __declspec(dllexport) +# else +# define LIBCOMMON_SYMEXPORT +# endif +#else +// If none of the above macros are defined, then we assume we are being used +// by some third-party build system that cannot/doesn't signal the library +// type. Note that this fallback works for both static and shared libraries +// provided the library only exports functions (in other words, no global +// exported data) and for the shared case the result will be sub-optimal +// compared to having dllimport. If, however, your library does export data, +// then you will probably want to replace the fallback with the (commented +// out) error since it won't work for the shared case. +// +# define LIBCOMMON_SYMEXPORT // Using static or shared. +//# error define LIBCOMMON_STATIC or LIBCOMMON_SHARED preprocessor macro to signal libcommon library type being linked +#endif diff --git a/libcommon/makefile b/libcommon/makefile deleted file mode 100644 index ac0bb3c..0000000 --- a/libcommon/makefile +++ /dev/null @@ -1,31 +0,0 @@ -# file : libcommon/makefile -# license : GNU GPL; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make - -dirs := common - -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(dirs))) - -$(dist): export dirs := $(dirs) -$(dist): export extra_dist := $(call vc8slns,libcommon) \ -$(call vc9slns,libcommon) $(call vc10slns,libcommon) \ -$(call vc11slns,libcommon) $(call vc12slns,libcommon) -$(dist): $(addprefix $(out_base)/,$(addsuffix /.dist,$(dirs))) - $(call meta-automake) - $(call meta-vc8slns,libcommon) - $(call meta-vc9slns,libcommon) - $(call meta-vc10slns,libcommon) - $(call meta-vc11slns,libcommon) - $(call meta-vc12slns,libcommon) - -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(dirs))) - -$(call include,$(bld_root)/meta/vc8sln.make) -$(call include,$(bld_root)/meta/vc9sln.make) -$(call include,$(bld_root)/meta/vc10sln.make) -$(call include,$(bld_root)/meta/vc11sln.make) -$(call include,$(bld_root)/meta/vc12sln.make) -$(call include,$(bld_root)/meta/automake.make) - -$(foreach d,$(dirs),$(call import,$(src_base)/$d/makefile)) -- cgit v1.1