mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2024-11-29 01:33:46 +00:00
Put the generic split() in its own file.
This commit is contained in:
parent
527f8cedea
commit
93fe091303
4 changed files with 43 additions and 17 deletions
29
include/dindexer-core/split.hpp
Normal file
29
include/dindexer-core/split.hpp
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/* Copyright 2015, 2016, Michele Santullo
|
||||||
|
* This file is part of "dindexer".
|
||||||
|
*
|
||||||
|
* "dindexer" is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* "dindexer" is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef id913CE9D2F60745349F39F2C82455973E
|
||||||
|
#define id913CE9D2F60745349F39F2C82455973E
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <boost/utility/string_ref.hpp>
|
||||||
|
#include "duckhandy/compatibility.h"
|
||||||
|
|
||||||
|
namespace dincore {
|
||||||
|
std::vector<boost::string_ref> split ( boost::string_ref parList, char parSeparator, bool parTrim, bool parDeleteEmpty ) a_pure;
|
||||||
|
} //namespace dincore
|
||||||
|
|
||||||
|
#endif
|
|
@ -15,17 +15,22 @@
|
||||||
* along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
|
* along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef id913CE9D2F60745349F39F2C82455973E
|
#ifndef idABF7D6D669F445B2852C4DDFC29C701E
|
||||||
#define id913CE9D2F60745349F39F2C82455973E
|
#define idABF7D6D669F445B2852C4DDFC29C701E
|
||||||
|
|
||||||
#include <vector>
|
#include "dindexer-core/split.hpp"
|
||||||
#include <boost/utility/string_ref.hpp>
|
|
||||||
#include "duckhandy/compatibility.h"
|
|
||||||
|
|
||||||
namespace dincore {
|
namespace dincore {
|
||||||
std::vector<boost::string_ref> split_and_trim ( boost::string_ref parList, char parSeparator ) a_pure;
|
|
||||||
std::vector<boost::string_ref> split_tags ( boost::string_ref parCommaSeparatedList ) a_pure;
|
std::vector<boost::string_ref> split_tags ( boost::string_ref parCommaSeparatedList ) a_pure;
|
||||||
std::vector<boost::string_ref> split ( boost::string_ref parList, char parSeparator, bool parTrim, bool parDeleteEmpty ) a_pure;
|
std::vector<boost::string_ref> split_and_trim ( boost::string_ref parCommaSeparatedList, char parSeparator ) a_pure;
|
||||||
|
|
||||||
|
inline std::vector<boost::string_ref> split_tags (boost::string_ref parCommaSeparatedList) {
|
||||||
|
return split(parCommaSeparatedList, ',', true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::vector<boost::string_ref> split_and_trim (boost::string_ref parCommaSeparatedList, char parSeparator) {
|
||||||
|
return split(parCommaSeparatedList, parSeparator, true, true);
|
||||||
|
}
|
||||||
} //namespace dincore
|
} //namespace dincore
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2,7 +2,7 @@ project(${bare_name}-core CXX)
|
||||||
|
|
||||||
add_library(${PROJECT_NAME} SHARED
|
add_library(${PROJECT_NAME} SHARED
|
||||||
searchpaths.cpp
|
searchpaths.cpp
|
||||||
split_tags.cpp
|
split.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME}
|
target_link_libraries(${PROJECT_NAME}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
* along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
|
* along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "dindexer-core/split_tags.hpp"
|
#include "dindexer-core/split.hpp"
|
||||||
#include <boost/algorithm/string/finder.hpp>
|
#include <boost/algorithm/string/finder.hpp>
|
||||||
#include <boost/algorithm/string/split.hpp>
|
#include <boost/algorithm/string/split.hpp>
|
||||||
#include <boost/algorithm/string/trim.hpp>
|
#include <boost/algorithm/string/trim.hpp>
|
||||||
|
@ -25,14 +25,6 @@
|
||||||
#include <ciso646>
|
#include <ciso646>
|
||||||
|
|
||||||
namespace dincore {
|
namespace dincore {
|
||||||
std::vector<boost::string_ref> split_tags (boost::string_ref parCommaSeparatedList) {
|
|
||||||
return split(parCommaSeparatedList, ',', true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<boost::string_ref> split_and_trim (boost::string_ref parList, char parSeparator) {
|
|
||||||
return split(parList, parSeparator, true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<boost::string_ref> split (boost::string_ref parList, char parSeparator, bool parTrim, bool parDeleteEmpty) {
|
std::vector<boost::string_ref> split (boost::string_ref parList, char parSeparator, bool parTrim, bool parDeleteEmpty) {
|
||||||
using OutRange = boost::iterator_range<std::string::const_iterator>;
|
using OutRange = boost::iterator_range<std::string::const_iterator>;
|
||||||
using boost::token_finder;
|
using boost::token_finder;
|
Loading…
Reference in a new issue