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

Function main

example/4_async_file_processing_version_2/source/main.cpp:62–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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