diff --git a/Bar/CMakeLists.txt b/Bar/CMakeLists.txt index 791f61e..546eed0 100644 --- a/Bar/CMakeLists.txt +++ b/Bar/CMakeLists.txt @@ -13,7 +13,7 @@ set_target_properties(Bar PROPERTIES VERSION ${PROJECT_VERSION} POSITION_INDEPENDENT_CODE ON PUBLIC_HEADER include/bar/Bar.hpp) -#target_link_libraries(Bar PUBLIC ...) +target_link_libraries(Bar PRIVATE absl::log) add_library(${PROJECT_NAMESPACE}::Bar ALIAS Bar) add_subdirectory(tests) diff --git a/Bar/src/Bar.cpp b/Bar/src/Bar.cpp index 3776b6c..0d2d81d 100644 --- a/Bar/src/Bar.cpp +++ b/Bar/src/Bar.cpp @@ -4,167 +4,169 @@ #include #include +#include "absl/log/log.h" + namespace bar { std::vector stringVectorOutput(int level) { - std::cout << "[" << level << "] Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "[" << level << "] Enter " << __func__ << "()" << std::endl; std::vector result(level, std::to_string(level)); - std::cout << "[" << level << "] Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "[" << level << "] Exit " << __func__ << "()" << std::endl; return result; } int stringVectorInput(std::vector data) { - std::cout << "Enter " << __func__ << "()" << std::endl; - std::cout << "{"; + LOG(INFO) << "Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "{"; for (const auto& item : data) { - std::cout << item << ", "; + LOG(INFO) << item << ", "; } - std::cout << "}" << std::endl; - std::cout << "Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "}" << std::endl; + LOG(INFO) << "Exit " << __func__ << "()" << std::endl; return data.size(); } int stringVectorRefInput(const std::vector& data) { - std::cout << "Enter " << __func__ << "()" << std::endl; - std::cout << "{"; + LOG(INFO) << "Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "{"; for (const auto& item : data) { - std::cout << item << ", "; + LOG(INFO) << item << ", "; } - std::cout << "}" << std::endl; - std::cout << "Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "}" << std::endl; + LOG(INFO) << "Exit " << __func__ << "()" << std::endl; return data.size(); } std::vector> stringJaggedArrayOutput(int level) { - std::cout << "[" << level << "] Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "[" << level << "] Enter " << __func__ << "()" << std::endl; std::vector> result; result.reserve(level); for (int i = 1; i <= level; ++i) { result.emplace_back(std::vector(i, std::to_string(i))); } - std::cout << "[" << level << "] Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "[" << level << "] Exit " << __func__ << "()" << std::endl; return result; } int stringJaggedArrayInput(std::vector> data) { - std::cout << "Enter " << __func__ << "()" << std::endl; - std::cout << "{"; + LOG(INFO) << "Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "{"; for (const auto& inner : data) { - std::cout << "{"; + LOG(INFO) << "{"; for (const auto& item : inner) { - std::cout << item << ", "; + LOG(INFO) << item << ", "; } - std::cout << "}, "; + LOG(INFO) << "}, "; } - std::cout << "}" << std::endl; - std::cout << "Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "}" << std::endl; + LOG(INFO) << "Exit " << __func__ << "()" << std::endl; return data.size(); } int stringJaggedArrayRefInput(const std::vector>& data) { - std::cout << "Enter " << __func__ << "()" << std::endl; - std::cout << "{"; + LOG(INFO) << "Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "{"; for (const auto& inner : data) { - std::cout << "{"; + LOG(INFO) << "{"; for (const auto& item : inner) { - std::cout << item << ", "; + LOG(INFO) << item << ", "; } - std::cout << "}, "; + LOG(INFO) << "}, "; } - std::cout << "}" << std::endl; - std::cout << "Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "}" << std::endl; + LOG(INFO) << "Exit " << __func__ << "()" << std::endl; return data.size(); } std::vector> pairVectorOutput(int level) { - std::cout << "[" << level << "] Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "[" << level << "] Enter " << __func__ << "()" << std::endl; std::vector> result(level, std::make_pair(level, level)); - std::cout << "[" << level << "] Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "[" << level << "] Exit " << __func__ << "()" << std::endl; return result; } int pairVectorInput(std::vector> data) { - std::cout << "Enter " << __func__ << "()" << std::endl; - std::cout << "{"; + LOG(INFO) << "Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "{"; for (const auto& item : data) { - std::cout << "[" << item.first << "," << item.second << "], "; + LOG(INFO) << "[" << item.first << "," << item.second << "], "; } - std::cout << "}" << std::endl; - std::cout << "Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "}" << std::endl; + LOG(INFO) << "Exit " << __func__ << "()" << std::endl; return data.size(); } int pairVectorRefInput(const std::vector>& data) { - std::cout << "Enter " << __func__ << "()" << std::endl; - std::cout << "{"; + LOG(INFO) << "Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "{"; for (const auto& item : data) { - std::cout << "[" << item.first << "," << item.second << "], "; + LOG(INFO) << "[" << item.first << "," << item.second << "], "; } - std::cout << "}" << std::endl; - std::cout << "Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "}" << std::endl; + LOG(INFO) << "Exit " << __func__ << "()" << std::endl; return data.size(); } std::vector>> pairJaggedArrayOutput(int level) { - std::cout << "[" << level << "] Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "[" << level << "] Enter " << __func__ << "()" << std::endl; std::vector>> result; result.reserve(level); for (int i = 1; i <= level; ++i) { result.emplace_back(std::vector>(i, std::make_pair(i, i))); } - std::cout << "[" << level << "] Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "[" << level << "] Exit " << __func__ << "()" << std::endl; return result; } int pairJaggedArrayInput(std::vector>> data) { - std::cout << "Enter " << __func__ << "()" << std::endl; - std::cout << "{"; + LOG(INFO) << "Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "{"; for (const auto& inner : data) { - std::cout << "{"; + LOG(INFO) << "{"; for (const auto& item : inner) { - std::cout << "[" << item.first << "," << item.second << "], "; + LOG(INFO) << "[" << item.first << "," << item.second << "], "; } - std::cout << "}, "; + LOG(INFO) << "}, "; } - std::cout << "}" << std::endl; - std::cout << "Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "}" << std::endl; + LOG(INFO) << "Exit " << __func__ << "()" << std::endl; return data.size(); } int pairJaggedArrayRefInput(const std::vector>>& data) { - std::cout << "Enter " << __func__ << "()" << std::endl; - std::cout << "{"; + LOG(INFO) << "Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "{"; for (const auto& inner : data) { - std::cout << "{"; + LOG(INFO) << "{"; for (const auto& item : inner) { - std::cout << "[" << item.first << "," << item.second << "], "; + LOG(INFO) << "[" << item.first << "," << item.second << "], "; } - std::cout << "}, "; + LOG(INFO) << "}, "; } - std::cout << "}" << std::endl; - std::cout << "Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "}" << std::endl; + LOG(INFO) << "Exit " << __func__ << "()" << std::endl; return data.size(); } void freeFunction(int level) { - std::cout << "[" << level << "] Enter " << __func__ << "(int)" << std::endl; - std::cout << "[" << level << "] Exit " << __func__ << "(int)" << std::endl; + LOG(INFO) << "[" << level << "] Enter " << __func__ << "(int)" << std::endl; + LOG(INFO) << "[" << level << "] Exit " << __func__ << "(int)" << std::endl; } void freeFunction(int64_t level) { - std::cout << "[" << level << "] Enter " << __func__ << "(int64_t)" << std::endl; - std::cout << "[" << level << "] Exit " << __func__ << "(int64_t)" << std::endl; + LOG(INFO) << "[" << level << "] Enter " << __func__ << "(int64_t)" << std::endl; + LOG(INFO) << "[" << level << "] Exit " << __func__ << "(int64_t)" << std::endl; } void Bar::staticFunction(int level) { - std::cout << "[" << level << "] Enter " << __func__ << "(int)" << std::endl; + LOG(INFO) << "[" << level << "] Enter " << __func__ << "(int)" << std::endl; freeFunction(level + 1); - std::cout << "[" << level << "] Exit " << __func__ << "(int)" << std::endl; + LOG(INFO) << "[" << level << "] Exit " << __func__ << "(int)" << std::endl; } void Bar::staticFunction(int64_t level) { - std::cout << "[" << level << "] Enter " << __func__ << "(int64_t)" << std::endl; + LOG(INFO) << "[" << level << "] Enter " << __func__ << "(int64_t)" << std::endl; freeFunction(level + 1); - std::cout << "[" << level << "] Exit " << __func__ << "(int64_t)" << std::endl; + LOG(INFO) << "[" << level << "] Exit " << __func__ << "(int64_t)" << std::endl; } int Bar::getInt() const { diff --git a/Foo/CMakeLists.txt b/Foo/CMakeLists.txt index 87defe3..8d6a367 100644 --- a/Foo/CMakeLists.txt +++ b/Foo/CMakeLists.txt @@ -12,7 +12,7 @@ set_target_properties(Foo PROPERTIES VERSION ${PROJECT_VERSION} POSITION_INDEPENDENT_CODE ON PUBLIC_HEADER include/foo/Foo.hpp) -#target_link_libraries(Foo PUBLIC ...) +target_link_libraries(Foo PRIVATE absl::log) add_library(${PROJECT_NAMESPACE}::Foo ALIAS Foo) add_subdirectory(tests) diff --git a/Foo/src/Foo.cpp b/Foo/src/Foo.cpp index 63fff10..e09393b 100644 --- a/Foo/src/Foo.cpp +++ b/Foo/src/Foo.cpp @@ -4,167 +4,169 @@ #include #include +#include + namespace foo { std::vector stringVectorOutput(int level) { - std::cout << "[" << level << "] Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "[" << level << "] Enter " << __func__ << "()" << std::endl; std::vector result(level, std::to_string(level)); - std::cout << "[" << level << "] Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "[" << level << "] Exit " << __func__ << "()" << std::endl; return result; } int stringVectorInput(std::vector data) { - std::cout << "Enter " << __func__ << "()" << std::endl; - std::cout << "{"; + LOG(INFO) << "Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "{"; for (const auto& item : data) { - std::cout << item << ", "; + LOG(INFO) << item << ", "; } - std::cout << "}" << std::endl; - std::cout << "Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "}" << std::endl; + LOG(INFO) << "Exit " << __func__ << "()" << std::endl; return data.size(); } int stringVectorRefInput(const std::vector& data) { - std::cout << "Enter " << __func__ << "()" << std::endl; - std::cout << "{"; + LOG(INFO) << "Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "{"; for (const auto& item : data) { - std::cout << item << ", "; + LOG(INFO) << item << ", "; } - std::cout << "}" << std::endl; - std::cout << "Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "}" << std::endl; + LOG(INFO) << "Exit " << __func__ << "()" << std::endl; return data.size(); } std::vector> stringJaggedArrayOutput(int level) { - std::cout << "[" << level << "] Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "[" << level << "] Enter " << __func__ << "()" << std::endl; std::vector> result; result.reserve(level); for (int i = 1; i <= level; ++i) { result.emplace_back(std::vector(i, std::to_string(i))); } - std::cout << "[" << level << "] Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "[" << level << "] Exit " << __func__ << "()" << std::endl; return result; } int stringJaggedArrayInput(std::vector> data) { - std::cout << "Enter " << __func__ << "()" << std::endl; - std::cout << "{"; + LOG(INFO) << "Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "{"; for (const auto& inner : data) { - std::cout << "{"; + LOG(INFO) << "{"; for (const auto& item : inner) { - std::cout << item << ", "; + LOG(INFO) << item << ", "; } - std::cout << "}, "; + LOG(INFO) << "}, "; } - std::cout << "}" << std::endl; - std::cout << "Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "}" << std::endl; + LOG(INFO) << "Exit " << __func__ << "()" << std::endl; return data.size(); } int stringJaggedArrayRefInput(const std::vector>& data) { - std::cout << "Enter " << __func__ << "()" << std::endl; - std::cout << "{"; + LOG(INFO) << "Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "{"; for (const auto& inner : data) { - std::cout << "{"; + LOG(INFO) << "{"; for (const auto& item : inner) { - std::cout << item << ", "; + LOG(INFO) << item << ", "; } - std::cout << "}, "; + LOG(INFO) << "}, "; } - std::cout << "}" << std::endl; - std::cout << "Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "}" << std::endl; + LOG(INFO) << "Exit " << __func__ << "()" << std::endl; return data.size(); } std::vector> pairVectorOutput(int level) { - std::cout << "[" << level << "] Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "[" << level << "] Enter " << __func__ << "()" << std::endl; std::vector> result(level, std::make_pair(level, level)); - std::cout << "[" << level << "] Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "[" << level << "] Exit " << __func__ << "()" << std::endl; return result; } int pairVectorInput(std::vector> data) { - std::cout << "Enter " << __func__ << "()" << std::endl; - std::cout << "{"; + LOG(INFO) << "Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "{"; for (const auto& item : data) { - std::cout << "[" << item.first << "," << item.second << "], "; + LOG(INFO) << "[" << item.first << "," << item.second << "], "; } - std::cout << "}" << std::endl; - std::cout << "Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "}" << std::endl; + LOG(INFO) << "Exit " << __func__ << "()" << std::endl; return data.size(); } int pairVectorRefInput(const std::vector>& data) { - std::cout << "Enter " << __func__ << "()" << std::endl; - std::cout << "{"; + LOG(INFO) << "Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "{"; for (const auto& item : data) { - std::cout << "[" << item.first << "," << item.second << "], "; + LOG(INFO) << "[" << item.first << "," << item.second << "], "; } - std::cout << "}" << std::endl; - std::cout << "Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "}" << std::endl; + LOG(INFO) << "Exit " << __func__ << "()" << std::endl; return data.size(); } std::vector>> pairJaggedArrayOutput(int level) { - std::cout << "[" << level << "] Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "[" << level << "] Enter " << __func__ << "()" << std::endl; std::vector>> result; result.reserve(level); for (int i = 1; i <= level; ++i) { result.emplace_back(std::vector>(i, std::make_pair(i, i))); } - std::cout << "[" << level << "] Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "[" << level << "] Exit " << __func__ << "()" << std::endl; return result; } int pairJaggedArrayInput(std::vector>> data) { - std::cout << "Enter " << __func__ << "()" << std::endl; - std::cout << "{"; + LOG(INFO) << "Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "{"; for (const auto& inner : data) { - std::cout << "{"; + LOG(INFO) << "{"; for (const auto& item : inner) { - std::cout << "[" << item.first << "," << item.second << "], "; + LOG(INFO) << "[" << item.first << "," << item.second << "], "; } - std::cout << "}, "; + LOG(INFO) << "}, "; } - std::cout << "}" << std::endl; - std::cout << "Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "}" << std::endl; + LOG(INFO) << "Exit " << __func__ << "()" << std::endl; return data.size(); } int pairJaggedArrayRefInput(const std::vector>>& data) { - std::cout << "Enter " << __func__ << "()" << std::endl; - std::cout << "{"; + LOG(INFO) << "Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "{"; for (const auto& inner : data) { - std::cout << "{"; + LOG(INFO) << "{"; for (const auto& item : inner) { - std::cout << "[" << item.first << "," << item.second << "], "; + LOG(INFO) << "[" << item.first << "," << item.second << "], "; } - std::cout << "}, "; + LOG(INFO) << "}, "; } - std::cout << "}" << std::endl; - std::cout << "Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "}" << std::endl; + LOG(INFO) << "Exit " << __func__ << "()" << std::endl; return data.size(); } void freeFunction(int level) { - std::cout << "[" << level << "] Enter " << __func__ << "(int)" << std::endl; - std::cout << "[" << level << "] Exit " << __func__ << "(int)" << std::endl; + LOG(INFO) << "[" << level << "] Enter " << __func__ << "(int)" << std::endl; + LOG(INFO) << "[" << level << "] Exit " << __func__ << "(int)" << std::endl; } void freeFunction(int64_t level) { - std::cout << "[" << level << "] Enter " << __func__ << "(int64_t)" << std::endl; - std::cout << "[" << level << "] Exit " << __func__ << "(int64_t)" << std::endl; + LOG(INFO) << "[" << level << "] Enter " << __func__ << "(int64_t)" << std::endl; + LOG(INFO) << "[" << level << "] Exit " << __func__ << "(int64_t)" << std::endl; } void Foo::staticFunction(int level) { - std::cout << "[" << level << "] Enter " << __func__ << "(int)" << std::endl; + LOG(INFO) << "[" << level << "] Enter " << __func__ << "(int)" << std::endl; freeFunction(level + 1); - std::cout << "[" << level << "] Exit " << __func__ << "(int)" << std::endl; + LOG(INFO) << "[" << level << "] Exit " << __func__ << "(int)" << std::endl; } void Foo::staticFunction(int64_t level) { - std::cout << "[" << level << "] Enter " << __func__ << "(int64_t)" << std::endl; + LOG(INFO) << "[" << level << "] Enter " << __func__ << "(int64_t)" << std::endl; freeFunction(level + 1); - std::cout << "[" << level << "] Exit " << __func__ << "(int64_t)" << std::endl; + LOG(INFO) << "[" << level << "] Exit " << __func__ << "(int64_t)" << std::endl; } int Foo::getInt() const { diff --git a/FooBar/CMakeLists.txt b/FooBar/CMakeLists.txt index 3b09402..20e0443 100644 --- a/FooBar/CMakeLists.txt +++ b/FooBar/CMakeLists.txt @@ -1,5 +1,4 @@ add_library(FooBar OBJECT) - target_sources(FooBar PRIVATE include/foobar/FooBar.hpp @@ -7,8 +6,6 @@ target_sources(FooBar target_include_directories(FooBar PUBLIC $ - $ - $ $) target_compile_features(FooBar PUBLIC cxx_std_20) set_target_properties(FooBar PROPERTIES @@ -16,13 +13,13 @@ set_target_properties(FooBar PROPERTIES PUBLIC_HEADER include/foobar/FooBar.hpp) # note: macOS is APPLE and also UNIX ! if(APPLE) - set_target_properties(FooBar PROPERTIES - INSTALL_RPATH "@loader_path") + set_target_properties(FooBar PROPERTIES INSTALL_RPATH "@loader_path") elseif(UNIX) set_target_properties(FooBar PROPERTIES POSITION_INDEPENDENT_CODE ON INSTALL_RPATH "$ORIGIN") endif() +target_link_libraries(FooBar PRIVATE absl::log Bar Foo) add_library(${PROJECT_NAMESPACE}::FooBar ALIAS FooBar) add_subdirectory(tests) diff --git a/FooBar/src/FooBar.cpp b/FooBar/src/FooBar.cpp index 48028c8..b258aec 100644 --- a/FooBar/src/FooBar.cpp +++ b/FooBar/src/FooBar.cpp @@ -5,6 +5,7 @@ #include #include +#include #include "bar/Bar.hpp" #include "foo/Foo.hpp" @@ -12,177 +13,177 @@ namespace foobar { using std::make_unique; std::vector stringVectorOutput(int level) { - std::cout << "[" << level << "] Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "[" << level << "] Enter " << __func__ << "()" << std::endl; std::vector result; auto foo_vec = foo::stringVectorOutput(level + 1); auto bar_vec = bar::stringVectorOutput(level + 1); result.insert(result.end(), foo_vec.begin(), foo_vec.end()); result.insert(result.end(), bar_vec.begin(), bar_vec.end()); - std::cout << "[" << level << "] Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "[" << level << "] Exit " << __func__ << "()" << std::endl; return result; } int stringVectorInput(std::vector data) { - std::cout << "Enter " << __func__ << "()" << std::endl; - std::cout << "{"; + LOG(INFO) << "Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "{"; for (const auto& item : data) { - std::cout << item << ", "; + LOG(INFO) << item << ", "; } - std::cout << "}" << std::endl; - std::cout << "Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "}" << std::endl; + LOG(INFO) << "Exit " << __func__ << "()" << std::endl; return data.size(); } int stringVectorRefInput(const std::vector& data) { - std::cout << "Enter " << __func__ << "()" << std::endl; - std::cout << "{"; + LOG(INFO) << "Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "{"; for (const auto& item : data) { - std::cout << item << ", "; + LOG(INFO) << item << ", "; } - std::cout << "}" << std::endl; - std::cout << "Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "}" << std::endl; + LOG(INFO) << "Exit " << __func__ << "()" << std::endl; return data.size(); } std::vector> stringJaggedArrayOutput(int level) { - std::cout << "[" << level << "] Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "[" << level << "] Enter " << __func__ << "()" << std::endl; std::vector> result; result.reserve(level); for (int i = 1; i <= level; ++i) { result.emplace_back(std::vector(i, std::to_string(i))); } - std::cout << "[" << level << "] Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "[" << level << "] Exit " << __func__ << "()" << std::endl; return result; } int stringJaggedArrayInput(std::vector> data) { - std::cout << "Enter " << __func__ << "()" << std::endl; - std::cout << "{"; + LOG(INFO) << "Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "{"; for (const auto& inner : data) { - std::cout << "{"; + LOG(INFO) << "{"; for (const auto& item : inner) { - std::cout << item << ", "; + LOG(INFO) << item << ", "; } - std::cout << "}, "; + LOG(INFO) << "}, "; } - std::cout << "}" << std::endl; - std::cout << "Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "}" << std::endl; + LOG(INFO) << "Exit " << __func__ << "()" << std::endl; return data.size(); } int stringJaggedArrayRefInput(const std::vector>& data) { - std::cout << "Enter " << __func__ << "()" << std::endl; - std::cout << "{"; + LOG(INFO) << "Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "{"; for (const auto& inner : data) { - std::cout << "{"; + LOG(INFO) << "{"; for (const auto& item : inner) { - std::cout << item << ", "; + LOG(INFO) << item << ", "; } - std::cout << "}, "; + LOG(INFO) << "}, "; } - std::cout << "}" << std::endl; - std::cout << "Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "}" << std::endl; + LOG(INFO) << "Exit " << __func__ << "()" << std::endl; return data.size(); } std::vector> pairVectorOutput(int level) { - std::cout << "[" << level << "] Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "[" << level << "] Enter " << __func__ << "()" << std::endl; std::vector> result; auto foo_vec = foo::pairVectorOutput(level + 1); auto bar_vec = bar::pairVectorOutput(level + 1); result.insert(result.end(), foo_vec.begin(), foo_vec.end()); result.insert(result.end(), bar_vec.begin(), bar_vec.end()); - std::cout << "[" << level << "] Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "[" << level << "] Exit " << __func__ << "()" << std::endl; return result; } int pairVectorInput(std::vector> data) { - std::cout << "Enter " << __func__ << "()" << std::endl; - std::cout << "{"; + LOG(INFO) << "Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "{"; for (const auto& item : data) { - std::cout << "[" << item.first << "," << item.second << "], "; + LOG(INFO) << "[" << item.first << "," << item.second << "], "; } - std::cout << "}" << std::endl; - std::cout << "Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "}" << std::endl; + LOG(INFO) << "Exit " << __func__ << "()" << std::endl; return data.size(); } int pairVectorRefInput(const std::vector>& data) { - std::cout << "Enter " << __func__ << "()" << std::endl; - std::cout << "{"; + LOG(INFO) << "Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "{"; for (const auto& item : data) { - std::cout << "[" << item.first << "," << item.second << "], "; + LOG(INFO) << "[" << item.first << "," << item.second << "], "; } - std::cout << "}" << std::endl; - std::cout << "Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "}" << std::endl; + LOG(INFO) << "Exit " << __func__ << "()" << std::endl; return data.size(); } std::vector>> pairJaggedArrayOutput(int level) { - std::cout << "[" << level << "] Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "[" << level << "] Enter " << __func__ << "()" << std::endl; std::vector>> result; result.reserve(level); for (int i = 1; i <= level; ++i) { result.emplace_back(std::vector>(i, std::make_pair(i, i))); } - std::cout << "[" << level << "] Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "[" << level << "] Exit " << __func__ << "()" << std::endl; return result; } int pairJaggedArrayInput(std::vector>> data) { - std::cout << "Enter " << __func__ << "()" << std::endl; - std::cout << "{"; + LOG(INFO) << "Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "{"; for (const auto& inner : data) { - std::cout << "{"; + LOG(INFO) << "{"; for (const auto& item : inner) { - std::cout << "[" << item.first << "," << item.second << "], "; + LOG(INFO) << "[" << item.first << "," << item.second << "], "; } - std::cout << "}, "; + LOG(INFO) << "}, "; } - std::cout << "}" << std::endl; - std::cout << "Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "}" << std::endl; + LOG(INFO) << "Exit " << __func__ << "()" << std::endl; return data.size(); } int pairJaggedArrayRefInput(const std::vector>>& data) { - std::cout << "Enter " << __func__ << "()" << std::endl; - std::cout << "{"; + LOG(INFO) << "Enter " << __func__ << "()" << std::endl; + LOG(INFO) << "{"; for (const auto& inner : data) { - std::cout << "{"; + LOG(INFO) << "{"; for (const auto& item : inner) { - std::cout << "[" << item.first << "," << item.second << "], "; + LOG(INFO) << "[" << item.first << "," << item.second << "], "; } - std::cout << "}, "; + LOG(INFO) << "}, "; } - std::cout << "}" << std::endl; - std::cout << "Exit " << __func__ << "()" << std::endl; + LOG(INFO) << "}" << std::endl; + LOG(INFO) << "Exit " << __func__ << "()" << std::endl; return data.size(); } void freeFunction(int level) { - std::cout << "[" << level << "] Enter " << __func__ << "(int)" << std::endl; + LOG(INFO) << "[" << level << "] Enter " << __func__ << "(int)" << std::endl; foo::freeFunction(level + 1); bar::freeFunction(level + 1); - std::cout << "[" << level << "] Exit " << __func__ << "(int)" << std::endl; + LOG(INFO) << "[" << level << "] Exit " << __func__ << "(int)" << std::endl; } void freeFunction(int64_t level) { - std::cout << "[" << level << "] Enter " << __func__ << "(int64_t)" << std::endl; + LOG(INFO) << "[" << level << "] Enter " << __func__ << "(int64_t)" << std::endl; foo::freeFunction(level + 1); bar::freeFunction(level + 1); - std::cout << "[" << level << "] Exit " << __func__ << "(int64_t)" << std::endl; + LOG(INFO) << "[" << level << "] Exit " << __func__ << "(int64_t)" << std::endl; } void FooBar::staticFunction(int level) { - std::cout << "[" << level << "] Enter " << __func__ << "(int)" << std::endl; + LOG(INFO) << "[" << level << "] Enter " << __func__ << "(int)" << std::endl; freeFunction(level + 1); - std::cout << "[" << level << "] Exit " << __func__ << "(int)" << std::endl; + LOG(INFO) << "[" << level << "] Exit " << __func__ << "(int)" << std::endl; } void FooBar::staticFunction(int64_t level) { - std::cout << "[" << level << "] Enter " << __func__ << "(int64_t)" << std::endl; + LOG(INFO) << "[" << level << "] Enter " << __func__ << "(int64_t)" << std::endl; freeFunction(level + 1); - std::cout << "[" << level << "] Exit " << __func__ << "(int64_t)" << std::endl; + LOG(INFO) << "[" << level << "] Exit " << __func__ << "(int64_t)" << std::endl; } FooBar::FooBar() { diff --git a/FooBarApp/CMakeLists.txt b/FooBarApp/CMakeLists.txt index 5947ca6..f0f0339 100644 --- a/FooBarApp/CMakeLists.txt +++ b/FooBarApp/CMakeLists.txt @@ -1,10 +1,7 @@ add_executable(FooBarApp) -target_sources(FooBarApp - PRIVATE - src/main.cpp) -target_include_directories(FooBarApp - PRIVATE - $ +target_sources(FooBarApp PRIVATE src/main.cpp) +target_include_directories(FooBarApp PRIVATE + $ ) target_compile_features(FooBarApp PRIVATE cxx_std_20) set_target_properties(FooBarApp PROPERTIES @@ -17,7 +14,14 @@ elseif(UNIX AND NOT APPLE) set_target_properties(FooBarApp PROPERTIES INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}") endif() -target_link_libraries(FooBarApp PRIVATE Full) +target_link_libraries(FooBarApp PRIVATE + absl::flags + absl::flags_parse + absl::log + absl::strings + protobuf::libprotobuf + CMakeCpp::Full +) add_executable(${PROJECT_NAMESPACE}::FooBarApp ALIAS FooBarApp) diff --git a/FooBarApp/src/main.cpp b/FooBarApp/src/main.cpp index c20fe64..a650c4f 100644 --- a/FooBarApp/src/main.cpp +++ b/FooBarApp/src/main.cpp @@ -1,34 +1,50 @@ #include -#include +#include #include #include +#include + +#include +#include +#include +#include +#include +#include void* kVar = [] { std::cerr << "kFooBarApp\n"; return nullptr; }(); -int main(int /*argc*/, char** /*argv*/) { +int main(int argc, char* argv[]) { + absl::ParseCommandLine(argc, argv); + + { + const std::vector v = {"foo","bar","baz"}; + std::string s = absl::StrJoin(v, "-"); + std::cout << "Joined string: " << s << "\n"; + } + foobar::freeFunction(int{0}); - std::cout << std::endl; + LOG(INFO) << std::endl; foobar::freeFunction(int64_t{1}); - std::cout << std::endl; + LOG(INFO) << std::endl; foobar::FooBar::staticFunction(int{2}); - std::cout << std::endl; + LOG(INFO) << std::endl; foobar::FooBar::staticFunction(int64_t{3}); - std::cout << std::endl; + LOG(INFO) << std::endl; foobar::FooBar f; f.setBarInt(13); f.setFooInt(17); - std::cout << std::to_string(f.getInt()) << std::endl; + LOG(INFO) << std::to_string(f.getInt()) << std::endl; f.setBarInt64(int64_t{31}); f.setFooInt64(int64_t{42}); - std::cout << std::to_string(f.getInt64()) << std::endl; + LOG(INFO) << std::to_string(f.getInt64()) << std::endl; - std::cout << f() << std::endl; + LOG(INFO) << f() << std::endl; return 0; }