This commit is contained in:
Andrey Zimin
2024-05-15 18:55:51 +03:00
parent 478e417dc1
commit 04de2af292
3 changed files with 11 additions and 9 deletions

View File

@@ -3,6 +3,8 @@
#include "hack/utils/singleton.hpp" #include "hack/utils/singleton.hpp"
#include "hack/utils/func_query.hpp" #include "hack/utils/func_query.hpp"
#include "nlohmann/json.hpp"
int f(int a) int f(int a)
{ {
hack::log()("f implementatioln"); hack::log()("f implementatioln");
@@ -54,12 +56,12 @@ auto main(int argc, char *argv[]) -> int
hack::log("")("func_concat result: ", combine(a), a); hack::log("")("func_concat result: ", combine(a), a);
} }
{// ex: utils::exec // {// ex: utils::exec
hack::log()(hack::utils::unix_cmd("ls")); // hack::log()(hack::utils::unix_cmd("ls"));
hack::log()(hack::utils::unix_cmd("pwd")); // hack::log()(hack::utils::unix_cmd("pwd"));
auto t = hack::utils::unix_cmd("pwd"); // auto t = hack::utils::unix_cmd("pwd");
hack::log::type_trace(t); // hack::log::type_trace(t);
} // }
{// ex: counter {// ex: counter
counter_test a, b, c; counter_test a, b, c;
@@ -88,7 +90,7 @@ auto main(int argc, char *argv[]) -> int
hack::log()("JSON sting", query); hack::log()("JSON sting", query);
nlohmann::json js { "test", "data" }; nlohmann::json js { "test", "data" };
query = hack::utils::make_query("super_function", 1'000'000, 123.3f, js); query = hack::utils::make_query<nlohmann::json>("super_function", 1'000'000, 123.3f, js);
hack::log()("JSON", query); hack::log()("JSON", query);
query = hack::utils::make_query("super_function"); query = hack::utils::make_query("super_function");

Submodule sandbox/subprojects/hack updated: b14e81244d...478e417dc1

View File

@@ -63,7 +63,7 @@ namespace hack::utils
template<typename Json> template<typename Json>
inline std::string make_one(const Json& f) inline std::string make_one(const Json& f)
{ {
auto f_str = f; auto f_str = f.dump();
f_str = std::regex_replace(f_str, std::regex("'"), "[quote]"); f_str = std::regex_replace(f_str, std::regex("'"), "[quote]");
return hack::string::str_concat + "'" + f_str + "'::jsonb,"; return hack::string::str_concat + "'" + f_str + "'::jsonb,";
} }