|
relx 0.1.0
A Modern C++23 Type-Safe SQL Query Builder
|
Classes | |
| struct | autoincrement |
| AUTOINCREMENT constraint. More... | |
| struct | check |
| CHECK constraint. More... | |
| class | column |
| Represents a column in a database table. More... | |
| class | column< TableT, Name, std::optional< T >, Modifiers... > |
| class | column_check_constraint |
| Check constraint explicitly associated with a column. More... | |
| struct | column_traits |
| Contains schema definition components. More... | |
| struct | column_traits< bool > |
| struct | column_traits< double > |
| struct | column_traits< float > |
| struct | column_traits< int > |
| struct | column_traits< long > |
| struct | column_traits< long long > |
| struct | column_traits< std::chrono::system_clock::time_point > |
| Column traits for std::chrono::system_clock::time_point. More... | |
| struct | column_traits< std::chrono::year_month_day > |
| Column traits for std::chrono::year_month_day. More... | |
| struct | column_traits< std::nullopt_t > |
| struct | column_traits< std::optional< T > > |
| struct | column_traits< std::string > |
| class | composite_foreign_key |
| Represents a composite foreign key constraint with multiple columns. More... | |
| class | composite_index |
| Represents a composite index on multiple columns. More... | |
| class | composite_primary_key |
| Represents a composite primary key constraint on multiple columns. More... | |
| class | composite_unique_constraint |
| Represents a composite UNIQUE constraint on multiple columns. More... | |
| class | create_table |
| Generate CREATE TABLE SQL statement for a table struct. More... | |
| struct | default_value |
| DEFAULT value for non-string values. More... | |
| class | drop_table |
| Generate DROP TABLE SQL statement for a table struct. More... | |
| struct | fixed_string |
| Compile-time string type that can be used as template non-type parameter in C++20. More... | |
| struct | fk_impl |
| struct | fk_impl< std::tuple< std::integral_constant< decltype(LocalColumns), LocalColumns >... >, std::tuple< std::integral_constant< decltype(ReferencedColumns), ReferencedColumns >... > > |
| class | foreign_key |
| Represents a foreign key constraint on a table. More... | |
| struct | identity |
| IDENTITY constraint with configurable options. More... | |
| class | index |
| Represents an index on a table. More... | |
| struct | is_default_value_specialization |
| struct | is_default_value_specialization< default_value< Value > > |
| struct | is_string_default_specialization |
| struct | is_string_default_specialization< string_default< Value, IsLiteral > > |
| struct | member_pointer_class |
| Helper to extract the class type from a member pointer. More... | |
| struct | member_pointer_class< T C::* > |
| Specialization for extracting class type from member pointer. More... | |
| struct | member_pointer_type |
| Helper to extract the member type from a member pointer. More... | |
| struct | member_pointer_type< T C::* > |
| Specialization for extracting member type from member pointer. More... | |
| struct | null_default |
| NULL default for optional types. More... | |
| struct | on_delete |
| ON DELETE action for foreign keys. More... | |
| struct | on_update |
| ON UPDATE action for foreign keys. More... | |
| struct | pack_element |
| struct | pack_element< 0, First, Rest... > |
| struct | pack_element< N, First, Rest... > |
| struct | primary_key |
| PRIMARY KEY constraint. More... | |
| struct | references |
| REFERENCES constraint for foreign keys. More... | |
| struct | string_default |
| DEFAULT value for string literals. More... | |
| class | table_check_constraint |
| Check constraint that accepts a condition string at compile time. More... | |
| class | table_primary_key |
| Represents a primary key constraint on a table. More... | |
| struct | unique |
| UNIQUE constraint. More... | |
| class | unique_constraint |
| Represents a UNIQUE constraint on a table. More... | |
Concepts | |
| concept | ValidIdentityType |
| Concept for valid identity types. | |
| concept | ColumnTypeConcept |
| concept | is_column |
| Helper to detect column members in a table. | |
| concept | TableConcept |
| Concept for a database table type. | |
| concept | is_constraint |
| Helper to detect constraint members in a table. | |
Typedefs | |
| template<auto... Args> | |
| using | fk = decltype(make_fk< Args... >()) |
| Type alias for foreign key using the make_fk helper. | |
| template<typename T > | |
| using | member_pointer_class_t = typename member_pointer_class< T >::type |
| Convenience alias for member_pointer_class. | |
| template<typename T > | |
| using | member_pointer_type_t = typename member_pointer_type< T >::type |
| Convenience alias for member_pointer_type. | |
| template<auto... ColumnPtrs> | |
| using | pk = decltype(make_pk< ColumnPtrs... >()) |
| Helper type alias for primary key constraints. | |
Enumerations | |
| enum class | reference_action { cascade , restrict , set_null , set_default , no_action } |
| Foreign key actions. More... | |
| enum class | index_type : uint8_t { normal , unique , fulltext , spatial } |
| Index types. More... | |
Functions | |
| template<typename TableT , fixed_string Name, typename T , typename... Modifiers, typename ValueType > | |
| auto | operator== (const column< TableT, Name, T, Modifiers... > &col, const ValueType &value) |
| template<typename TableT , fixed_string Name, typename T , typename... Modifiers, typename ValueType > | |
| auto | operator!= (const column< TableT, Name, T, Modifiers... > &col, const ValueType &value) |
| template<typename TableT , fixed_string Name, typename T , typename... Modifiers, typename ValueType > | |
| auto | operator> (const column< TableT, Name, T, Modifiers... > &col, const ValueType &value) |
| template<typename TableT , fixed_string Name, typename T , typename... Modifiers, typename ValueType > | |
| auto | operator< (const column< TableT, Name, T, Modifiers... > &col, const ValueType &value) |
| template<typename TableT , fixed_string Name, typename T , typename... Modifiers, typename ValueType > | |
| auto | operator>= (const column< TableT, Name, T, Modifiers... > &col, const ValueType &value) |
| template<typename TableT , fixed_string Name, typename T , typename... Modifiers, typename ValueType > | |
| auto | operator<= (const column< TableT, Name, T, Modifiers... > &col, const ValueType &value) |
| template<typename TableT1 , fixed_string Name1, typename T1 , typename... Modifiers1, typename TableT2 , fixed_string Name2, typename T2 , typename... Modifiers2> | |
| auto | operator== (const column< TableT1, Name1, T1, Modifiers1... > &col1, const column< TableT2, Name2, T2, Modifiers2... > &col2) |
| template<typename TableT1 , fixed_string Name1, typename T1 , typename... Modifiers1, typename TableT2 , fixed_string Name2, typename T2 , typename... Modifiers2> | |
| auto | operator!= (const column< TableT1, Name1, T1, Modifiers1... > &col1, const column< TableT2, Name2, T2, Modifiers2... > &col2) |
| template<typename TableT1 , fixed_string Name1, typename T1 , typename... Modifiers1, typename TableT2 , fixed_string Name2, typename T2 , typename... Modifiers2> | |
| auto | operator> (const column< TableT1, Name1, T1, Modifiers1... > &col1, const column< TableT2, Name2, T2, Modifiers2... > &col2) |
| template<typename TableT1 , fixed_string Name1, typename T1 , typename... Modifiers1, typename TableT2 , fixed_string Name2, typename T2 , typename... Modifiers2> | |
| auto | operator< (const column< TableT1, Name1, T1, Modifiers1... > &col1, const column< TableT2, Name2, T2, Modifiers2... > &col2) |
| template<typename TableT1 , fixed_string Name1, typename T1 , typename... Modifiers1, typename TableT2 , fixed_string Name2, typename T2 , typename... Modifiers2> | |
| auto | operator>= (const column< TableT1, Name1, T1, Modifiers1... > &col1, const column< TableT2, Name2, T2, Modifiers2... > &col2) |
| template<typename TableT1 , fixed_string Name1, typename T1 , typename... Modifiers1, typename TableT2 , fixed_string Name2, typename T2 , typename... Modifiers2> | |
| auto | operator<= (const column< TableT1, Name1, T1, Modifiers1... > &col1, const column< TableT2, Name2, T2, Modifiers2... > &col2) |
| template<typename TableT , fixed_string Name, typename... Modifiers> | |
| auto | operator! (const column< TableT, Name, bool, Modifiers... > &col) |
| template<typename TableT , fixed_string Name, typename... Modifiers, query::SqlExpr Expr> | |
| auto | operator&& (const column< TableT, Name, bool, Modifiers... > &col, const Expr &expr) |
| template<query::SqlExpr Expr, typename TableT , fixed_string Name, typename... Modifiers> | |
| auto | operator&& (const Expr &expr, const column< TableT, Name, bool, Modifiers... > &col) |
| template<typename TableT , fixed_string Name, typename... Modifiers, query::SqlExpr Expr> | |
| auto | operator|| (const column< TableT, Name, bool, Modifiers... > &col, const Expr &expr) |
| template<query::SqlExpr Expr, typename TableT , fixed_string Name, typename... Modifiers> | |
| auto | operator|| (const Expr &expr, const column< TableT, Name, bool, Modifiers... > &col) |
| template<typename ValueType , typename TableT , fixed_string Name, typename T , typename... Modifiers> | |
| auto | operator== (const ValueType &value, const column< TableT, Name, T, Modifiers... > &col) |
| template<typename ValueType , typename TableT , fixed_string Name, typename T , typename... Modifiers> | |
| auto | operator!= (const ValueType &value, const column< TableT, Name, T, Modifiers... > &col) |
| template<typename ValueType , typename TableT , fixed_string Name, typename T , typename... Modifiers> | |
| auto | operator> (const ValueType &value, const column< TableT, Name, T, Modifiers... > &col) |
| template<typename ValueType , typename TableT , fixed_string Name, typename T , typename... Modifiers> | |
| auto | operator< (const ValueType &value, const column< TableT, Name, T, Modifiers... > &col) |
| template<typename ValueType , typename TableT , fixed_string Name, typename T , typename... Modifiers> | |
| auto | operator>= (const ValueType &value, const column< TableT, Name, T, Modifiers... > &col) |
| template<typename ValueType , typename TableT , fixed_string Name, typename T , typename... Modifiers> | |
| auto | operator<= (const ValueType &value, const column< TableT, Name, T, Modifiers... > &col) |
| template<typename TableT , fixed_string Name, typename... Modifiers, typename Cond > requires query::SqlExpr<Cond> || (!std::same_as<Cond, bool>) | |
| auto | operator&& (const column< TableT, Name, bool, Modifiers... > &col, const Cond &cond) |
| template<typename TableT , fixed_string Name, typename... Modifiers, typename Cond > requires query::SqlExpr<Cond> || (!std::same_as<Cond, bool>) | |
| auto | operator|| (const column< TableT, Name, bool, Modifiers... > &col, const Cond &cond) |
| template<typename Cond , typename TableT , fixed_string Name, typename... Modifiers> requires query::SqlExpr<Cond> || (!std::same_as<Cond, bool>) | |
| auto | operator&& (const Cond &cond, const column< TableT, Name, bool, Modifiers... > &col) |
| template<typename Cond , typename TableT , fixed_string Name, typename... Modifiers> requires query::SqlExpr<Cond> || (!std::same_as<Cond, bool>) | |
| auto | operator|| (const Cond &cond, const column< TableT, Name, bool, Modifiers... > &col) |
| template<fixed_string Condition, fixed_string Name> | |
| constexpr auto | named_check () |
| Helper function to create a named check constraint at compile time. | |
| template<fixed_string Condition> | |
| constexpr auto | table_check () |
| Helper function to create an unnamed check constraint at compile time. | |
| template<auto ColumnPtr, fixed_string Condition> | |
| constexpr auto | column_check () |
| Helper function to create a column-bound check constraint at compile time. | |
| template<auto ColumnPtr, fixed_string Condition, fixed_string Name> | |
| constexpr auto | named_column_check () |
| Helper function to create a named column-bound check constraint at compile time. | |
| template<typename... Modifiers> | |
| static std::string | apply_modifiers () |
| Helper to apply all column modifiers to a SQL definition. | |
| template<std::size_t N> | |
| std::ostream & | operator<< (std::ostream &os, const fixed_string< N > &str) |
| constexpr std::string_view | reference_action_to_string (reference_action action) |
| Convert reference action to SQL string. | |
| template<auto... Args> | |
| auto | make_fk () |
| Helper function to create a foreign key. | |
| template<auto... Args> | |
| auto | make_fk (reference_action on_delete, reference_action on_update) |
| Helper function to create a foreign key with reference actions. | |
| constexpr std::string_view | index_type_to_string (index_type type) |
| Convert index type to SQL string. | |
| template<auto... ColumnPtrs> | |
| auto | make_pk () |
| Helper function to create a primary key. | |
| template<TableConcept Table> | |
| std::string | collect_column_definitions (const Table &table_instance) |
| Generate SQL column definitions from a table struct using Boost PFR. | |
| template<TableConcept Table> | |
| std::string | collect_constraint_definitions (const Table &table_instance) |
| Generate SQL constraint definitions from a table struct. | |
| using relx::schema::fk = typedef decltype(make_fk<Args...>()) |
Type alias for foreign key using the make_fk helper.
| Args | All column pointers (local followed by referenced) |
Definition at line 319 of file foreign_key.hpp.
| using relx::schema::member_pointer_class_t = typedef typename member_pointer_class<T>::type |
Convenience alias for member_pointer_class.
| T | The member pointer type |
| using relx::schema::member_pointer_type_t = typedef typename member_pointer_type<T>::type |
Convenience alias for member_pointer_type.
| T | The member pointer type |
| using relx::schema::pk = typedef decltype(make_pk<ColumnPtrs...>()) |
Helper type alias for primary key constraints.
Automatically selects between single-column and composite primary key based on the number of columns
Definition at line 87 of file primary_key.hpp.
|
strong |
|
strong |
Foreign key actions.
| Enumerator | |
|---|---|
| cascade | |
| restrict | |
| set_null | |
| set_default | |
| no_action | |
Definition at line 16 of file foreign_key.hpp.
|
static |
Helper to apply all column modifiers to a SQL definition.
Definition at line 189 of file column.hpp.
| std::string relx::schema::collect_column_definitions | ( | const Table & | table_instance | ) |
| std::string relx::schema::collect_constraint_definitions | ( | const Table & | table_instance | ) |
|
constexpr |
Helper function to create a column-bound check constraint at compile time.
| ColumnPtr | Pointer to the column |
| Condition | The SQL condition |
Definition at line 109 of file check_constraint.hpp.
|
constexpr |
| auto relx::schema::make_fk | ( | ) |
Helper function to create a foreign key.
| LocalColumns | Local column pointers (first half of Args) |
| ReferencedColumns | Referenced column pointers (second half of Args) |
Definition at line 274 of file foreign_key.hpp.
| auto relx::schema::make_fk | ( | reference_action | on_delete, |
| reference_action | on_update | ||
| ) |
Helper function to create a foreign key with reference actions.
| Args | All column pointers (local columns followed by referenced columns) |
Definition at line 298 of file foreign_key.hpp.
| auto relx::schema::make_pk | ( | ) |
Helper function to create a primary key.
| ColumnPtrs | Pointers to the columns that form the primary key |
Definition at line 70 of file primary_key.hpp.
|
constexpr |
Helper function to create a named check constraint at compile time.
| Condition | The SQL condition |
| Name | The constraint name |
Definition at line 92 of file check_constraint.hpp.
|
constexpr |
Helper function to create a named column-bound check constraint at compile time.
| ColumnPtr | Pointer to the column |
| Condition | The SQL condition |
| Name | The constraint name |
Definition at line 119 of file check_constraint.hpp.
| auto relx::schema::operator! | ( | const column< TableT, Name, bool, Modifiers... > & | col | ) |
Definition at line 222 of file operators.hpp.
| auto relx::schema::operator!= | ( | const column< TableT, Name, T, Modifiers... > & | col, |
| const ValueType & | value | ||
| ) |
Definition at line 106 of file operators.hpp.
| auto relx::schema::operator!= | ( | const column< TableT1, Name1, T1, Modifiers1... > & | col1, |
| const column< TableT2, Name2, T2, Modifiers2... > & | col2 | ||
| ) |
Definition at line 156 of file operators.hpp.
| auto relx::schema::operator!= | ( | const ValueType & | value, |
| const column< TableT, Name, T, Modifiers... > & | col | ||
| ) |
Definition at line 267 of file operators.hpp.
| auto relx::schema::operator&& | ( | const column< TableT, Name, bool, Modifiers... > & | col, |
| const Cond & | cond | ||
| ) |
Definition at line 305 of file operators.hpp.
| auto relx::schema::operator&& | ( | const column< TableT, Name, bool, Modifiers... > & | col, |
| const Expr & | expr | ||
| ) |
Definition at line 230 of file operators.hpp.
| auto relx::schema::operator&& | ( | const Cond & | cond, |
| const column< TableT, Name, bool, Modifiers... > & | col | ||
| ) |
Definition at line 331 of file operators.hpp.
| auto relx::schema::operator&& | ( | const Expr & | expr, |
| const column< TableT, Name, bool, Modifiers... > & | col | ||
| ) |
Definition at line 237 of file operators.hpp.
| auto relx::schema::operator< | ( | const column< TableT, Name, T, Modifiers... > & | col, |
| const ValueType & | value | ||
| ) |
Definition at line 120 of file operators.hpp.
| auto relx::schema::operator< | ( | const column< TableT1, Name1, T1, Modifiers1... > & | col1, |
| const column< TableT2, Name2, T2, Modifiers2... > & | col2 | ||
| ) |
Definition at line 182 of file operators.hpp.
| auto relx::schema::operator< | ( | const ValueType & | value, |
| const column< TableT, Name, T, Modifiers... > & | col | ||
| ) |
Definition at line 281 of file operators.hpp.
| std::ostream & relx::schema::operator<< | ( | std::ostream & | os, |
| const fixed_string< N > & | str | ||
| ) |
Definition at line 57 of file fixed_string.hpp.
| auto relx::schema::operator<= | ( | const column< TableT, Name, T, Modifiers... > & | col, |
| const ValueType & | value | ||
| ) |
Definition at line 134 of file operators.hpp.
| auto relx::schema::operator<= | ( | const column< TableT1, Name1, T1, Modifiers1... > & | col1, |
| const column< TableT2, Name2, T2, Modifiers2... > & | col2 | ||
| ) |
Definition at line 208 of file operators.hpp.
| auto relx::schema::operator<= | ( | const ValueType & | value, |
| const column< TableT, Name, T, Modifiers... > & | col | ||
| ) |
Definition at line 295 of file operators.hpp.
| auto relx::schema::operator== | ( | const column< TableT, Name, T, Modifiers... > & | col, |
| const ValueType & | value | ||
| ) |
Definition at line 99 of file operators.hpp.
| auto relx::schema::operator== | ( | const column< TableT1, Name1, T1, Modifiers1... > & | col1, |
| const column< TableT2, Name2, T2, Modifiers2... > & | col2 | ||
| ) |
Definition at line 142 of file operators.hpp.
| auto relx::schema::operator== | ( | const ValueType & | value, |
| const column< TableT, Name, T, Modifiers... > & | col | ||
| ) |
Definition at line 260 of file operators.hpp.
| auto relx::schema::operator> | ( | const column< TableT, Name, T, Modifiers... > & | col, |
| const ValueType & | value | ||
| ) |
Definition at line 113 of file operators.hpp.
| auto relx::schema::operator> | ( | const column< TableT1, Name1, T1, Modifiers1... > & | col1, |
| const column< TableT2, Name2, T2, Modifiers2... > & | col2 | ||
| ) |
Definition at line 169 of file operators.hpp.
| auto relx::schema::operator> | ( | const ValueType & | value, |
| const column< TableT, Name, T, Modifiers... > & | col | ||
| ) |
Definition at line 274 of file operators.hpp.
| auto relx::schema::operator>= | ( | const column< TableT, Name, T, Modifiers... > & | col, |
| const ValueType & | value | ||
| ) |
Definition at line 127 of file operators.hpp.
| auto relx::schema::operator>= | ( | const column< TableT1, Name1, T1, Modifiers1... > & | col1, |
| const column< TableT2, Name2, T2, Modifiers2... > & | col2 | ||
| ) |
Definition at line 195 of file operators.hpp.
| auto relx::schema::operator>= | ( | const ValueType & | value, |
| const column< TableT, Name, T, Modifiers... > & | col | ||
| ) |
Definition at line 288 of file operators.hpp.
| auto relx::schema::operator|| | ( | const column< TableT, Name, bool, Modifiers... > & | col, |
| const Cond & | cond | ||
| ) |
Definition at line 318 of file operators.hpp.
| auto relx::schema::operator|| | ( | const column< TableT, Name, bool, Modifiers... > & | col, |
| const Expr & | expr | ||
| ) |
Definition at line 244 of file operators.hpp.
| auto relx::schema::operator|| | ( | const Cond & | cond, |
| const column< TableT, Name, bool, Modifiers... > & | col | ||
| ) |
Definition at line 344 of file operators.hpp.
| auto relx::schema::operator|| | ( | const Expr & | expr, |
| const column< TableT, Name, bool, Modifiers... > & | col | ||
| ) |
Definition at line 251 of file operators.hpp.
|
constexpr |
Convert reference action to SQL string.
| action | The action to convert |
Definition at line 21 of file foreign_key.hpp.
|
constexpr |
Helper function to create an unnamed check constraint at compile time.
| Condition | The SQL condition |
Definition at line 100 of file check_constraint.hpp.