updated build system
Some checks reported errors
BlockStorage/repertory/pipeline/head Something is wrong with the build of this commit
Some checks reported errors
BlockStorage/repertory/pipeline/head Something is wrong with the build of this commit
This commit is contained in:
parent
3c97c2d953
commit
284e2a3ead
7
.nvimrc
7
.nvimrc
@ -18,14 +18,14 @@ if vim.env.NV_DARCULA_ENABLE_DAP then
|
||||
|
||||
local externalConsole = gos.is_windows
|
||||
local type = "cppdbg"
|
||||
local cwd = gpath.create_path("./build")
|
||||
local cwd = gpath.create_path("./dist/debug/shared/linux/x86_64/repertory/")
|
||||
dap.configurations.cpp = {
|
||||
{
|
||||
name = "Mount",
|
||||
type = type,
|
||||
request = "launch",
|
||||
program = function()
|
||||
return gpath.create_path(cwd, "repertory")
|
||||
return gpath.create_path(cwd, "bin/repertory")
|
||||
end,
|
||||
cwd = cwd,
|
||||
stopAtEntry = true,
|
||||
@ -36,8 +36,9 @@ if vim.env.NV_DARCULA_ENABLE_DAP then
|
||||
type = type,
|
||||
request = "launch",
|
||||
program = function()
|
||||
return gpath.create_path(cwd, "repertory_tests")
|
||||
return gpath.create_path(cwd, "bin/repertory_test")
|
||||
end,
|
||||
args={"--gtest_filter=utils_db*"},
|
||||
cwd = cwd,
|
||||
stopAtEntry = true,
|
||||
externalConsole=externalConsole,
|
||||
|
@ -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;
|
||||
|
@ -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)) {}
|
||||
|
||||
|
@ -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)) {}
|
||||
|
||||
|
@ -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)) {}
|
||||
|
||||
|
@ -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)) {}
|
||||
|
||||
|
@ -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,
|
||||
};
|
||||
}
|
||||
|
@ -54,8 +54,8 @@ auto db_delete::dump() const -> std::string {
|
||||
auto db_delete::go() const -> db_result<context> {
|
||||
sqlite3_stmt *stmt_ptr{nullptr};
|
||||
auto query_str = dump();
|
||||
auto res = sqlite3_prepare_v2(&context_->db3, query_str.c_str(), -1,
|
||||
&stmt_ptr, nullptr);
|
||||
auto res = sqlite3_prepare_v2(context_->db3, query_str.c_str(), -1, &stmt_ptr,
|
||||
nullptr);
|
||||
context_->stmt = db3_stmt_t{
|
||||
stmt_ptr,
|
||||
sqlite3_statement_deleter(),
|
||||
@ -88,7 +88,7 @@ auto db_delete::go() const -> db_result<context> {
|
||||
|
||||
auto db_delete::group(context::w_t::group_func_t func) -> context::w_t::wn_t {
|
||||
if (not context_->where.has_value()) {
|
||||
context_->where = context::w_t{context_};
|
||||
context_->where = context::w_t{0U, context_};
|
||||
}
|
||||
|
||||
return context_->where->group(std::move(func));
|
||||
@ -96,7 +96,7 @@ auto db_delete::group(context::w_t::group_func_t func) -> context::w_t::wn_t {
|
||||
|
||||
auto db_delete::where(std::string column_name) const -> context::w_t::cn_t {
|
||||
if (not context_->where.has_value()) {
|
||||
context_->where = context::w_t{context_};
|
||||
context_->where = context::w_t{0U, context_};
|
||||
}
|
||||
|
||||
return context_->where->where(column_name);
|
||||
|
@ -62,8 +62,8 @@ auto db_insert::dump() const -> std::string {
|
||||
auto db_insert::go() const -> db_result<context> {
|
||||
sqlite3_stmt *stmt_ptr{nullptr};
|
||||
auto query_str = dump();
|
||||
auto res = sqlite3_prepare_v2(&context_->db3, query_str.c_str(), -1,
|
||||
&stmt_ptr, nullptr);
|
||||
auto res = sqlite3_prepare_v2(context_->db3, query_str.c_str(), -1, &stmt_ptr,
|
||||
nullptr);
|
||||
context_->stmt = db3_stmt_t{
|
||||
stmt_ptr,
|
||||
sqlite3_statement_deleter(),
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
namespace repertory::utils::db::sqlite {
|
||||
void db_select::context::clear() {
|
||||
std::cout << "clear" << std::endl;
|
||||
columns.clear();
|
||||
count_columns.clear();
|
||||
limit.reset();
|
||||
@ -134,8 +135,8 @@ auto db_select::dump() const -> std::string {
|
||||
auto db_select::go() const -> db_result<context> {
|
||||
sqlite3_stmt *stmt_ptr{nullptr};
|
||||
auto query_str = dump();
|
||||
auto res = sqlite3_prepare_v2(&context_->db3, query_str.c_str(), -1,
|
||||
&stmt_ptr, nullptr);
|
||||
auto res = sqlite3_prepare_v2(context_->db3, query_str.c_str(), -1, &stmt_ptr,
|
||||
nullptr);
|
||||
context_->stmt = db3_stmt_t{
|
||||
stmt_ptr,
|
||||
sqlite3_statement_deleter(),
|
||||
@ -168,7 +169,7 @@ auto db_select::go() const -> db_result<context> {
|
||||
|
||||
auto db_select::group(context::w_t::group_func_t func) -> context::w_t::wn_t {
|
||||
if (not context_->where.has_value()) {
|
||||
context_->where = context::w_t{context_};
|
||||
context_->where = context::w_t{0U, context_};
|
||||
}
|
||||
|
||||
return context_->where->group(std::move(func));
|
||||
@ -192,7 +193,7 @@ auto db_select::order_by(std::string column_name,
|
||||
|
||||
auto db_select::where(std::string column_name) const -> context::w_t::cn_t {
|
||||
if (not context_->where.has_value()) {
|
||||
context_->where = context::w_t{context_};
|
||||
context_->where = context::w_t{0U, context_};
|
||||
}
|
||||
|
||||
return context_->where->where(column_name);
|
||||
|
@ -95,8 +95,8 @@ auto db_update::dump() const -> std::string {
|
||||
auto db_update::go() const -> db_result<context> {
|
||||
sqlite3_stmt *stmt_ptr{nullptr};
|
||||
auto query_str = dump();
|
||||
auto res = sqlite3_prepare_v2(&context_->db3, query_str.c_str(), -1,
|
||||
&stmt_ptr, nullptr);
|
||||
auto res = sqlite3_prepare_v2(context_->db3, query_str.c_str(), -1, &stmt_ptr,
|
||||
nullptr);
|
||||
context_->stmt = db3_stmt_t{
|
||||
stmt_ptr,
|
||||
sqlite3_statement_deleter(),
|
||||
@ -157,7 +157,7 @@ auto db_update::go() const -> db_result<context> {
|
||||
|
||||
auto db_update::group(context::w_t::group_func_t func) -> context::w_t::wn_t {
|
||||
if (not context_->where.has_value()) {
|
||||
context_->where = context::w_t{context_};
|
||||
context_->where = context::w_t{0U, context_};
|
||||
}
|
||||
|
||||
return context_->where->group(std::move(func));
|
||||
@ -176,7 +176,7 @@ auto db_update::order_by(std::string column_name,
|
||||
|
||||
auto db_update::where(std::string column_name) const -> context::w_t::cn_t {
|
||||
if (not context_->where.has_value()) {
|
||||
context_->where = context::w_t{context_};
|
||||
context_->where = context::w_t{0U, context_};
|
||||
}
|
||||
|
||||
return context_->where->where(column_name);
|
||||
|
Loading…
x
Reference in New Issue
Block a user