Skip to content

Commit

Permalink
Merge pull request #1250 from FireDaemon/feature/generalized_udf
Browse files Browse the repository at this point in the history
Generalized application-defined scalar functions
  • Loading branch information
trueqbit authored Nov 24, 2023
2 parents 78c6736 + ae8e3df commit ddfae57
Show file tree
Hide file tree
Showing 12 changed files with 1,206 additions and 282 deletions.
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/cstring_literal.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::cstring_literal 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::cstring_literal 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

0 comments on commit ddfae57

Please sign in to comment.