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

Generalized application-defined scalar functions #1250

Merged
merged 14 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
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
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ for:
install:
- |-
cd C:\Tools\vcpkg
git fetch --tags && git checkout 2023.10.19
git fetch --tags && git checkout 2023.11.20
cd %APPVEYOR_BUILD_FOLDER%
C:\Tools\vcpkg\bootstrap-vcpkg.bat -disableMetrics
C:\Tools\vcpkg\vcpkg integrate install
Expand Down Expand Up @@ -140,7 +140,7 @@ for:
install:
- |-
pushd $HOME/vcpkg
git fetch --tags && git checkout 2023.10.19
git fetch --tags && git checkout 2023.11.20
popd
$HOME/vcpkg/bootstrap-vcpkg.sh -disableMetrics
$HOME/vcpkg/vcpkg integrate install --overlay-triplets=vcpkg/triplets
Expand Down Expand Up @@ -168,7 +168,7 @@ for:
# using custom vcpkg triplets for building and linking dynamic dependent libraries
install:
- |-
git clone --depth 1 --branch 2023.10.19 https://github.com/microsoft/vcpkg.git $HOME/vcpkg
git clone --depth 1 --branch 2023.11.20 https://github.com/microsoft/vcpkg.git $HOME/vcpkg
$HOME/vcpkg/bootstrap-vcpkg.sh -disableMetrics
$HOME/vcpkg/vcpkg integrate install --overlay-triplets=vcpkg/triplets
vcpkg install sqlite3[core,dbstat,math,json1,fts5] catch2 --overlay-triplets=vcpkg/triplets
Expand Down
37 changes: 7 additions & 30 deletions dev/alias.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#pragma once

#include <type_traits> // std::enable_if
#include <utility> // std::index_sequence, std::make_index_sequence
#include <type_traits> // std::enable_if, std::is_same, std::conditional
#include <utility> // std::make_index_sequence, std::move
#include <string> // std::string
#include <sstream> // std::stringstream
#include <algorithm> // std::copy_n

#include "functional/cxx_universal.h" // ::size_t
#include "functional/cxx_type_traits_polyfill.h"
#include "functional/char_array_template.h"
#include "type_traits.h"
#include "alias_traits.h"
#include "table_type_of.h"
Expand All @@ -16,29 +15,7 @@
namespace sqlite_orm {

namespace internal {

#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
/*
* Helper class to facilitate user-defined string literal operator template
*/
template<size_t N>
struct string_identifier_template {
static constexpr size_t size() {
return N - 1;
}

constexpr string_identifier_template(const char (&id)[N]) {
std::copy_n(id, N, this->id);
}

char id[N];
};

template<template<char...> class Alias, string_identifier_template t, size_t... Idx>
consteval auto to_alias(std::index_sequence<Idx...>) {
return Alias<t.id[Idx]...>{};
}

template<class T>
inline constexpr bool is_operator_argument_v<T, std::enable_if_t<orm_column_alias<T>>> = true;
#endif
Expand Down Expand Up @@ -364,18 +341,18 @@ namespace sqlite_orm {
* Examples:
* constexpr auto z_alias = "z"_alias.for_<User>();
*/
template<internal::string_identifier_template t>
template<internal::char_array_template name>
[[nodiscard]] consteval auto operator"" _alias() {
return internal::to_alias<internal::recordset_alias_builder, t>(std::make_index_sequence<t.size()>{});
return internal::explode_into<internal::recordset_alias_builder, name>(std::make_index_sequence<name.size()>{});
}

/** @short Create a column alias.
* column_alias<'a'[, ...]> from a string literal.
* E.g. "a"_col, "b"_col
*/
template<internal::string_identifier_template t>
template<internal::char_array_template name>
[[nodiscard]] consteval auto operator"" _col() {
return internal::to_alias<internal::column_alias, t>(std::make_index_sequence<t.size()>{});
return internal::explode_into<internal::column_alias, name>(std::make_index_sequence<name.size()>{});
}
#endif
}
Loading