Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqlite_orm as a C++ named module #1336

Draft
wants to merge 32 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7e2f578
First attempt to offer sqlite_orm as a named C++ module
trueqbit Jul 16, 2024
2adf823
Added includes of dependent headers
trueqbit Jul 17, 2024
b0c02a1
Import named module `std` when building named module `sqlite_orm`
trueqbit Jul 17, 2024
3bbcd81
Reverted changes to examples/iteration.cpp
trueqbit Jul 17, 2024
08908ac
Update using of internal namespace
trueqbit Jul 17, 2024
9c0b25d
Added missing includes to dev/serializing_util.h
trueqbit Jul 18, 2024
5b515ca
Only export the public sqlite_orm API
trueqbit Jul 18, 2024
1ab8076
Included <sqlite3.h> explicitly in examples and unit tests
trueqbit Jul 18, 2024
6aa4c3e
Merge branch 'upstream/dev' into feature/modules-support
trueqbit Jul 18, 2024
7c4f44d
Explicitly included <cstdint> in examples
trueqbit Jul 18, 2024
e6df974
Removed test code in `storage_t<>::drop_column()`
trueqbit Jul 18, 2024
1bd2bac
Explicitly included <cstdint> in unit tests
trueqbit Jul 18, 2024
93f50b1
[CMake] Package module interface unit .ixx file
trueqbit Jul 19, 2024
b28d104
Building the sqlite_orm named module depends on `std.compat`
trueqbit Jul 20, 2024
a971b92
Use std-qualified `std::time_t` in examples
trueqbit Jul 20, 2024
bd635cc
Corrected named module exports
trueqbit Jul 20, 2024
787ac05
Provide a module interface unit .cppm file for clang
trueqbit Jul 20, 2024
dd49223
Removed inclusion of `cxx_universal.h` where it's not needed
trueqbit Jul 20, 2024
59dde21
No more including of `cxx_universal.h`
trueqbit Jul 20, 2024
32b363a
Updated formatting
trueqbit Jul 20, 2024
1b5d90f
Provide a module interface unit .cxx file for gcc
trueqbit Jul 22, 2024
a006f62
Updated newline-endings of clang .cppm file
trueqbit Jul 22, 2024
1a3d518
Trying to compile a test file that consumes sqlite_orm as a named module
trueqbit Jul 22, 2024
ea04817
Merge branch 'upstream/dev' into feature/modules-support
trueqbit Jul 22, 2024
f673902
Corrected if conditions in CMake build scripts
trueqbit Jul 22, 2024
312defd
Trying to correct adding sqlite_orm.ixx to test target sources
trueqbit Jul 22, 2024
d9a6810
Updated formatting of amalgamated sqlite_orm.h
trueqbit Jul 22, 2024
495c2a4
Link sqlite_orm to modules_tests
trueqbit Jul 22, 2024
efbef40
Updated comment on when the "named module" test is built
trueqbit Jul 23, 2024
996bcbc
Merge branch 'upstream/dev' into feature/modules-support
trueqbit Jul 24, 2024
8ba8730
Added `_EXPORT_SQLITE_ORM` macro to clang-format's `AttributeMacros`
trueqbit Jul 24, 2024
8cdae9b
Merge branch 'upstream/dev' into feature/modules-support
trueqbit Jul 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
AttributeMacros: [SQLITE_ORM_CPP_LIKELY, SQLITE_ORM_CPP_UNLIKELY]
AttributeMacros: [SQLITE_ORM_CPP_LIKELY, SQLITE_ORM_CPP_UNLIKELY, _EXPORT_SQLITE_ORM]
StatementMacros:
- __pragma
- _Pragma
Expand Down
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ set(PACKAGE_VERSION ${sqlite_orm_VERSION})
project("sqlite_orm" VERSION ${PACKAGE_VERSION})

# Handling C++ standard version to use
option(SQLITE_ORM_ENABLE_CXX_23 "Enable C++ 23" OFF)
option(SQLITE_ORM_ENABLE_CXX_20 "Enable C++ 20" OFF)
option(SQLITE_ORM_ENABLE_CXX_17 "Enable C++ 17" OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(SQLITE_ORM_ENABLE_CXX_20)
if(SQLITE_ORM_ENABLE_CXX_23)
set(CMAKE_CXX_STANDARD 23)
message(STATUS "SQLITE_ORM: Build with C++23 features")
elseif(SQLITE_ORM_ENABLE_CXX_20)
set(CMAKE_CXX_STANDARD 20)
message(STATUS "SQLITE_ORM: Build with C++20 features")
elseif(SQLITE_ORM_ENABLE_CXX_17)
Expand Down
5 changes: 5 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ configuration:
environment:
appveyor_yml_disable_ps_linux: true
matrix:
- job_name: Visual Studio 2022, x64, C++23
appveyor_build_worker_image: Visual Studio 2022
platform: x64
SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_23=ON"

- job_name: clang, C++14
appveyor_build_worker_image: Ubuntu
CC: clang
Expand Down
4 changes: 4 additions & 0 deletions dev/alias.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#pragma once

#ifndef _IMPORT_STD_MODULE
#include <type_traits> // std::enable_if, std::is_same
#include <utility> // std::make_index_sequence, std::move
#include <string> // std::string
#include <sstream> // std::stringstream
#if(SQLITE_VERSION_NUMBER >= 3008003) && defined(SQLITE_ORM_WITH_CTE)
#include <array>
#endif
#endif

#include "functional/cxx_type_traits_polyfill.h"
#include "functional/mpl/conditional.h"
Expand Down Expand Up @@ -185,7 +187,9 @@ namespace sqlite_orm {
inline constexpr bool is_builtin_numeric_column_alias_v<column_alias<C...>> = ((C >= '0' && C <= '9') && ...);
#endif
}
}

_EXPORT_SQLITE_ORM namespace sqlite_orm {
/**
* Using a column pointer, create a column reference to an aliased table column.
*
Expand Down
8 changes: 7 additions & 1 deletion dev/alias_traits.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
#pragma once

#ifndef _IMPORT_STD_MODULE
#include <type_traits> // std::is_base_of, std::is_same
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
#include <concepts>
#endif
#endif

#include "functional/cxx_type_traits_polyfill.h"
#include "type_traits.h"
#include "table_reference.h"

namespace sqlite_orm {
_EXPORT_SQLITE_ORM namespace sqlite_orm {

/** @short Base class for a custom table alias, column alias or expression alias.
*/
struct alias_tag {};
}

namespace sqlite_orm {
namespace internal {

template<class A>
Expand Down Expand Up @@ -65,7 +69,9 @@ namespace sqlite_orm {
template<class A>
using is_cte_moniker = polyfill::bool_constant<is_cte_moniker_v<A>>;
}
}

_EXPORT_SQLITE_ORM namespace sqlite_orm {
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
template<class A>
concept orm_alias = std::derived_from<A, alias_tag>;
Expand Down
2 changes: 1 addition & 1 deletion dev/arg_values.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "row_extractor.h"

namespace sqlite_orm {
_EXPORT_SQLITE_ORM namespace sqlite_orm {

/** @short Wrapper around a dynamically typed value object.
*/
Expand Down
4 changes: 3 additions & 1 deletion dev/arithmetic_tag.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#pragma once

#ifndef _IMPORT_STD_MODULE
#include <type_traits> // std::is_integral
#endif

#include "functional/mpl/conditional.h"

namespace sqlite_orm {
_EXPORT_SQLITE_ORM namespace sqlite_orm {

/**
* Helper classes used by statement_binder and row_extractor.
Expand Down
4 changes: 4 additions & 0 deletions dev/ast/excluded.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once

#ifndef _IMPORT_STD_MODULE
#include <utility> // std::move
#endif

namespace sqlite_orm {
namespace internal {
Expand All @@ -12,7 +14,9 @@ namespace sqlite_orm {
expression_type expression;
};
}
}

_EXPORT_SQLITE_ORM namespace sqlite_orm {
template<class T>
internal::excluded_t<T> excluded(T expression) {
return {std::move(expression)};
Expand Down
4 changes: 4 additions & 0 deletions dev/ast/exists.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once

#ifndef _IMPORT_STD_MODULE
#include <utility> // std::move
#endif

#include "../tags.h"

Expand All @@ -17,7 +19,9 @@ namespace sqlite_orm {
exists_t(expression_type expression_) : expression(std::move(expression_)) {}
};
}
}

_EXPORT_SQLITE_ORM namespace sqlite_orm {
/**
* EXISTS(condition).
* Example: storage.select(columns(&Agent::code, &Agent::name, &Agent::workingArea, &Agent::comission),
Expand Down
4 changes: 4 additions & 0 deletions dev/ast/group_by.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#pragma once

#ifndef _IMPORT_STD_MODULE
#include <tuple> // std::tuple, std::make_tuple
#include <type_traits> // std::true_type, std::false_type
#include <utility> // std::forward, std::move
#endif

#include "../functional/cxx_type_traits_polyfill.h"

Expand Down Expand Up @@ -37,7 +39,9 @@ namespace sqlite_orm {
using is_group_by = polyfill::disjunction<polyfill::is_specialization_of<T, group_by_t>,
polyfill::is_specialization_of<T, group_by_with_having>>;
}
}

_EXPORT_SQLITE_ORM namespace sqlite_orm {
/**
* GROUP BY column.
* Example: storage.get_all<Employee>(group_by(&Employee::name))
Expand Down
2 changes: 2 additions & 0 deletions dev/ast/into.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ namespace sqlite_orm {
template<class T>
using is_into = polyfill::is_specialization_of<T, into_t>;
}
}

_EXPORT_SQLITE_ORM namespace sqlite_orm {
template<class T>
internal::into_t<T> into() {
return {};
Expand Down
6 changes: 4 additions & 2 deletions dev/ast/match.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#pragma once

#include <utility> // std::move
#ifndef _IMPORT_STD_MODULE
#include <utility>
#endif

namespace sqlite_orm {
_EXPORT_SQLITE_ORM namespace sqlite_orm {
namespace internal {

template<class T, class X>
Expand Down
2 changes: 2 additions & 0 deletions dev/ast/rank.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ namespace sqlite_orm {
namespace internal {
struct rank_t {};
}
}

_EXPORT_SQLITE_ORM namespace sqlite_orm {
inline internal::rank_t rank() {
return {};
}
Expand Down
4 changes: 4 additions & 0 deletions dev/ast/set.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#pragma once

#ifndef _IMPORT_STD_MODULE
#include <tuple> // std::tuple, std::tuple_size
#include <string> // std::string
#include <vector> // std::vector
#include <sstream> // std::stringstream
#include <type_traits> // std::false_type, std::true_type
#endif

#include "../tuple_helper/tuple_traits.h"
#include "../table_name_collector.h"
Expand Down Expand Up @@ -85,7 +87,9 @@ namespace sqlite_orm {
template<class C>
struct is_dynamic_set<dynamic_set_t<C>> : std::true_type {};
}
}

_EXPORT_SQLITE_ORM namespace sqlite_orm {
/**
* SET keyword used in UPDATE ... SET queries.
* Args must have `assign_t` type. E.g. set(assign(&User::id, 5)) or set(c(&User::id) = 5)
Expand Down
2 changes: 2 additions & 0 deletions dev/ast/special_keywords.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ namespace sqlite_orm {
struct current_date_t {};
struct current_timestamp_t {};
}
}

_EXPORT_SQLITE_ORM namespace sqlite_orm {
inline internal::current_time_t current_time() {
return {};
}
Expand Down
4 changes: 4 additions & 0 deletions dev/ast/upsert_clause.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#pragma once

#ifndef _IMPORT_STD_MODULE
#if SQLITE_VERSION_NUMBER >= 3024000
#include <tuple> // std::tuple
#include <utility> // std::forward, std::move
#endif
#endif

#include "../functional/cxx_type_traits_polyfill.h"

Expand Down Expand Up @@ -51,7 +53,9 @@ namespace sqlite_orm {
template<class T>
using is_upsert_clause = polyfill::bool_constant<is_upsert_clause_v<T>>;
}
}

_EXPORT_SQLITE_ORM namespace sqlite_orm {
#if SQLITE_VERSION_NUMBER >= 3024000
/**
* ON CONFLICT upsert clause builder function.
Expand Down
4 changes: 4 additions & 0 deletions dev/ast/where.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#pragma once

#ifndef _IMPORT_STD_MODULE
#include <type_traits> // std::false_type, std::true_type
#include <utility> // std::move
#endif

#include "../functional/cxx_type_traits_polyfill.h"
#include "../serialize_result_type.h"
Expand Down Expand Up @@ -35,7 +37,9 @@ namespace sqlite_orm {
template<class T>
struct is_where : polyfill::bool_constant<is_where_v<T>> {};
}
}

_EXPORT_SQLITE_ORM namespace sqlite_orm {
/**
* WHERE clause. Use it to add WHERE conditions wherever you like.
* C is expression type. Can be any expression like: is_equal_t, is_null_t, exists_t etc
Expand Down
2 changes: 2 additions & 0 deletions dev/ast_iterator.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#pragma once

#ifndef _IMPORT_STD_MODULE
#include <vector> // std::vector
#include <functional> // std::reference_wrapper
#endif

#include "tuple_helper/tuple_iteration.h"
#include "type_traits.h"
Expand Down
2 changes: 2 additions & 0 deletions dev/backup.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#pragma once

#include <sqlite3.h>
#ifndef _IMPORT_STD_MODULE
#include <system_error> // std::system_error
#include <string> // std::string
#include <memory>
#include <utility> // std::move, std::exchange
#endif

#include "error_code.h"
#include "connection_holder.h"
Expand Down
4 changes: 3 additions & 1 deletion dev/carray.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Hence we make it only available for compilers supporting inline variables.
*/

#ifndef _IMPORT_STD_MODULE
#if SQLITE_VERSION_NUMBER >= 3020000
#ifdef SQLITE_ORM_INLINE_VARIABLES_SUPPORTED
#include <utility> // std::move
Expand All @@ -14,12 +15,13 @@
#endif
#endif
#endif
#endif

#include "pointer_value.h"

#if SQLITE_VERSION_NUMBER >= 3020000
#ifdef SQLITE_ORM_INLINE_VARIABLES_SUPPORTED
namespace sqlite_orm {
_EXPORT_SQLITE_ORM namespace sqlite_orm {

#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
inline constexpr orm_pointer_type auto carray_pointer_tag = "carray"_pointer_type;
Expand Down
2 changes: 2 additions & 0 deletions dev/column_expression.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#pragma once

#ifndef _IMPORT_STD_MODULE
#include <type_traits> // std::enable_if, std::is_same, std::decay, std::is_arithmetic
#include <tuple> // std::tuple
#include <functional> // std::reference_wrapper
#endif

#include "functional/cxx_type_traits_polyfill.h"
#include "tuple_helper/tuple_transformer.h"
Expand Down
2 changes: 2 additions & 0 deletions dev/column_names_getter.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#pragma once

#ifndef _IMPORT_STD_MODULE
#include <type_traits> // std::is_base_of
#include <string> // std::string
#include <vector> // std::vector
#include <functional> // std::reference_wrapper
#include <system_error>
#include <utility> // std::move
#endif

#include "tuple_helper/tuple_traits.h"
#include "tuple_helper/tuple_iteration.h"
Expand Down
4 changes: 4 additions & 0 deletions dev/column_pointer.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#pragma once

#ifndef _IMPORT_STD_MODULE
#include <type_traits> // std::enable_if, std::is_convertible
#include <utility> // std::move
#endif

#include "functional/cxx_core_features.h"
#include "functional/cxx_type_traits_polyfill.h"
Expand Down Expand Up @@ -40,7 +42,9 @@ namespace sqlite_orm {
struct alias_holder;
#endif
}
}

_EXPORT_SQLITE_ORM namespace sqlite_orm {
/**
* Explicitly refer to a column, used in contexts
* where the automatic object mapping deduction needs to be overridden.
Expand Down
6 changes: 4 additions & 2 deletions dev/column_result.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#pragma once

#ifndef _IMPORT_STD_MODULE
#include <type_traits> // std::enable_if, std::is_same, std::decay, std::is_arithmetic, std::is_base_of
#include <functional> // std::reference_wrapper
#endif

#include "functional/cxx_type_traits_polyfill.h"
#include "functional/mpl.h"
Expand Down Expand Up @@ -129,8 +131,8 @@ namespace sqlite_orm {
};

template<class DBOs>
struct column_result_t<DBOs, nullptr_t, void> {
using type = nullptr_t;
struct column_result_t<DBOs, std::nullptr_t, void> {
using type = std::nullptr_t;
};

template<class DBOs>
Expand Down
Loading