Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
Addressed the chicken-and-egg problem with <optional>, <string_view>
Browse files Browse the repository at this point in the history
  • Loading branch information
trueqbit committed May 28, 2022
1 parent 31d2da2 commit 231fec9
Show file tree
Hide file tree
Showing 16 changed files with 71 additions and 83 deletions.
4 changes: 1 addition & 3 deletions dev/expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

#include <tuple>
#include <utility> // std::move, std::forward
#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
#include <optional>
#endif
#include "functional/cxx_optional.h"

#include "functional/cxx_universal.h"
#include "operators.h"
Expand Down
4 changes: 1 addition & 3 deletions dev/field_printer.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
#include <sstream> // std::stringstream
#include <vector> // std::vector
#include <memory> // std::shared_ptr, std::unique_ptr
#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
#include <optional> // std::optional
#endif // SQLITE_ORM_OPTIONAL_SUPPORTED
#ifndef SQLITE_ORM_OMITS_CODECVT
#include <codecvt> // std::codecvt_utf8_utf16
#endif // SQLITE_ORM_OMITS_CODECVT
#include "functional/cxx_optional.h"

#include "functional/cxx_universal.h"
#include "functional/cxx_polyfill.h"
Expand Down
10 changes: 0 additions & 10 deletions dev/functional/cxx_core_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,3 @@
#if __cpp_concepts >= 201907L
#define SQLITE_ORM_CONCEPTS_SUPPORTED
#endif

#if __cplusplus >= 201703L // C++17 or later
#if __has_include(<optional>)
#define SQLITE_ORM_OPTIONAL_SUPPORTED
#endif

#if __has_include(<string_view>)
#define SQLITE_ORM_STRING_VIEW_SUPPORTED
#endif
#endif
11 changes: 11 additions & 0 deletions dev/functional/cxx_optional.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#include "cxx_core_features.h"

#if SQLITE_ORM_HAS_INCLUDE(<optional>)
#include <optional>
#endif

#if __cpp_lib_optional >= 201606L
#define SQLITE_ORM_OPTIONAL_SUPPORTED
#endif
1 change: 0 additions & 1 deletion dev/functional/cxx_polyfill.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#pragma once

#include <type_traits>

#include "cxx_universal.h"
Expand Down
11 changes: 11 additions & 0 deletions dev/functional/cxx_string_view.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#include "cxx_core_features.h"

#if SQLITE_ORM_HAS_INCLUDE(<string_view>)
#include <string_view>
#endif

#if __cpp_lib_string_view >= 201606L
#define SQLITE_ORM_STRING_VIEW_SUPPORTED
#endif
4 changes: 1 addition & 3 deletions dev/node_tuple.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
#include <tuple> // std::tuple
#include <utility> // std::pair
#include <functional> // std::reference_wrapper
#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
#include <optional> // std::optional
#endif // SQLITE_ORM_OPTIONAL_SUPPORTED
#include "functional/cxx_optional.h"

#include "tuple_helper/tuple_filter.h"
#include "conditions.h"
Expand Down
5 changes: 2 additions & 3 deletions dev/operators.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

#include <type_traits> // std::false_type, std::true_type
#include <utility> // std::move
#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
#include <optional> // std::nullopt
#endif // SQLITE_ORM_OPTIONAL_SUPPORTED
#include "functional/cxx_optional.h"

#include "tags.h"
#include "serialize_result_type.h"

Expand Down
4 changes: 1 addition & 3 deletions dev/select_constraints.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
#include <string> // std::string
#include <utility> // std::declval
#include <tuple> // std::tuple, std::get, std::tuple_size
#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
#include <optional> // std::optional
#endif // SQLITE_ORM_OPTIONAL_SUPPORTED
#include "functional/cxx_optional.h"

#include "functional/cxx_universal.h"
#include "functional/cxx_polyfill.h"
Expand Down
5 changes: 2 additions & 3 deletions dev/serialize_result_type.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#pragma once

#ifdef SQLITE_ORM_STRING_VIEW_SUPPORTED
#include <string_view> // string_view
#else
#include "functional/cxx_string_view.h"
#ifndef SQLITE_ORM_STRING_VIEW_SUPPORTED
#include <string> // std::string
#endif

Expand Down
1 change: 1 addition & 0 deletions dev/statement_binder.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <string> // std::string, std::wstring
#include <vector> // std::vector
#include <cstring> // ::strncpy, ::strlen
#include "functional/cxx_string_view.h"
#ifndef SQLITE_ORM_STRING_VIEW_SUPPORTED
#include <cwchar> // ::wcsncpy, ::wcslen
#endif
Expand Down
4 changes: 1 addition & 3 deletions dev/statement_serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
#endif // SQLITE_ORM_OMITS_CODECVT
#include <memory>
#include <array>
#ifdef SQLITE_ORM_STRING_VIEW_SUPPORTED
#include <string_view>
#endif
#include "functional/cxx_string_view.h"

#include "functional/cxx_universal.h"
#include "functional/cxx_functional_polyfill.h"
Expand Down
5 changes: 1 addition & 4 deletions dev/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
#include <tuple> // std::tuple_size, std::tuple, std::make_tuple
#include <utility> // std::forward, std::pair
#include <algorithm> // std::for_each, std::ranges::for_each

#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
#include <optional> // std::optional
#endif // SQLITE_ORM_OPTIONAL_SUPPORTED
#include "functional/cxx_optional.h"

#include "functional/cxx_universal.h"
#include "functional/cxx_functional_polyfill.h"
Expand Down
4 changes: 1 addition & 3 deletions dev/type_is_nullable.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#pragma once

#include <memory> // std::shared_ptr, std::unique_ptr
#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
#include <optional> // std::optional
#endif // SQLITE_ORM_OPTIONAL_SUPPORTED
#include "functional/cxx_optional.h"

#include "functional/cxx_polyfill.h"

Expand Down
4 changes: 1 addition & 3 deletions dev/type_printer.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
#include <string> // std::string
#include <memory> // std::shared_ptr, std::unique_ptr
#include <vector> // std::vector
#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
#include <optional> // std::optional
#endif // SQLITE_ORM_OPTIONAL_SUPPORTED
#include "functional/cxx_optional.h"

#include "functional/cxx_polyfill.h"
#include "type_traits.h"
Expand Down
77 changes: 36 additions & 41 deletions include/sqlite_orm/sqlite_orm.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,6 @@ using std::nullptr_t;
#define SQLITE_ORM_CONCEPTS_SUPPORTED
#endif

#if __cplusplus >= 201703L // C++17 or later
#if __has_include(<optional>)
#define SQLITE_ORM_OPTIONAL_SUPPORTED
#endif

#if __has_include(<string_view>)
#define SQLITE_ORM_STRING_VIEW_SUPPORTED
#endif
#endif

// #include "cxx_compiler_quirks.h"

#ifdef __clang__
Expand Down Expand Up @@ -513,9 +503,17 @@ namespace sqlite_orm {
#include <string> // std::string
#include <memory> // std::shared_ptr, std::unique_ptr
#include <vector> // std::vector
#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
#include <optional> // std::optional
#endif // SQLITE_ORM_OPTIONAL_SUPPORTED
// #include "functional/cxx_optional.h"

// #include "cxx_core_features.h"

#if SQLITE_ORM_HAS_INCLUDE(<optional>)
#include <optional>
#endif

#if __cpp_lib_optional >= 201606L
#define SQLITE_ORM_OPTIONAL_SUPPORTED
#endif

// #include "functional/cxx_polyfill.h"

Expand Down Expand Up @@ -1684,9 +1682,7 @@ namespace sqlite_orm {
#pragma once

#include <memory> // std::shared_ptr, std::unique_ptr
#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
#include <optional> // std::optional
#endif // SQLITE_ORM_OPTIONAL_SUPPORTED
// #include "functional/cxx_optional.h"

// #include "functional/cxx_polyfill.h"

Expand All @@ -1711,9 +1707,9 @@ namespace sqlite_orm {
#pragma once

#include <type_traits> // std::false_type, std::true_type
#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
#include <optional> // std::nullopt
#endif // SQLITE_ORM_OPTIONAL_SUPPORTED
#include <utility> // std::move
// #include "functional/cxx_optional.h"

// #include "tags.h"

namespace sqlite_orm {
Expand All @@ -1729,9 +1725,19 @@ namespace sqlite_orm {

// #include "serialize_result_type.h"

#ifdef SQLITE_ORM_STRING_VIEW_SUPPORTED
#include <string_view> // string_view
#else
// #include "functional/cxx_string_view.h"

// #include "cxx_core_features.h"

#if SQLITE_ORM_HAS_INCLUDE(<string_view>)
#include <string_view>
#endif

#if __cpp_lib_string_view >= 201606L
#define SQLITE_ORM_STRING_VIEW_SUPPORTED
#endif

#ifndef SQLITE_ORM_STRING_VIEW_SUPPORTED
#include <string> // std::string
#endif

Expand Down Expand Up @@ -2296,12 +2302,10 @@ namespace sqlite_orm {
#include <sstream> // std::stringstream
#include <vector> // std::vector
#include <memory> // std::shared_ptr, std::unique_ptr
#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
#include <optional> // std::optional
#endif // SQLITE_ORM_OPTIONAL_SUPPORTED
#ifndef SQLITE_ORM_OMITS_CODECVT
#include <codecvt> // std::codecvt_utf8_utf16
#endif // SQLITE_ORM_OMITS_CODECVT
// #include "functional/cxx_optional.h"

// #include "functional/cxx_universal.h"

Expand Down Expand Up @@ -2549,9 +2553,7 @@ namespace sqlite_orm {

#include <tuple>
#include <utility> // std::move, std::forward
#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
#include <optional>
#endif
// #include "functional/cxx_optional.h"

// #include "functional/cxx_universal.h"

Expand Down Expand Up @@ -6350,9 +6352,7 @@ namespace sqlite_orm {
#include <string> // std::string
#include <utility> // std::declval
#include <tuple> // std::tuple, std::get, std::tuple_size
#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
#include <optional> // std::optional
#endif // SQLITE_ORM_OPTIONAL_SUPPORTED
// #include "functional/cxx_optional.h"

// #include "functional/cxx_universal.h"

Expand Down Expand Up @@ -7739,6 +7739,8 @@ namespace sqlite_orm {
#include <string> // std::string, std::wstring
#include <vector> // std::vector
#include <cstring> // ::strncpy, ::strlen
// #include "functional/cxx_string_view.h"

#ifndef SQLITE_ORM_STRING_VIEW_SUPPORTED
#include <cwchar> // ::wcsncpy, ::wcslen
#endif
Expand Down Expand Up @@ -10525,10 +10527,7 @@ namespace sqlite_orm {
#include <tuple> // std::tuple_size, std::tuple, std::make_tuple
#include <utility> // std::forward, std::pair
#include <algorithm> // std::for_each, std::ranges::for_each

#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
#include <optional> // std::optional
#endif // SQLITE_ORM_OPTIONAL_SUPPORTED
// #include "functional/cxx_optional.h"

// #include "functional/cxx_universal.h"

Expand Down Expand Up @@ -14661,9 +14660,7 @@ namespace sqlite_orm {
#endif // SQLITE_ORM_OMITS_CODECVT
#include <memory>
#include <array>
#ifdef SQLITE_ORM_STRING_VIEW_SUPPORTED
#include <string_view>
#endif
// #include "functional/cxx_string_view.h"

// #include "functional/cxx_universal.h"

Expand Down Expand Up @@ -18440,9 +18437,7 @@ namespace sqlite_orm {
#include <tuple> // std::tuple
#include <utility> // std::pair
#include <functional> // std::reference_wrapper
#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
#include <optional> // std::optional
#endif // SQLITE_ORM_OPTIONAL_SUPPORTED
// #include "functional/cxx_optional.h"

// #include "tuple_helper/tuple_filter.h"

Expand Down

0 comments on commit 231fec9

Please sign in to comment.