updated build system

This commit is contained in:
Scott E. Graves 2024-10-10 12:52:51 -05:00
parent 7a683a46a9
commit 6645b322bd
3 changed files with 54 additions and 15 deletions

View File

@ -30,14 +30,14 @@ template <typename cn_t, typename ctx_t, typename op_t, typename w_t,
typename wn_t>
struct db_next_limit_t final {
std::shared_ptr<ctx_t> ctx;
std::string action;
w_t *owner;
w_t next{ctx};
std::string action;
using group_func_t = std::function<void(w_t &)>;
[[nodiscard]] auto where(std::string column_name) -> cn_t {
return next.where(column_name);
return get_next().where(column_name);
}
[[nodiscard]] auto dump() const -> std::string { return op_t{ctx}.dump(); }
@ -46,10 +46,18 @@ struct db_next_limit_t final {
return ctx->where->dump(idx);
}
[[nodiscard]] auto get_next() -> wn_t & {
return std::get<w_t>(std::prev(owner->sub_actions->end()));
}
[[nodiscard]] auto get_next() const -> const wn_t & {
return std::get<w_t>(std::prev(owner->sub_actions->end()));
}
[[nodiscard]] auto go() const -> auto { return op_t{ctx}.go(); }
[[nodiscard]] auto group(group_func_t func) -> wn_t {
return next.group(std::move(func));
return get_next().group(std::move(func));
}
[[nodiscard]] auto limit(std::int32_t value) -> op_t {
@ -68,12 +76,17 @@ struct db_where_next_limit_t final {
using n_t = db_next_limit_t<cn_t, ctx_t, op_t, w_t, db_where_next_limit_t>;
[[nodiscard]] auto and_() -> n_t & {
[[nodiscard]] auto and_() -> n_t {
owner->actions.emplace_back(n_t{
ctx,
owner,
"AND",
});
owner->sub_actions.emplace_back(w_t{
ctx,
});
return std::get<n_t>(*std::prev(owner->actions.end()));
}
@ -93,12 +106,17 @@ struct db_where_next_limit_t final {
return op_t{ctx}.order_by(column_name, ascending);
}
[[nodiscard]] auto or_() -> n_t & {
[[nodiscard]] auto or_() -> n_t {
owner->actions.emplace_back(n_t{
ctx,
owner,
"OR",
});
owner->sub_actions.emplace_back(w_t{
ctx,
});
return std::get<n_t>(*std::prev(owner->actions.end()));
}
};
@ -152,6 +170,7 @@ template <typename ctx_t, typename op_t> struct db_where_with_limit_t final {
using action_t = std::variant<db_comp_data_t, n_t, db_where_with_limit_t>;
std::vector<action_t> actions{};
std::vector<db_where_limit_t> sub_actions{};
[[nodiscard]] static auto dump(std::int32_t &idx,
auto &&data) -> std::string {
@ -165,7 +184,7 @@ template <typename ctx_t, typename op_t> struct db_where_with_limit_t final {
},
[&idx, &stream](const n_t &next) {
stream << ' ' << next.action << ' '
<< dump(idx, next.next);
<< dump(idx, next.get_next());
},
[&idx, &stream](const db_where_with_limit_t &where) {
stream << '(' << dump(idx, where) << ')';

View File

@ -30,14 +30,13 @@ template <typename cn_t, typename ctx_t, typename op_t, typename w_t,
typename wn_t>
struct db_next_t final {
std::shared_ptr<ctx_t> ctx;
w_t *owner;
std::string action;
w_t next{ctx};
using group_func_t = std::function<void(w_t &)>;
[[nodiscard]] auto where(std::string column_name) -> cn_t {
return next.where(column_name);
return get_next().where(column_name);
}
[[nodiscard]] auto dump() const -> std::string { return op_t{ctx}.dump(); }
@ -46,10 +45,18 @@ struct db_next_t final {
return ctx->where->dump(idx);
}
[[nodiscard]] auto get_next() -> wn_t & {
return std::get<w_t>(std::prev(owner->sub_actions->end()));
}
[[nodiscard]] auto get_next() const -> const wn_t & {
return std::get<w_t>(std::prev(owner->sub_actions->end()));
}
[[nodiscard]] auto go() const -> auto { return op_t{ctx}.go(); }
[[nodiscard]] auto group(group_func_t func) -> wn_t {
return next.group(std::move(func));
return get_next().group(std::move(func));
}
};
@ -60,12 +67,17 @@ struct db_where_next_t final {
using n_t = db_next_t<cn_t, ctx_t, op_t, w_t, db_where_next_t>;
[[nodiscard]] auto and_() -> n_t & {
[[nodiscard]] auto and_() -> n_t {
owner->actions.emplace_back(n_t{
ctx,
owner,
"AND",
});
owner->sub_actions.emplace_back(w_t{
ctx,
});
return std::get<n_t>(*std::prev(owner->actions.end()));
}
@ -77,12 +89,17 @@ struct db_where_next_t final {
[[nodiscard]] auto go() const -> auto { return op_t{ctx}.go(); }
[[nodiscard]] auto or_() -> n_t & {
[[nodiscard]] auto or_() -> n_t {
owner->actions.emplace_back(n_t{
ctx,
owner,
"OR",
});
owner->sub_actions.emplace_back(w_t{
ctx,
});
return std::get<n_t>(*std::prev(owner->actions.end()));
}
};
@ -136,6 +153,7 @@ template <typename ctx_t, typename op_t> struct db_where_t final {
using action_t = std::variant<db_comp_data_t, n_t, db_where_t>;
std::vector<action_t> actions{};
std::vector<db_where_t> sub_actions{};
[[nodiscard]] static auto dump(std::int32_t &idx,
auto &&data) -> std::string {
@ -149,7 +167,7 @@ template <typename ctx_t, typename op_t> struct db_where_t final {
},
[&idx, &stream](const n_t &next) {
stream << ' ' << next.action << ' '
<< dump(idx, next.next);
<< dump(idx, next.get_next());
},
[&idx, &stream](const db_where_t &where) {
stream << '(' << dump(idx, where) << ')';

View File

@ -44,7 +44,9 @@ auto execute_sql(sqlite3 &db3, const std::string &sql,
}
void set_journal_mode(sqlite3 &db3) {
sqlite3_exec(&db3, "PRAGMA journal_mode = WAL;PRAGMA synchronous = NORMAL;",
sqlite3_exec(&db3,
"PRAGMA journal_mode = WAL;PRAGMA synchronous = NORMAL;PRAGMA "
"auto_vacuum = FULL;",
nullptr, nullptr, nullptr);
}
} // namespace repertory::utils::db::sqlite