#include #include "hack/logger/logger.hpp" #include "hack/utils/utils.hpp" #include "hack/utils/func_query.hpp" int f(int a) { hack::log()("f implementatioln"); return ++a; } int plus(int a) { return ++a; } int minus(int a) { return --a; } struct counter_test { counter_test() : id { ++hack::utils::counter::id } { } int id; }; struct counter_test_2 { counter_test_2() : id { ++hack::utils::counter::id } { } int id; }; auto main(int argc, char *argv[]) -> int { {// ex: utils::func_memory int a = 12; auto cach_f = hack::utils::func_memory(f); hack::log()("result 1", cach_f(a)); hack::log()("result 2", cach_f(a)); } {// ex: utils::func_concat int a = 1; auto combine ( hack::utils::func_concat(plus, minus, plus, f) ); hack::log("")("func_concat result: ", combine(a), a); } {// ex: utils::exec hack::log()(hack::utils::unix_cmd("ls")); hack::log()(hack::utils::unix_cmd("pwd")); auto t = hack::utils::unix_cmd("pwd"); hack::log::type_trace(t); } {// ex: counter counter_test a, b, c; counter_test_2 a1, b1, c1; hack::log()(c.id); hack::log()(c1.id); } {// ex: case as string switch(hack::utils::case_int("test")) { case hack::utils::case_int("test"): hack::log()("wow"); break; case hack::utils::case_int("no_test"): hack::log()("ups"); break; } } {// ex: query function auto query = hack::utils::make_query("super_function", "1", "two"); hack::log()("query", query); query = hack::utils::make_query("super_function", 1, 'c'); hack::log()("query", query); hack::utils::JSON js { "test", "data" }; query = hack::utils::make_query("super_function", 1, 123.3f, js); hack::log()("query", query); query = hack::utils::make_query("super_function"); hack::log()("query", query); } }