From f12d498e405b5ba452f30aee36ee6484eeec541c Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Sun, 10 Jul 2016 17:12:19 +0100 Subject: [PATCH] Move split_tags to core. --- include/{dindexer-common => dindexer-core}/split_tags.hpp | 4 ++-- src/common/CMakeLists.txt | 1 - src/common/settings.cpp | 4 +++- src/core/CMakeLists.txt | 1 + src/{common => core}/split_tags.cpp | 6 +++--- src/locate/main.cpp | 4 ++-- src/tag/main.cpp | 8 ++++---- test/unit_cli/test_tag_splitting.cpp | 4 ++-- 8 files changed, 17 insertions(+), 15 deletions(-) rename include/{dindexer-common => dindexer-core}/split_tags.hpp (96%) rename src/{common => core}/split_tags.cpp (96%) diff --git a/include/dindexer-common/split_tags.hpp b/include/dindexer-core/split_tags.hpp similarity index 96% rename from include/dindexer-common/split_tags.hpp rename to include/dindexer-core/split_tags.hpp index 3005751..6af5d6b 100644 --- a/include/dindexer-common/split_tags.hpp +++ b/include/dindexer-core/split_tags.hpp @@ -23,9 +23,9 @@ #include #include "helpers/compatibility.h" -namespace dinlib { +namespace dincore { std::vector split_and_trim ( const std::string& parList, char parSeparator ) a_pure; std::vector split_tags ( const std::string& parCommaSeparatedList ) a_pure; -} //namespace dinlib +} //namespace dincore #endif diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 2242e42..aaa2809 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -8,7 +8,6 @@ add_library(${PROJECT_NAME} validationerror.cpp common_info.cpp readline_wrapper.cpp - split_tags.cpp ) target_include_directories(${PROJECT_NAME} diff --git a/src/common/settings.cpp b/src/common/settings.cpp index e3a66f1..bdb66d2 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -16,7 +16,7 @@ */ #include "dindexer-common/settings.hpp" -#include "dindexer-common/split_tags.hpp" +#include "dindexer-core/split_tags.hpp" #include "dindexer-core/searchpaths.hpp" #include "dindexerConfig.h" #include @@ -35,6 +35,8 @@ namespace dinlib { } //unnamed namespace void load_settings (const std::string& parPath, dinlib::Settings& parOut, bool parExpand) { + using dincore::split_and_trim; + const std::string path = (parExpand ? expand(parPath.c_str()) : parPath); std::string search_paths; diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 5ae3892..db7fa9b 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -2,6 +2,7 @@ project(${bare_name}-core CXX) add_library(${PROJECT_NAME} SHARED searchpaths.cpp + split_tags.cpp ) target_link_libraries(${PROJECT_NAME} diff --git a/src/common/split_tags.cpp b/src/core/split_tags.cpp similarity index 96% rename from src/common/split_tags.cpp rename to src/core/split_tags.cpp index 931a8d5..cdc5ef9 100644 --- a/src/common/split_tags.cpp +++ b/src/core/split_tags.cpp @@ -15,7 +15,7 @@ * along with "dindexer". If not, see . */ -#include "dindexer-common/split_tags.hpp" +#include "dindexer-core/split_tags.hpp" #include #include #include @@ -24,7 +24,7 @@ #include #include -namespace dinlib { +namespace dincore { std::vector split_tags (const std::string& parCommaSeparatedList) { return split_and_trim(parCommaSeparatedList, ','); } @@ -52,4 +52,4 @@ namespace dinlib { filtered([](const string_ref& r){return not r.empty();}) ); } -} //namespace dinlib +} //namespace dincore diff --git a/src/locate/main.cpp b/src/locate/main.cpp index 860a7a5..6e8fa91 100644 --- a/src/locate/main.cpp +++ b/src/locate/main.cpp @@ -17,7 +17,7 @@ #include "commandline.hpp" #include "dindexer-common/settings.hpp" -#include "dindexer-common/split_tags.hpp" +#include "dindexer-core/split_tags.hpp" #include "dindexerConfig.h" #include "hash.hpp" #include "glob2regex/glob2regex.hpp" @@ -47,7 +47,7 @@ namespace { if (not parVM.count("tags")) return std::vector(); else - return dinlib::split_tags(parVM["tags"].as()); + return dincore::split_tags(parVM["tags"].as()); } } //unnamed namespace diff --git a/src/tag/main.cpp b/src/tag/main.cpp index 454bc43..f934d9a 100644 --- a/src/tag/main.cpp +++ b/src/tag/main.cpp @@ -18,7 +18,7 @@ #include "commandline.hpp" #include "dindexer-common/settings.hpp" #include "dindexerConfig.h" -#include "dindexer-common/split_tags.hpp" +#include "dindexer-core/split_tags.hpp" #include "glob2regex/glob2regex.hpp" #include "enum.h" #include @@ -62,7 +62,7 @@ namespace { switch (parMode) { case TaggingMode::ID: { - auto ids_string = dinlib::split_tags(parVM["ids"].as()); + auto ids_string = dincore::split_tags(parVM["ids"].as()); std::vector ids; ids.reserve(ids_string.size()); std::transform(ids_string.begin(), ids_string.end(), std::back_inserter(ids), &lexical_cast); @@ -92,7 +92,7 @@ namespace { switch (parMode) { case TaggingMode::ID: { - auto ids_string = dinlib::split_tags(parVM["ids"].as()); + auto ids_string = dincore::split_tags(parVM["ids"].as()); std::vector ids; ids.reserve(ids_string.size()); std::transform(ids_string.begin(), ids_string.end(), std::back_inserter(ids), &lexical_cast); @@ -157,7 +157,7 @@ int main (int parArgc, char* parArgv[]) { } const auto master_tags_string = vm["tags"].as(); - const std::vector tags = dinlib::split_tags(master_tags_string); + const std::vector tags = dincore::split_tags(master_tags_string); const auto mode = (glob_mode ? TaggingMode::Glob : TaggingMode::ID); if (not vm.count("delete")) diff --git a/test/unit_cli/test_tag_splitting.cpp b/test/unit_cli/test_tag_splitting.cpp index 08066f6..0b8ef5b 100644 --- a/test/unit_cli/test_tag_splitting.cpp +++ b/test/unit_cli/test_tag_splitting.cpp @@ -18,10 +18,10 @@ #include #include #include -#include "dindexer-common/split_tags.hpp" +#include "dindexer-core/split_tags.hpp" TEST(cli_main, split_tags) { - using dinlib::split_tags; + using dincore::split_tags; { const std::string test_tags = "tag1,tag2";