use std::regex_token_iterator instead of boost tokenized
This commit is contained in:
parent
ac6f07a744
commit
7a1a209168
@ -12,11 +12,11 @@
|
|||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
#include <boost/range/adaptor/tokenized.hpp>
|
|
||||||
#include <boost/range/adaptor/transformed.hpp>
|
#include <boost/range/adaptor/transformed.hpp>
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <iterator>
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
using namespace osrm;
|
using namespace osrm;
|
||||||
|
|
||||||
@ -34,9 +34,8 @@ struct MaxCellSizesArgument
|
|||||||
|
|
||||||
std::ostream &operator<<(std::ostream &os, const MaxCellSizesArgument &arg)
|
std::ostream &operator<<(std::ostream &os, const MaxCellSizesArgument &arg)
|
||||||
{
|
{
|
||||||
return os << boost::algorithm::join(
|
auto to_string = [](std::size_t x) { return std::to_string(x); };
|
||||||
arg.value | boost::adaptors::transformed([](auto x) { return std::to_string(x); }),
|
return os << boost::algorithm::join(arg.value | boost::adaptors::transformed(to_string), ",");
|
||||||
",");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void validate(boost::any &v, const std::vector<std::string> &values, MaxCellSizesArgument *, int)
|
void validate(boost::any &v, const std::vector<std::string> &values, MaxCellSizesArgument *, int)
|
||||||
@ -50,18 +49,21 @@ void validate(boost::any &v, const std::vector<std::string> &values, MaxCellSize
|
|||||||
// one string, it's an error, and exception will be thrown.
|
// one string, it's an error, and exception will be thrown.
|
||||||
const std::string &s = validators::get_single_string(values);
|
const std::string &s = validators::get_single_string(values);
|
||||||
|
|
||||||
|
std::regex re(",");
|
||||||
std::vector<size_t> output;
|
std::vector<size_t> output;
|
||||||
boost::copy(s | tokenized(boost::regex("[^,]+")) | transformed([](const auto &x) {
|
std::transform(std::sregex_token_iterator(s.begin(), s.end(), re, -1),
|
||||||
try
|
std::sregex_token_iterator(),
|
||||||
{
|
std::back_inserter(output),
|
||||||
return boost::lexical_cast<std::size_t>(x);
|
[](const auto &x) {
|
||||||
}
|
try
|
||||||
catch (const boost::bad_lexical_cast &)
|
{
|
||||||
{
|
return boost::lexical_cast<std::size_t>(x);
|
||||||
throw validation_error(validation_error::invalid_option_value);
|
}
|
||||||
}
|
catch (const boost::bad_lexical_cast &)
|
||||||
}),
|
{
|
||||||
std::back_inserter(output));
|
throw validation_error(validation_error::invalid_option_value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
v = boost::any(MaxCellSizesArgument{output});
|
v = boost::any(MaxCellSizesArgument{output});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user