Hide qi namespace alias
This commit is contained in:
parent
6484fed190
commit
ccb8a07dc7
@ -23,11 +23,6 @@ namespace osrm
|
|||||||
namespace updater
|
namespace updater
|
||||||
{
|
{
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
namespace qi = boost::spirit::qi;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Functor to parse a list of CSV files using "key,value,comment" grammar.
|
// Functor to parse a list of CSV files using "key,value,comment" grammar.
|
||||||
// Key and Value structures must be a model of Random Access Sequence.
|
// Key and Value structures must be a model of Random Access Sequence.
|
||||||
// Also the Value structure must have source member that will be filled
|
// Also the Value structure must have source member that will be filled
|
||||||
@ -35,8 +30,8 @@ namespace qi = boost::spirit::qi;
|
|||||||
template <typename Key, typename Value> struct CSVFilesParser
|
template <typename Key, typename Value> struct CSVFilesParser
|
||||||
{
|
{
|
||||||
using Iterator = boost::iostreams::mapped_file_source::iterator;
|
using Iterator = boost::iostreams::mapped_file_source::iterator;
|
||||||
using KeyRule = qi::rule<Iterator, Key()>;
|
using KeyRule = boost::spirit::qi::rule<Iterator, Key()>;
|
||||||
using ValueRule = qi::rule<Iterator, Value()>;
|
using ValueRule = boost::spirit::qi::rule<Iterator, Value()>;
|
||||||
|
|
||||||
CSVFilesParser(std::size_t start_index, const KeyRule &key_rule, const ValueRule &value_rule)
|
CSVFilesParser(std::size_t start_index, const KeyRule &key_rule, const ValueRule &value_rule)
|
||||||
: start_index(start_index), key_rule(key_rule), value_rule(value_rule)
|
: start_index(start_index), key_rule(key_rule), value_rule(value_rule)
|
||||||
@ -94,6 +89,8 @@ template <typename Key, typename Value> struct CSVFilesParser
|
|||||||
// Parse a single CSV file and return result as a vector<Key, Value>
|
// Parse a single CSV file and return result as a vector<Key, Value>
|
||||||
auto ParseCSVFile(const std::string &filename, std::size_t file_id) const
|
auto ParseCSVFile(const std::string &filename, std::size_t file_id) const
|
||||||
{
|
{
|
||||||
|
namespace qi = boost::spirit::qi;
|
||||||
|
|
||||||
std::vector<std::pair<Key, Value>> result;
|
std::vector<std::pair<Key, Value>> result;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -105,7 +102,7 @@ template <typename Key, typename Value> struct CSVFilesParser
|
|||||||
|
|
||||||
BOOST_ASSERT(file_id <= std::numeric_limits<std::uint8_t>::max());
|
BOOST_ASSERT(file_id <= std::numeric_limits<std::uint8_t>::max());
|
||||||
ValueRule value_source =
|
ValueRule value_source =
|
||||||
value_rule[qi::_val = qi::_1, boost::phoenix::bind(&Value::source, qi::_val) = file_id];
|
value_rule[qi::_val = qi::_1, bind(&Value::source, qi::_val) = file_id];
|
||||||
qi::rule<Iterator, std::pair<Key, Value>()> csv_line =
|
qi::rule<Iterator, std::pair<Key, Value>()> csv_line =
|
||||||
(key_rule >> ',' >> value_source) >> -(',' >> *(qi::char_ - qi::eol));
|
(key_rule >> ',' >> value_source) >> -(',' >> *(qi::char_ - qi::eol));
|
||||||
const auto ok = qi::parse(first, last, -(csv_line % qi::eol) >> *qi::eol, result);
|
const auto ok = qi::parse(first, last, -(csv_line % qi::eol) >> *qi::eol, result);
|
||||||
@ -117,8 +114,8 @@ template <typename Key, typename Value> struct CSVFilesParser
|
|||||||
--begin_of_line;
|
--begin_of_line;
|
||||||
auto line_number = std::count(mmap.begin(), first, '\n') + 1;
|
auto line_number = std::count(mmap.begin(), first, '\n') + 1;
|
||||||
const auto message = boost::format("CSV file %1% malformed on line %2%:\n %3%\n") %
|
const auto message = boost::format("CSV file %1% malformed on line %2%:\n %3%\n") %
|
||||||
filename % std::to_string(line_number) %
|
filename % std::to_string(line_number) %
|
||||||
std::string(begin_of_line + 1, std::find(first, last, '\n'));
|
std::string(begin_of_line + 1, std::find(first, last, '\n'));
|
||||||
throw util::exception(message.str() + SOURCE_REF);
|
throw util::exception(message.str() + SOURCE_REF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,10 +123,10 @@ template <typename Key, typename Value> struct CSVFilesParser
|
|||||||
|
|
||||||
return std::move(result);
|
return std::move(result);
|
||||||
}
|
}
|
||||||
catch (const boost::exception& e)
|
catch (const boost::exception &e)
|
||||||
{
|
{
|
||||||
const auto message = boost::format("exception in loading %1%:\n %2%") %
|
const auto message = boost::format("exception in loading %1%:\n %2%") % filename %
|
||||||
filename % boost::diagnostic_information(e);
|
boost::diagnostic_information(e);
|
||||||
throw util::exception(message.str() + SOURCE_REF);
|
throw util::exception(message.str() + SOURCE_REF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user