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

Commit

Permalink
format all files using clang format
Browse files Browse the repository at this point in the history
command used: 
find -name '*.cpp' -o -name '*.h' | xargs clang-format -i
  • Loading branch information
DoozyX committed Oct 14, 2019
1 parent 9d92007 commit e8a2cda
Show file tree
Hide file tree
Showing 106 changed files with 10,240 additions and 8,426 deletions.
62 changes: 31 additions & 31 deletions dev/aggregate_functions.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
#pragma once

namespace sqlite_orm {

namespace aggregate_functions {

template<class T>
struct avg_t {
T t;

operator std::string() const {
return "AVG";
}
};

template<class T>
struct count_t {
T t;

operator std::string() const {
return "COUNT";
}
};

/**
* T is use to specify type explicitly for queries like
* SELECT COUNT(*) FROM table_name;
Expand All @@ -30,119 +30,119 @@ namespace sqlite_orm {
template<class T>
struct count_asterisk_t {
using type = T;

operator std::string() const {
return "COUNT";
}
};

struct count_asterisk_without_type {
operator std::string() const {
return "COUNT";
}
};

template<class T>
struct sum_t {
T t;

operator std::string() const {
return "SUM";
}
};

template<class T>
struct total_t {
T t;

operator std::string() const {
return "TOTAL";
}
};

template<class T>
struct max_t {
T t;

operator std::string() const {
return "MAX";
}
};

template<class T>
struct min_t {
T t;

operator std::string() const {
return "MIN";
}
};

template<class T>
struct group_concat_single_t {
T t;

operator std::string() const {
return "GROUP_CONCAT";
}
};

template<class T>
struct group_concat_double_t {
T t;
std::string y;

operator std::string() const {
return "GROUP_CONCAT";
}
};

}

template<class T>
aggregate_functions::avg_t<T> avg(T t) {
return {t};
}

template<class T>
aggregate_functions::count_t<T> count(T t) {
return {t};
}

inline aggregate_functions::count_asterisk_without_type count() {
return {};
}

template<class T>
aggregate_functions::count_asterisk_t<T> count() {
return {};
}

template<class T>
aggregate_functions::sum_t<T> sum(T t) {
return {t};
}

template<class T>
aggregate_functions::max_t<T> max(T t) {
return {t};
}

template<class T>
aggregate_functions::min_t<T> min(T t) {
return {t};
}

template<class T>
aggregate_functions::total_t<T> total(T t) {
return {t};
}

template<class T>
aggregate_functions::group_concat_single_t<T> group_concat(T t) {
return {t};
}

template<class T, class Y>
aggregate_functions::group_concat_double_t<T> group_concat(T t, Y y) {
return {t, y};
Expand Down
123 changes: 75 additions & 48 deletions dev/alias.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,49 @@

#include <type_traits> // std::enable_if, std::is_base_of, std::is_member_pointer
#include <sstream> // std::stringstream
#include <string> // std::string
#include <string> // std::string

namespace sqlite_orm {

/**
* This is base class for every class which is used as a custom table alias.
* For more information please look through self_join.cpp example
*/
struct alias_tag {};

namespace internal {

/**
* This is a common built-in class used for custom single character table aliases.
* Also you can use language aliases `alias_a`, `alias_b` etc. instead
*/
template<class T, char A>
struct table_alias : alias_tag {
using type = T;

static char get() {
return A;
}
};

/**
* Column expression with table alias attached like 'C.ID'. This is not a column alias
*/
template<class T, class C>
struct alias_column_t {
using alias_type = T;
using column_type = C;

column_type column;
alias_column_t() {};
alias_column_t(column_type column_): column(column_) {}

alias_column_t(){};

alias_column_t(column_type column_) : column(column_) {}
};

template<class T, class SFINAE = void>
struct alias_extractor;

template<class T>
struct alias_extractor<T, typename std::enable_if<std::is_base_of<alias_tag, T>::value>::type> {
static std::string get() {
Expand All @@ -53,72 +53,99 @@ namespace sqlite_orm {
return ss.str();
}
};

template<class T>
struct alias_extractor<T, typename std::enable_if<!std::is_base_of<alias_tag, T>::value>::type> {
static std::string get() {
return {};
}
};

template<class T, class E>
struct as_t {
using alias_type = T;
using expression_type = E;

expression_type expression;
};

template<class T>
struct alias_holder {
using type = T;
};
}

/**
* @return column with table alias attached. Place it instead of a column statement in case you need to specify a
* column with table alias prefix like 'a.column'. For more information please look through self_join.cpp example
*/
template<class T, class C>
internal::alias_column_t<T, C> alias_column(C c) {
static_assert(std::is_member_pointer<C>::value, "alias_column argument must be a member pointer mapped to a storage");
static_assert(std::is_member_pointer<C>::value,
"alias_column argument must be a member pointer mapped to a storage");
return {c};
}

template<class T, class E>
internal::as_t<T, E> as(E expression) {
return {std::move(expression)};
}

template<class T>
internal::alias_holder<T> get() {
return {};
}

template<class T> using alias_a = internal::table_alias<T, 'a'>;
template<class T> using alias_b = internal::table_alias<T, 'b'>;
template<class T> using alias_c = internal::table_alias<T, 'c'>;
template<class T> using alias_d = internal::table_alias<T, 'd'>;
template<class T> using alias_e = internal::table_alias<T, 'e'>;
template<class T> using alias_f = internal::table_alias<T, 'f'>;
template<class T> using alias_g = internal::table_alias<T, 'g'>;
template<class T> using alias_h = internal::table_alias<T, 'h'>;
template<class T> using alias_i = internal::table_alias<T, 'i'>;
template<class T> using alias_j = internal::table_alias<T, 'j'>;
template<class T> using alias_k = internal::table_alias<T, 'k'>;
template<class T> using alias_l = internal::table_alias<T, 'l'>;
template<class T> using alias_m = internal::table_alias<T, 'm'>;
template<class T> using alias_n = internal::table_alias<T, 'n'>;
template<class T> using alias_o = internal::table_alias<T, 'o'>;
template<class T> using alias_p = internal::table_alias<T, 'p'>;
template<class T> using alias_q = internal::table_alias<T, 'q'>;
template<class T> using alias_r = internal::table_alias<T, 'r'>;
template<class T> using alias_s = internal::table_alias<T, 's'>;
template<class T> using alias_t = internal::table_alias<T, 't'>;
template<class T> using alias_u = internal::table_alias<T, 'u'>;
template<class T> using alias_v = internal::table_alias<T, 'v'>;
template<class T> using alias_w = internal::table_alias<T, 'w'>;
template<class T> using alias_x = internal::table_alias<T, 'x'>;
template<class T> using alias_y = internal::table_alias<T, 'y'>;
template<class T> using alias_z = internal::table_alias<T, 'z'>;

template<class T>
using alias_a = internal::table_alias<T, 'a'>;
template<class T>
using alias_b = internal::table_alias<T, 'b'>;
template<class T>
using alias_c = internal::table_alias<T, 'c'>;
template<class T>
using alias_d = internal::table_alias<T, 'd'>;
template<class T>
using alias_e = internal::table_alias<T, 'e'>;
template<class T>
using alias_f = internal::table_alias<T, 'f'>;
template<class T>
using alias_g = internal::table_alias<T, 'g'>;
template<class T>
using alias_h = internal::table_alias<T, 'h'>;
template<class T>
using alias_i = internal::table_alias<T, 'i'>;
template<class T>
using alias_j = internal::table_alias<T, 'j'>;
template<class T>
using alias_k = internal::table_alias<T, 'k'>;
template<class T>
using alias_l = internal::table_alias<T, 'l'>;
template<class T>
using alias_m = internal::table_alias<T, 'm'>;
template<class T>
using alias_n = internal::table_alias<T, 'n'>;
template<class T>
using alias_o = internal::table_alias<T, 'o'>;
template<class T>
using alias_p = internal::table_alias<T, 'p'>;
template<class T>
using alias_q = internal::table_alias<T, 'q'>;
template<class T>
using alias_r = internal::table_alias<T, 'r'>;
template<class T>
using alias_s = internal::table_alias<T, 's'>;
template<class T>
using alias_t = internal::table_alias<T, 't'>;
template<class T>
using alias_u = internal::table_alias<T, 'u'>;
template<class T>
using alias_v = internal::table_alias<T, 'v'>;
template<class T>
using alias_w = internal::table_alias<T, 'w'>;
template<class T>
using alias_x = internal::table_alias<T, 'x'>;
template<class T>
using alias_y = internal::table_alias<T, 'y'>;
template<class T>
using alias_z = internal::table_alias<T, 'z'>;
}
Loading

0 comments on commit e8a2cda

Please sign in to comment.