Replace boost::string_ref with std::string_view
This commit is contained in:
parent
60e283312c
commit
0021ccef59
@ -57,8 +57,7 @@ class BaseAPI
|
|||||||
{
|
{
|
||||||
// TODO: check forward/reverse
|
// TODO: check forward/reverse
|
||||||
const auto toName = [this](const auto &phantom) {
|
const auto toName = [this](const auto &phantom) {
|
||||||
return facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id))
|
return std::string(facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id)));
|
||||||
.to_string();
|
|
||||||
};
|
};
|
||||||
const auto noEmpty = [](const auto &name) { return !name.empty(); };
|
const auto noEmpty = [](const auto &name) { return !name.empty(); };
|
||||||
|
|
||||||
@ -128,8 +127,7 @@ class BaseAPI
|
|||||||
static_cast<float>(static_cast<double>(util::toFloating(snapped_location.lat))));
|
static_cast<float>(static_cast<double>(util::toFloating(snapped_location.lat))));
|
||||||
|
|
||||||
const auto toName = [this](const auto &phantom) {
|
const auto toName = [this](const auto &phantom) {
|
||||||
return facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id))
|
return std::string(facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id)));
|
||||||
.to_string();
|
|
||||||
};
|
};
|
||||||
const auto noEmpty = [](const auto &name) { return !name.empty(); };
|
const auto noEmpty = [](const auto &name) { return !name.empty(); };
|
||||||
|
|
||||||
|
@ -145,11 +145,11 @@ inline std::string assembleSummary(const datafacade::BaseDataFacade &facade,
|
|||||||
const auto name_id_to_string = [&](const NameID name_id) {
|
const auto name_id_to_string = [&](const NameID name_id) {
|
||||||
const auto name = facade.GetNameForID(name_id);
|
const auto name = facade.GetNameForID(name_id);
|
||||||
if (!name.empty())
|
if (!name.empty())
|
||||||
return name.to_string();
|
return std::string(name);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const auto ref = facade.GetRefForID(name_id);
|
const auto ref = facade.GetRefForID(name_id);
|
||||||
return ref.to_string();
|
return std::string(ref);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -140,11 +140,11 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
|
|||||||
steps.push_back(RouteStep{path_point.from_edge_based_node,
|
steps.push_back(RouteStep{path_point.from_edge_based_node,
|
||||||
step_name_id,
|
step_name_id,
|
||||||
is_segregated,
|
is_segregated,
|
||||||
name.to_string(),
|
std::string(name),
|
||||||
ref.to_string(),
|
std::string(ref),
|
||||||
pronunciation.to_string(),
|
std::string(pronunciation),
|
||||||
destinations.to_string(),
|
std::string(destinations),
|
||||||
exits.to_string(),
|
std::string(exits),
|
||||||
NO_ROTARY_NAME,
|
NO_ROTARY_NAME,
|
||||||
NO_ROTARY_NAME,
|
NO_ROTARY_NAME,
|
||||||
from_alias<double>(segment_duration) / 10.,
|
from_alias<double>(segment_duration) / 10.,
|
||||||
@ -241,11 +241,11 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
|
|||||||
steps.push_back(RouteStep{leg_data[leg_data.size() - 1].from_edge_based_node,
|
steps.push_back(RouteStep{leg_data[leg_data.size() - 1].from_edge_based_node,
|
||||||
step_name_id,
|
step_name_id,
|
||||||
is_segregated,
|
is_segregated,
|
||||||
facade.GetNameForID(step_name_id).to_string(),
|
std::string(facade.GetNameForID(step_name_id)),
|
||||||
facade.GetRefForID(step_name_id).to_string(),
|
std::string(facade.GetRefForID(step_name_id)),
|
||||||
facade.GetPronunciationForID(step_name_id).to_string(),
|
std::string(facade.GetPronunciationForID(step_name_id)),
|
||||||
facade.GetDestinationsForID(step_name_id).to_string(),
|
std::string(facade.GetDestinationsForID(step_name_id)),
|
||||||
facade.GetExitsForID(step_name_id).to_string(),
|
std::string(facade.GetExitsForID(step_name_id)),
|
||||||
NO_ROTARY_NAME,
|
NO_ROTARY_NAME,
|
||||||
NO_ROTARY_NAME,
|
NO_ROTARY_NAME,
|
||||||
from_alias<double>(duration) / 10.,
|
from_alias<double>(duration) / 10.,
|
||||||
@ -287,11 +287,11 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
|
|||||||
steps.push_back(RouteStep{source_node_id,
|
steps.push_back(RouteStep{source_node_id,
|
||||||
source_name_id,
|
source_name_id,
|
||||||
is_segregated,
|
is_segregated,
|
||||||
facade.GetNameForID(source_name_id).to_string(),
|
std::string(facade.GetNameForID(source_name_id)),
|
||||||
facade.GetRefForID(source_name_id).to_string(),
|
std::string(facade.GetRefForID(source_name_id)),
|
||||||
facade.GetPronunciationForID(source_name_id).to_string(),
|
std::string(facade.GetPronunciationForID(source_name_id)),
|
||||||
facade.GetDestinationsForID(source_name_id).to_string(),
|
std::string(facade.GetDestinationsForID(source_name_id)),
|
||||||
facade.GetExitsForID(source_name_id).to_string(),
|
std::string(facade.GetExitsForID(source_name_id)),
|
||||||
NO_ROTARY_NAME,
|
NO_ROTARY_NAME,
|
||||||
NO_ROTARY_NAME,
|
NO_ROTARY_NAME,
|
||||||
from_alias<double>(duration) / 10.,
|
from_alias<double>(duration) / 10.,
|
||||||
@ -330,11 +330,11 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
|
|||||||
steps.push_back(RouteStep{target_node_id,
|
steps.push_back(RouteStep{target_node_id,
|
||||||
target_name_id,
|
target_name_id,
|
||||||
facade.IsSegregated(target_node_id),
|
facade.IsSegregated(target_node_id),
|
||||||
facade.GetNameForID(target_name_id).to_string(),
|
std::string(facade.GetNameForID(target_name_id)),
|
||||||
facade.GetRefForID(target_name_id).to_string(),
|
std::string(facade.GetRefForID(target_name_id)),
|
||||||
facade.GetPronunciationForID(target_name_id).to_string(),
|
std::string(facade.GetPronunciationForID(target_name_id)),
|
||||||
facade.GetDestinationsForID(target_name_id).to_string(),
|
std::string(facade.GetDestinationsForID(target_name_id)),
|
||||||
facade.GetExitsForID(target_name_id).to_string(),
|
std::string(facade.GetExitsForID(target_name_id)),
|
||||||
NO_ROTARY_NAME,
|
NO_ROTARY_NAME,
|
||||||
NO_ROTARY_NAME,
|
NO_ROTARY_NAME,
|
||||||
ZERO_DURATION,
|
ZERO_DURATION,
|
||||||
|
@ -70,7 +70,10 @@ template <typename StringView> inline auto decompose(const StringView &lhs, cons
|
|||||||
const auto trim = [](StringView view) {
|
const auto trim = [](StringView view) {
|
||||||
// we compare suffixes based on this value, it might break UTF chars, but as long as we are
|
// we compare suffixes based on this value, it might break UTF chars, but as long as we are
|
||||||
// consistent in handling, we do not create bad results
|
// consistent in handling, we do not create bad results
|
||||||
std::string str = boost::to_lower_copy(view.to_string());
|
std::string str(view);
|
||||||
|
std::transform(str.begin(), str.end(), str.begin(),
|
||||||
|
[](unsigned char c){ return std::tolower(c); } // correct
|
||||||
|
);
|
||||||
auto front = str.find_first_not_of(' ');
|
auto front = str.find_first_not_of(' ');
|
||||||
|
|
||||||
if (front == std::string::npos)
|
if (front == std::string::npos)
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
#define OSRM_STRING_VIEW_HPP
|
#define OSRM_STRING_VIEW_HPP
|
||||||
|
|
||||||
#include <boost/functional/hash.hpp>
|
#include <boost/functional/hash.hpp>
|
||||||
#include <boost/utility/string_ref.hpp>
|
#include <string_view>
|
||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
namespace util
|
namespace util
|
||||||
{
|
{
|
||||||
// Convenience typedef: boost::string_ref, boost::string_view or C++17's string_view
|
// Convenience typedef: boost::string_ref, boost::string_view or C++17's string_view
|
||||||
using StringView = boost::string_ref;
|
using StringView = std::string_view;
|
||||||
|
|
||||||
} // namespace util
|
} // namespace util
|
||||||
} // namespace osrm
|
} // namespace osrm
|
||||||
|
@ -340,7 +340,7 @@ class SpeedLayerFeatureBuilder : public vtzero::linestring_feature_builder
|
|||||||
add_property(m_layer.key_duration, m_layer.double_index(value));
|
add_property(m_layer.key_duration, m_layer.double_index(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_name(const boost::string_ref &value)
|
void set_name(const std::string_view value)
|
||||||
{
|
{
|
||||||
add_property(
|
add_property(
|
||||||
m_layer.key_name,
|
m_layer.key_name,
|
||||||
@ -518,7 +518,7 @@ void encodeVectorTile(const DataFacadeBase &facade,
|
|||||||
fbuilder.set_speed(speed_kmh_idx);
|
fbuilder.set_speed(speed_kmh_idx);
|
||||||
fbuilder.set_is_small(component_id.is_tiny);
|
fbuilder.set_is_small(component_id.is_tiny);
|
||||||
fbuilder.set_datasource(
|
fbuilder.set_datasource(
|
||||||
facade.GetDatasourceName(forward_datasource_idx).to_string());
|
std::string(facade.GetDatasourceName(forward_datasource_idx)));
|
||||||
fbuilder.set_weight(from_alias<double>(forward_weight) / 10.0);
|
fbuilder.set_weight(from_alias<double>(forward_weight) / 10.0);
|
||||||
fbuilder.set_duration(from_alias<double>(forward_duration) / 10.0);
|
fbuilder.set_duration(from_alias<double>(forward_duration) / 10.0);
|
||||||
fbuilder.set_name(name);
|
fbuilder.set_name(name);
|
||||||
@ -552,7 +552,7 @@ void encodeVectorTile(const DataFacadeBase &facade,
|
|||||||
fbuilder.set_speed(speed_kmh_idx);
|
fbuilder.set_speed(speed_kmh_idx);
|
||||||
fbuilder.set_is_small(component_id.is_tiny);
|
fbuilder.set_is_small(component_id.is_tiny);
|
||||||
fbuilder.set_datasource(
|
fbuilder.set_datasource(
|
||||||
facade.GetDatasourceName(reverse_datasource_idx).to_string());
|
std::string(facade.GetDatasourceName(reverse_datasource_idx)));
|
||||||
fbuilder.set_weight(from_alias<double>(reverse_weight) / 10.0);
|
fbuilder.set_weight(from_alias<double>(reverse_weight) / 10.0);
|
||||||
fbuilder.set_duration(from_alias<double>(reverse_duration) / 10.0);
|
fbuilder.set_duration(from_alias<double>(reverse_duration) / 10.0);
|
||||||
fbuilder.set_name(name);
|
fbuilder.set_name(name);
|
||||||
|
Loading…
Reference in New Issue
Block a user