5
5
#include < iterator> // std::iterator_traits
6
6
#include < string> // std::string
7
7
#include < type_traits> // std::integral_constant, std::declval
8
- #include < utility> // std::pair
8
+ #include < utility> // std::move, std::forward, std::pair
9
+ #include < tuple> // std::tuple
9
10
10
11
#include " functional/cxx_universal.h"
11
12
#include " functional/cxx_type_traits_polyfill.h"
@@ -596,10 +597,21 @@ namespace sqlite_orm {
596
597
*/
597
598
template <class T , class ... Ids>
598
599
internal::remove_t <T, Ids...> remove (Ids... ids) {
599
- std::tuple<Ids...> idsTuple{std::forward<Ids>(ids)...};
600
- return {std::move (idsTuple)};
600
+ return {{std::forward<Ids>(ids)...}};
601
601
}
602
602
603
+ #ifdef SQLITE_ORM_WITH_CPP20_ALIASES
604
+ /* *
605
+ * Create a remove statement
606
+ * `table` is an explicitly specified table reference of a mapped object to be extracted.
607
+ * Usage: remove<user_table>(5);
608
+ */
609
+ template <orm_table_reference auto table, class ... Ids>
610
+ auto remove (Ids... ids) {
611
+ return remove<internal::auto_decay_table_ref_t <table>>(std::forward<Ids>(ids)...);
612
+ }
613
+ #endif
614
+
603
615
/* *
604
616
* Create an update statement.
605
617
* T is an object type mapped to a storage.
@@ -625,12 +637,12 @@ namespace sqlite_orm {
625
637
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
626
638
/* *
627
639
* Create a get statement.
628
- * T is an object type mapped to a storage .
629
- * Usage: get<User >(5);
640
+ * `table` is an explicitly specified table reference of a mapped object to be extracted .
641
+ * Usage: get<user_table >(5);
630
642
*/
631
- template <orm_table_reference auto als , class ... Ids>
643
+ template <orm_table_reference auto table , class ... Ids>
632
644
auto get (Ids... ids) {
633
- return get<internal::mapped_type_proxy_t < decltype (als) >>(std::forward<Ids>(ids)...);
645
+ return get<internal::auto_decay_table_ref_t <table >>(std::forward<Ids>(ids)...);
634
646
}
635
647
#endif
636
648
@@ -644,6 +656,18 @@ namespace sqlite_orm {
644
656
return {{std::forward<Ids>(ids)...}};
645
657
}
646
658
659
+ #ifdef SQLITE_ORM_WITH_CPP20_ALIASES
660
+ /* *
661
+ * Create a get pointer statement.
662
+ * `table` is an explicitly specified table reference of a mapped object to be extracted.
663
+ * Usage: get_pointer<user_table>(5);
664
+ */
665
+ template <orm_table_reference auto table, class ... Ids>
666
+ auto get_pointer (Ids... ids) {
667
+ return get_pointer<internal::auto_decay_table_ref_t <table>>(std::forward<Ids>(ids)...);
668
+ }
669
+ #endif
670
+
647
671
#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
648
672
/* *
649
673
* Create a get optional statement.
@@ -656,6 +680,18 @@ namespace sqlite_orm {
656
680
}
657
681
#endif // SQLITE_ORM_OPTIONAL_SUPPORTED
658
682
683
+ #ifdef SQLITE_ORM_WITH_CPP20_ALIASES
684
+ /* *
685
+ * Create a get optional statement.
686
+ * `table` is an explicitly specified table reference of a mapped object to be extracted.
687
+ * Usage: get_optional<user_table>(5);
688
+ */
689
+ template <orm_table_reference auto table, class ... Ids>
690
+ auto get_optional (Ids... ids) {
691
+ return get_pointer<internal::auto_decay_table_ref_t <table>>(std::forward<Ids>(ids)...);
692
+ }
693
+ #endif
694
+
659
695
/* *
660
696
* Create a remove all statement.
661
697
* T is an object type mapped to a storage.
@@ -665,13 +701,24 @@ namespace sqlite_orm {
665
701
internal::remove_all_t <T, Args...> remove_all (Args... args) {
666
702
using args_tuple = std::tuple<Args...>;
667
703
internal::validate_conditions<args_tuple>();
668
- args_tuple conditions{std::forward<Args>(args)...};
669
- return {std::move (conditions)};
704
+ return {{std::forward<Args>(args)...}};
705
+ }
706
+
707
+ #ifdef SQLITE_ORM_WITH_CPP20_ALIASES
708
+ /* *
709
+ * Create a remove all statement.
710
+ * `table` is an explicitly specified table reference of a mapped object to be extracted.
711
+ * Usage: storage.remove_all<user_table>(...);
712
+ */
713
+ template <orm_table_reference auto table, class ... Args>
714
+ auto remove_all (Args... args) {
715
+ return remove_all<internal::auto_decay_table_ref_t <table>>(std::forward<Args>(args)...);
670
716
}
717
+ #endif
671
718
672
719
/* *
673
720
* Create a get all statement.
674
- * T is an object type mapped to a storage.
721
+ * T is an object mapped to a storage or a table alias .
675
722
* R is a container type. std::vector<T> is default
676
723
* Usage: storage.prepare(get_all<User>(...));
677
724
*/
@@ -685,15 +732,15 @@ namespace sqlite_orm {
685
732
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
686
733
/* *
687
734
* Create a get all statement.
688
- * `als ` is an explicitly specified table proxy of an object to be extracted.
735
+ * `mapped ` is an explicitly specified table reference or alias of a mapped object to be extracted.
689
736
* `R` is the container return type, which must have a `R::push_back(T&&)` method, and defaults to `std::vector<T>`
690
737
* Usage: storage.get_all<sqlite_schema>(...);
691
738
*/
692
- template <orm_refers_to_table auto als ,
693
- class R = std::vector<internal::mapped_type_proxy_t <decltype (als )>>,
739
+ template <orm_refers_to_table auto mapped ,
740
+ class R = std::vector<internal::mapped_type_proxy_t <decltype (mapped )>>,
694
741
class ... Args>
695
742
auto get_all (Args&&... conditions) {
696
- return get_all<internal::auto_decay_table_ref_t <als >, R>(std::forward<Args>(conditions)...);
743
+ return get_all<internal::auto_decay_table_ref_t <mapped >, R>(std::forward<Args>(conditions)...);
697
744
}
698
745
#endif
699
746
@@ -706,23 +753,37 @@ namespace sqlite_orm {
706
753
static_assert (internal::is_set<S>::value, " first argument in update_all can be either set or dynamic_set" );
707
754
using args_tuple = std::tuple<Wargs...>;
708
755
internal::validate_conditions<args_tuple>();
709
- args_tuple conditions{std::forward<Wargs>(wh)...};
710
- return {std::move (set), std::move (conditions)};
756
+ return {std::move (set), {std::forward<Wargs>(wh)...}};
711
757
}
712
758
713
759
/* *
714
760
* Create a get all pointer statement.
715
761
* T is an object type mapped to a storage.
716
762
* R is a container return type. std::vector<std::unique_ptr<T>> is default
717
763
* Usage: storage.prepare(get_all_pointer<User>(...));
718
- */
764
+ */
719
765
template <class T , class R = std::vector<std::unique_ptr<T>>, class ... Args>
720
766
internal::get_all_pointer_t <T, R, Args...> get_all_pointer (Args... conditions) {
721
767
using conditions_tuple = std::tuple<Args...>;
722
768
internal::validate_conditions<conditions_tuple>();
723
769
return {{std::forward<Args>(conditions)...}};
724
770
}
725
771
772
+ #ifdef SQLITE_ORM_WITH_CPP20_ALIASES
773
+ /* *
774
+ * Create a get all pointer statement.
775
+ * `table` is an explicitly specified table reference of a mapped object to be extracted.
776
+ * R is a container return type. std::vector<std::unique_ptr<T>> is default
777
+ * Usage: storage.prepare(get_all_pointer<user_table>(...));
778
+ */
779
+ template <orm_table_reference auto table,
780
+ class R = std::vector<internal::auto_decay_table_ref_t <table>>,
781
+ class ... Args>
782
+ auto get_all_pointer (Args... conditions) {
783
+ return get_all_pointer<internal::auto_decay_table_ref_t <table>, R>(std::forward<Args>(conditions)...);
784
+ }
785
+ #endif
786
+
726
787
#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
727
788
/* *
728
789
* Create a get all optional statement.
@@ -737,4 +798,19 @@ namespace sqlite_orm {
737
798
return {{std::forward<Args>(conditions)...}};
738
799
}
739
800
#endif // SQLITE_ORM_OPTIONAL_SUPPORTED
801
+
802
+ #ifdef SQLITE_ORM_WITH_CPP20_ALIASES
803
+ /* *
804
+ * Create a get all optional statement.
805
+ * `table` is an explicitly specified table reference of a mapped object to be extracted.
806
+ * R is a container return type. std::vector<std::optional<T>> is default
807
+ * Usage: storage.get_all_optional<user_table>(...);
808
+ */
809
+ template <orm_table_reference auto table,
810
+ class R = std::vector<internal::auto_decay_table_ref_t <table>>,
811
+ class ... Args>
812
+ auto get_all_optional (Args&&... conditions) {
813
+ return get_all_optional<internal::auto_decay_table_ref_t <table>, R>(std::forward<Args>(conditions)...);
814
+ }
815
+ #endif
740
816
}
0 commit comments