MCPcopy Create free account
hub / github.com/David-Haim/concurrencpp / main

Function main

example/3_async_file_processing/source/main.cpp:68–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68int main(int argc, const char* argv[]) {
69 if (argc < 4) {
70 const auto help_msg = "please pass all necessary arguments\n\
71argv[1] - the file to process\n\
72argv[2] - the character to replace\n\
73argv[3] - the character to replace with";
74
75 std::cerr << help_msg << std::endl;
76 return -1;
77 }
78
79 if (std::strlen(argv[2]) != 1 || std::strlen(argv[3]) != 1) {
80 std::cerr << "argv[2] and argv[3] must be one character only" << std::endl;
81 return -1;
82 }
83
84 const auto file_path = std::string(argv[1]);
85 const auto from_char = argv[2][0];
86 const auto to_char = argv[3][0];
87
88 concurrencpp::runtime runtime;
89
90 try {
91 replace_chars_in_file(runtime.background_executor(), runtime.thread_pool_executor(), file_path, from_char, to_char).get();
92 } catch (const std::exception& e) {
93 std::cerr << e.what() << std::endl;
94 }
95
96 return 0;
97}

Callers

nothing calls this directly

Calls 4

background_executorMethod · 0.80
replace_chars_in_fileFunction · 0.70
getMethod · 0.45
thread_pool_executorMethod · 0.45

Tested by

no test coverage detected