mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2024-11-29 01:33:46 +00:00
Move split_tags to core.
This commit is contained in:
parent
4bd7c3515a
commit
f12d498e40
8 changed files with 17 additions and 15 deletions
|
@ -23,9 +23,9 @@
|
|||
#include <boost/utility/string_ref.hpp>
|
||||
#include "helpers/compatibility.h"
|
||||
|
||||
namespace dinlib {
|
||||
namespace dincore {
|
||||
std::vector<boost::string_ref> split_and_trim ( const std::string& parList, char parSeparator ) a_pure;
|
||||
std::vector<boost::string_ref> split_tags ( const std::string& parCommaSeparatedList ) a_pure;
|
||||
} //namespace dinlib
|
||||
} //namespace dincore
|
||||
|
||||
#endif
|
|
@ -8,7 +8,6 @@ add_library(${PROJECT_NAME}
|
|||
validationerror.cpp
|
||||
common_info.cpp
|
||||
readline_wrapper.cpp
|
||||
split_tags.cpp
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
|
|
|
@ -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 <yaml-cpp/yaml.h>
|
||||
|
@ -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;
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ project(${bare_name}-core CXX)
|
|||
|
||||
add_library(${PROJECT_NAME} SHARED
|
||||
searchpaths.cpp
|
||||
split_tags.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "dindexer-common/split_tags.hpp"
|
||||
#include "dindexer-core/split_tags.hpp"
|
||||
#include <boost/algorithm/string/finder.hpp>
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
|
@ -24,7 +24,7 @@
|
|||
#include <boost/range/adaptor/filtered.hpp>
|
||||
#include <ciso646>
|
||||
|
||||
namespace dinlib {
|
||||
namespace dincore {
|
||||
std::vector<boost::string_ref> 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
|
|
@ -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<boost::string_ref>();
|
||||
else
|
||||
return dinlib::split_tags(parVM["tags"].as<std::string>());
|
||||
return dincore::split_tags(parVM["tags"].as<std::string>());
|
||||
}
|
||||
} //unnamed namespace
|
||||
|
||||
|
|
|
@ -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 <iostream>
|
||||
|
@ -62,7 +62,7 @@ namespace {
|
|||
switch (parMode) {
|
||||
case TaggingMode::ID:
|
||||
{
|
||||
auto ids_string = dinlib::split_tags(parVM["ids"].as<std::string>());
|
||||
auto ids_string = dincore::split_tags(parVM["ids"].as<std::string>());
|
||||
std::vector<uint64_t> ids;
|
||||
ids.reserve(ids_string.size());
|
||||
std::transform(ids_string.begin(), ids_string.end(), std::back_inserter(ids), &lexical_cast<uint64_t, string_ref>);
|
||||
|
@ -92,7 +92,7 @@ namespace {
|
|||
switch (parMode) {
|
||||
case TaggingMode::ID:
|
||||
{
|
||||
auto ids_string = dinlib::split_tags(parVM["ids"].as<std::string>());
|
||||
auto ids_string = dincore::split_tags(parVM["ids"].as<std::string>());
|
||||
std::vector<uint64_t> ids;
|
||||
ids.reserve(ids_string.size());
|
||||
std::transform(ids_string.begin(), ids_string.end(), std::back_inserter(ids), &lexical_cast<uint64_t, string_ref>);
|
||||
|
@ -157,7 +157,7 @@ int main (int parArgc, char* parArgv[]) {
|
|||
}
|
||||
|
||||
const auto master_tags_string = vm["tags"].as<std::string>();
|
||||
const std::vector<boost::string_ref> tags = dinlib::split_tags(master_tags_string);
|
||||
const std::vector<boost::string_ref> tags = dincore::split_tags(master_tags_string);
|
||||
const auto mode = (glob_mode ? TaggingMode::Glob : TaggingMode::ID);
|
||||
|
||||
if (not vm.count("delete"))
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include <sstream>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#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";
|
||||
|
|
Loading…
Reference in a new issue