From e13d3fdf4d4754c85e7e05e98592afb71d22be3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Mon, 22 Aug 2016 21:29:22 +0200 Subject: Move get_first_non_empty to louloulibs/utils --- CMakeLists.txt | 2 +- louloulibs/utils/get_first_non_empty.cpp | 11 +++++++++++ louloulibs/utils/get_first_non_empty.hpp | 20 ++++++++++++++++++++ src/utils/get_first_non_empty.cpp | 11 ----------- src/utils/get_first_non_empty.hpp | 20 -------------------- 5 files changed, 32 insertions(+), 32 deletions(-) create mode 100644 louloulibs/utils/get_first_non_empty.cpp create mode 100644 louloulibs/utils/get_first_non_empty.hpp delete mode 100644 src/utils/get_first_non_empty.cpp delete mode 100644 src/utils/get_first_non_empty.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ea9ffc3..9db8a30 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,7 +96,7 @@ if(LITESQL_FOUND) add_library(database STATIC src/database/database.cpp ${LITESQL_GENERATED_SOURCES}) - target_link_libraries(database ${LITESQL_LIBRARIES} src_utils) + target_link_libraries(database ${LITESQL_LIBRARIES} utils) if(BOTAN_FOUND) target_link_libraries(database ${BOTAN_LIBRARIES}) endif() diff --git a/louloulibs/utils/get_first_non_empty.cpp b/louloulibs/utils/get_first_non_empty.cpp new file mode 100644 index 0000000..5b3bedb --- /dev/null +++ b/louloulibs/utils/get_first_non_empty.cpp @@ -0,0 +1,11 @@ +#include + +bool is_empty(const std::string& val) +{ + return val.empty(); +} + +bool is_empty(const int& val) +{ + return val == 0; +} diff --git a/louloulibs/utils/get_first_non_empty.hpp b/louloulibs/utils/get_first_non_empty.hpp new file mode 100644 index 0000000..a38f5fb --- /dev/null +++ b/louloulibs/utils/get_first_non_empty.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include + +bool is_empty(const std::string& val); +bool is_empty(const int& val); + +template +T get_first_non_empty(T&& last) +{ + return last; +} + +template +T get_first_non_empty(T&& first, Args&&... args) +{ + if (!is_empty(first)) + return first; + return get_first_non_empty(std::forward(args)...); +} diff --git a/src/utils/get_first_non_empty.cpp b/src/utils/get_first_non_empty.cpp deleted file mode 100644 index 5b3bedb..0000000 --- a/src/utils/get_first_non_empty.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include - -bool is_empty(const std::string& val) -{ - return val.empty(); -} - -bool is_empty(const int& val) -{ - return val == 0; -} diff --git a/src/utils/get_first_non_empty.hpp b/src/utils/get_first_non_empty.hpp deleted file mode 100644 index a38f5fb..0000000 --- a/src/utils/get_first_non_empty.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include - -bool is_empty(const std::string& val); -bool is_empty(const int& val); - -template -T get_first_non_empty(T&& last) -{ - return last; -} - -template -T get_first_non_empty(T&& first, Args&&... args) -{ - if (!is_empty(first)) - return first; - return get_first_non_empty(std::forward(args)...); -} -- cgit v1.2.3