updated build system
Some checks reported errors
BlockStorage/repertory/pipeline/head Something is wrong with the build of this commit

This commit is contained in:
2024-10-11 15:56:46 -05:00
parent 3c97c2d953
commit 284e2a3ead
11 changed files with 73 additions and 72 deletions

View File

@ -57,10 +57,10 @@ struct db_comp_data_t final {
};
struct db_context_t {
db_context_t(sqlite3 &db3_, std::string table_name_)
db_context_t(sqlite3 *db3_, std::string table_name_)
: db3(db3_), table_name(std::move(table_name_)) {}
sqlite3 &db3;
sqlite3 *db3{};
std::string table_name;
db3_stmt_t stmt;

View File

@ -39,13 +39,14 @@ public:
[[nodiscard]] auto go() const -> db_result<context>;
};
context(sqlite3 &db3_, std::string table_name_)
context(sqlite3 *db3_, std::string table_name_)
: db_context_t(db3_, table_name_) {}
using w_t = db_where_t<context, db_delete_op_t>;
std::optional<w_t> where;
std::vector<db_types_t> where_values;
std::map<std::size_t, std::vector<w_t::action_t>> actions;
void clear();
};
@ -54,7 +55,7 @@ public:
public:
db_delete(sqlite3 &db3, std::string table_name)
: context_(std::make_shared<context>(db3, table_name)) {}
: context_(std::make_shared<context>(&db3, table_name)) {}
db_delete(std::shared_ptr<context> ctx) : context_(std::move(ctx)) {}

View File

@ -29,11 +29,11 @@ namespace repertory::utils::db::sqlite {
class db_insert final {
public:
struct context final : db_context_t {
context(sqlite3 &db3_, std::string table_name_)
context(sqlite3 *db3_, std::string table_name_)
: db_context_t(db3_, table_name_) {}
bool or_replace{false};
std::map<std::string, db_types_t> values{};
std::map<std::string, db_types_t> values;
void clear() { values.clear(); }
};
@ -42,7 +42,7 @@ public:
public:
db_insert(sqlite3 &db3, std::string table_name)
: context_(std::make_shared<context>(db3, table_name)) {}
: context_(std::make_shared<context>(&db3, table_name)) {}
db_insert(std::shared_ptr<context> ctx) : context_(std::move(ctx)) {}

View File

@ -46,7 +46,7 @@ public:
bool ascending) -> db_select_op_t;
};
context(sqlite3 &db3_, std::string table_name_)
context(sqlite3 *db3_, std::string table_name_)
: db_context_t(db3_, table_name_) {}
using w_t = db_where_t<context, db_select_op_t>;
@ -59,6 +59,7 @@ public:
std::optional<std::pair<std::string, bool>> order_by;
std::optional<w_t> where;
std::vector<db_types_t> where_values;
std::map<std::size_t, std::vector<w_t::action_t>> actions;
void clear();
};
@ -67,7 +68,7 @@ public:
public:
db_select(sqlite3 &db3, std::string table_name)
: context_(std::make_shared<context>(db3, table_name)) {}
: context_(std::make_shared<context>(&db3, table_name)) {}
db_select(std::shared_ptr<context> ctx) : context_(std::move(ctx)) {}

View File

@ -31,7 +31,7 @@ namespace repertory::utils::db::sqlite {
class db_update final {
public:
struct context final : db_context_t {
context(sqlite3 &db3_, std::string table_name_)
context(sqlite3 *db3_, std::string table_name_)
: db_context_t(db3_, table_name_) {}
struct db_update_op_t final {
@ -54,6 +54,7 @@ public:
std::optional<std::pair<std::string, bool>> order_by;
std::optional<w_t> where;
std::vector<db_types_t> where_values;
std::map<std::size_t, std::vector<w_t::action_t>> actions;
void clear();
};
@ -62,7 +63,7 @@ public:
public:
db_update(sqlite3 &db3, std::string table_name)
: context_(std::make_shared<context>(db3, table_name)) {}
: context_(std::make_shared<context>(&db3, table_name)) {}
db_update(std::shared_ptr<context> ctx) : context_(std::move(ctx)) {}

View File

@ -29,14 +29,14 @@ namespace repertory::utils::db::sqlite {
template <typename cn_t, typename ctx_t, typename op_t, typename w_t,
typename wn_t>
struct db_next_t final {
std::size_t action_idx{};
std::shared_ptr<ctx_t> ctx;
w_t *owner;
std::string action;
using group_func_t = std::function<void(w_t &)>;
[[nodiscard]] auto where(std::string column_name) -> cn_t {
return get_next().where(column_name);
return w_t{action_idx, ctx}.where(column_name);
}
[[nodiscard]] auto dump() const -> std::string { return op_t{ctx}.dump(); }
@ -45,18 +45,10 @@ struct db_next_t final {
return ctx->where->dump(idx);
}
[[nodiscard]] auto get_next() -> w_t & {
return *std::prev(owner->sub_actions.end());
}
[[nodiscard]] auto get_next() const -> const w_t & {
return *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 get_next().group(std::move(func));
return w_t{action_idx, ctx}.group(std::move(func));
}
[[nodiscard]] auto op() -> op_t {
@ -68,23 +60,20 @@ struct db_next_t final {
template <typename cn_t, typename ctx_t, typename op_t, typename w_t>
struct db_where_next_t final {
std::size_t action_idx{};
std::shared_ptr<ctx_t> ctx;
w_t *owner;
using n_t = db_next_t<cn_t, ctx_t, op_t, w_t, db_where_next_t>;
[[nodiscard]] auto and_() -> n_t {
owner->actions.emplace_back(n_t{
n_t next{
action_idx,
ctx,
owner,
"AND",
});
};
owner->sub_actions.emplace_back(w_t{
ctx,
});
return std::get<n_t>(*std::prev(owner->actions.end()));
ctx->actions[action_idx].emplace_back(next);
return next;
}
[[nodiscard]] auto dump() const -> std::string { return op_t{ctx}.dump(); }
@ -102,30 +91,27 @@ struct db_where_next_t final {
}
[[nodiscard]] auto or_() -> n_t {
owner->actions.emplace_back(n_t{
n_t next{
action_idx,
ctx,
owner,
"OR",
});
};
owner->sub_actions.emplace_back(w_t{
ctx,
});
return std::get<n_t>(*std::prev(owner->actions.end()));
ctx->actions[action_idx].emplace_back(next);
return next;
}
};
template <typename ctx_t, typename op_t, typename w_t>
struct db_comp_next_t final {
std::size_t action_idx{};
std::shared_ptr<ctx_t> ctx;
w_t *owner;
std::string column_name;
using wn_t = db_where_next_t<db_comp_next_t, ctx_t, op_t, w_t>;
[[nodiscard]] auto create(std::string operation, db_types_t value) {
owner->actions.emplace_back(db_comp_data_t{
ctx->actions[action_idx].emplace_back(db_comp_data_t{
column_name,
operation,
});
@ -133,8 +119,8 @@ struct db_comp_next_t final {
ctx->where_values.push_back(value);
return wn_t{
action_idx,
ctx,
owner,
};
}
@ -154,6 +140,7 @@ struct db_comp_next_t final {
};
template <typename ctx_t, typename op_t> struct db_where_t final {
std::size_t action_idx{0U};
std::shared_ptr<ctx_t> ctx;
using cn_t = db_comp_next_t<ctx_t, op_t, db_where_t>;
@ -164,25 +151,21 @@ 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 {
auto &&actions) -> std::string {
std::stringstream stream;
for (auto &&action : data.actions) {
for (auto &&action : actions) {
std::visit(overloaded{
[&idx, &stream](const db_comp_data_t &comp) {
stream << '"' << comp.column_name << '"' << comp.op_type
<< '?' + std::to_string(++idx);
},
[&idx, &stream](const n_t &next) {
stream << ' ' << next.action << ' '
<< dump(idx, next.get_next());
stream << ' ' << next.action << ' ';
},
[&idx, &stream](const db_where_t &where) {
stream << '(' << dump(idx, where) << ')';
stream << '(' << dump(idx, where.get_actions()) << ')';
},
},
action);
@ -194,24 +177,37 @@ template <typename ctx_t, typename op_t> struct db_where_t final {
[[nodiscard]] auto dump() const -> std::string { return op_t{ctx}.dump(); }
[[nodiscard]] auto dump(std::int32_t &idx) const -> std::string {
return dump(idx, *this);
return dump(idx, ctx->actions[action_idx]);
}
[[nodiscard]] auto get_actions() -> auto & {
return ctx->actions[action_idx];
}
[[nodiscard]] auto get_actions() const -> const auto & {
return ctx->actions[action_idx];
}
[[nodiscard]] auto group(group_func_t func) -> wn_t {
db_where_t where{ctx};
ctx->actions[action_idx];
db_where_t where{ctx->actions.size(), ctx};
func(where);
actions.emplace_back(std::move(where));
ctx->actions[action_idx].emplace_back(where);
return wn_t{
action_idx,
ctx,
this,
};
}
[[nodiscard]] auto where(std::string column_name) -> cn_t {
ctx->actions[action_idx];
return cn_t{
action_idx,
ctx,
this,
column_name,
};
}