diff --git a/cpp.json b/cpp.json new file mode 100644 index 0000000..7463118 --- /dev/null +++ b/cpp.json @@ -0,0 +1,326 @@ +{ + /* + // Place your snippets for C here. Each snippet is defined under a snippet name and has a prefix, body and + // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: + // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the + // same ids are connected. + // Example: + "Print to console": { + "prefix": "log", + "body": [ + "console.log('$1');", + "$2" + ], + "description": "Log output to console" + } + + +*/ + "virtual": { + "prefix": "virtual", + "body": [ + "virtual $1 $2() = 0;" + ], + "description": "virtual" + }, + "use_namespace_core": { + "prefix": "uc", + "body": [ + "using namespace core;" + ], + "description": "using namespace core" + }, + "while1": { + "prefix": "while1", + "body": [ + "while(1){sleep(1);}" + ], + "description": "while1" + }, + "header": { + "prefix": "#ifndef", + "body": [ + "#ifndef $0", + "#define $0", + "#ifdef __cplusplus", + "extern \"C\" {", + "#endif", + "", + "", + "#ifdef __cplusplus", + "}", + "#endif", + "#endif", + ], + "description": "header" + }, + "usname": { + "prefix": "usname", + "body": [ + "using namespace $1" + ], + "description": "usname" + }, + "main": { + "prefix": "main", + "body": [ + "int main(int argc, char* const argv[]) {", + "", + "return 0;", + "}", + ], + "description": "main" + }, + "out": { + "prefix": "out", + "body": [ + "<<\"$1\"<<$2<<\"$3\"", + ], + "description": "out" + }, + "struct": { + "prefix": "struct", + "body": [ + "typedef struct {", + "$1", + "}$0_t;", + ], + "description": "struct" + }, + "mutex_rec": { + "prefix": "mutex_rec", + "body": [ + "#include ", + "std::recursive_mutex lock_;", + "std::lock_guard lock(lock_);" + ], + "description": "mutex_rec" + }, + "mutex_normal": { + "prefix": "mutex_normal", + "body": [ + "#include ", + "std::mutex lock_;", + "std::lock_guard lock(lock_);" + ], + "description": "mutex_normal" + }, + "for": { + "prefix": "for", + "body": [ + "for(auto& var : $2)", + "{\n}" + ], + "description": "for" + }, + + "#pra": { + "prefix": "#pra", + "body": [ + "#pragma once", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "namespace zwsd {", + "using namespace std;", + "} // namespace zwsd", + ], + "description": "pragma once" + }, + "create_service": { + "prefix": "create_service", + "body": [ + "//", + "// Created by zwsd", + "//", + "", + "#pragma once", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "", + "#include \"zwtimecpp/core/core.hpp\"", + "#include \"zwtimecpp/core/logger/logger.hpp\"", + "#include \"zwtimecpp/core/logger/logger_factory.hpp\"", + "", + "", + "/**", + " * @brief", + " *", + " * service: $1", + " *", + " * 监听事件:", + " * 依赖状态:", + " * 依赖服务:", + " * 作用:", + " *", + " */", + "", + "namespace zwsd {", + "using namespace std;", + "using namespace core;", + "class $1 : public EventHandler,", + " public enable_shared_from_this<$1> {", + " ENABLE_LOGGER($1);", + "", + " shared_ptr core; //监听事件", + "", + " public:", + " $1(const shared_ptr &core):core(core){};", + "", + " void initialize(){};", + "", + " virtual void onEvent(shared_ptr ptr) override{};", + "};", + "} // namespace zwsd" + ], + "description": "create_service" + }, + "create_event": { + "prefix": "create_event", + "body": [ + "//", + "// Created by zwsd", + "//", + "", + "#pragma once", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include \"zwtimecpp/core/base/base_event.hpp\"", + "#include \"zwtimecpp/core/utils/better-enums/enum.h\"", + "namespace zwsd {", + "using namespace std;", + "using namespace core;", + "class ${1} : public BaseEvent {", + " DECLEAR_EVENT(${1});", + "", + " ${1}() {}", + "", + " public:", + " public:", + " static shared_ptr<${1}> create() {", + " shared_ptr<${1}> var(new ${1}());", + " return var;", + " }", + "};", + "}" + ], + "description": "create_event" + }, + "create_runner": { + "prefix": "create_runner", + "body": [ + "#include \"zwtimecpp/core/logger/logger.hpp\"", + "#include \"zwtimecpp/core/test/test_utils/runner_manager.hpp\"", + "#include \"zwtimecpp/core/thread/thread.hpp\"", + "#include \"zwtimecpp/core/utils/argh/argh.h\"", + "#include \"zwtimecpp/core/utils/better-enums/enum.h\"", + "#include \"zwtimecpp/core/utils/memory_utils.hpp\"", + "#include \"zwtimecpp/core/utils/nlohmann/json.hpp\"", + "", + "#include \"zwtimecpp/core/utils/cli_strong_version.hpp\"", + "", + "using namespace std;", + "using namespace zwsd;", + "using namespace core;", + "using namespace cli;", + "", + "using namespace front_display_msg;", + "", + "class $1 : public Runner {", + "ENABLE_LOGGER($1);", + "", + "public:", + "virtual void run(int argc, const char **argv) override;", + "virtual string introduction(logger_t logForHelp) override {", + "logger->info(\"{}\\n\\t\\t{}\", \"-h\", \"\");", + "logger->info(\"{}\\n\\t\\t{}\", \"-h\", \"\");", + "return \"\";", + "}", + "};", + "", + "void $1::run(int argc, const char **argv) {", + "//命令行参数demo ./runner_main $1 -n name", + "//--string_full_name -b bool_value -i int_value", + "#if 0", + "argh::parser cmdl;", + "string string_short_name;", + "string string_full_name;", + "int int_value;", + "int times;", + "bool bool_value;", + "cmdl.add_params({\"n\"/*string short name*/, \"string_full_name\", \"i\"/*int value*/,\"b\"});", + "cmdl.parse(argc, argv);", + "cmdl(\"-n\", \"default value\") >> string_short_name;", + "cmdl(\"--string_full_name\", \"default value\") >> string_full_name;", + "cmdl(\"-i\", 1) >> int_value;", + "bool_value = cmdl[\"b\"];", + "logger->info(", + "\"string_short_name {} string_full_name {} int_value {} times {} \"", + "\"bool_value{}\",", + "string_short_name, string_full_name, int_value, times, bool_value);", + "#endif", + "Core::initialize();", + "shared_ptr core = Core::Instance();", + "", + "auto rootMenu = make_unique(\"cli\");", + "cli::SetColor();", + "rootMenu->Insert(\"echo\",", + "[&](std::ostream &out, string eventName, string describe) {", + "},", + "\"广播事件 事件名字 事件描述\");", + "", + "CLI_START(rootMenu);", + "ThisThread().sleep();", + "}", + "", + "ENABLE_TEST2($1, \"$1\")" + ], + "description": "create_runner" + }, + "create_gtest": { + "prefix": "create_gtest", + "body": [ + "#include \"gtest/gtest.h\"", + "#include ", + "", + "#include \"project_mock.hpp\"", + "", + "using namespace std;", + "using namespace zwsd;", + "using namespace core;", + "", + "using namespace testing;", + "", + "class ${1} : public testing::Test {", + " public:", + " void SetUp() override {}", + "};", + "", + "TEST_F(${1}, test) {}", + ], + "description": "create_gtest" + } +} \ No newline at end of file