diff --git a/libs/traffxml/traff_model.cpp b/libs/traffxml/traff_model.cpp index f7b4ba483..1a083a55a 100644 --- a/libs/traffxml/traff_model.cpp +++ b/libs/traffxml/traff_model.cpp @@ -3,13 +3,15 @@ #include "base/logging.hpp" #include -#include +#include + +#include using namespace std; namespace traffxml { -const std::map kEventSpeedGroupMap{ +const std::unordered_map kEventSpeedGroupMap{ // TODO Activity*, Authority*, Carpool* (not in enum yet) {EventType::CongestionHeavyTraffic, traffic::SpeedGroup::G4}, {EventType::CongestionLongQueue, traffic::SpeedGroup::G0}, @@ -54,7 +56,7 @@ const std::map kEventSpeedGroupMap{ // none of the currently define events imply an explicit maxspeed #if 0 -const std::map kEventMaxspeedMap{ +const std::unordered_map kEventMaxspeedMap{ // TODO Activity*, Authority*, Carpool* (not in enum yet) // TODO Construction* (not in enum yet) // TODO Environment*, EquipmentStatus*, Hazard*, Incident* (not in enum yet) @@ -63,7 +65,7 @@ const std::map kEventMaxspeedMap{ }; #endif -const std::map kEventDelayMap{ +const std::unordered_map kEventDelayMap{ // TODO Activity*, Authority*, Carpool* (not in enum yet) // TODO Construction* (not in enum yet) //{EventType::DelayDelay, }, // mapped to speed group @@ -121,10 +123,10 @@ std::optional IsoTime::ParseIsoTime(std::string timeString) * 11: :00 (UTC offset, minutes, prefixed with separator) * 12: 00 (UTC offset, minutes, unsigned; blank for Z or if not specified) */ - std::regex iso8601Regex("([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2}(\\.[0-9]*)?)(Z|(([+-][0-9]{2})(:?([0-9]{2}))?))?"); + static boost::regex iso8601Regex("([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2}(\\.[0-9]*)?)(Z|(([+-][0-9]{2})(:?([0-9]{2}))?))?"); - std::smatch iso8601Matcher; - if (std::regex_search(timeString, iso8601Matcher, iso8601Regex)) + boost::smatch iso8601Matcher; + if (boost::regex_search(timeString, iso8601Matcher, iso8601Regex)) { int offset_h = iso8601Matcher[10].matched ? std::stoi(iso8601Matcher[10]) : 0; int offset_m = iso8601Matcher[12].matched ? std::stoi(iso8601Matcher[12]) : 0; diff --git a/libs/traffxml/traff_model_xml.cpp b/libs/traffxml/traff_model_xml.cpp index 243956921..0a6643d9c 100644 --- a/libs/traffxml/traff_model_xml.cpp +++ b/libs/traffxml/traff_model_xml.cpp @@ -6,11 +6,11 @@ #include #include #include -#include #include #include #include +#include #include @@ -504,9 +504,9 @@ bool LatLonFromXml(pugi::xml_node const & node, ms::LatLon & latLon) std::string string; if (StringFromXml(node, string)) { - std::regex latLonRegex("([+-]?[0-9]*\\.?[0-9]*)\\s+([+-]?[0-9]*\\.?[0-9]*)"); - std::smatch latLonMatcher; - if (std::regex_search(string, latLonMatcher, latLonRegex) && latLonMatcher[1].matched && latLonMatcher[2].matched) + static boost::regex latLonRegex("([+-]?[0-9]*\\.?[0-9]*)\\s+([+-]?[0-9]*\\.?[0-9]*)"); + boost::smatch latLonMatcher; + if (boost::regex_search(string, latLonMatcher, latLonRegex) && latLonMatcher[1].matched && latLonMatcher[2].matched) { try { @@ -689,10 +689,10 @@ std::optional OptionalDurationFromXml(pugi::xml_attribute const & attr * 1 h * 30 min */ - std::regex durationRegex("(([0-9]+):([0-9]{2}))|(([0-9]+) *h)|(([0-9]+) *min)"); - std::smatch durationMatcher; + static boost::regex durationRegex("(([0-9]+):([0-9]{2}))|(([0-9]+) *h)|(([0-9]+) *min)"); + boost::smatch durationMatcher; - if (std::regex_search(durationString, durationMatcher, durationRegex)) + if (boost::regex_search(durationString, durationMatcher, durationRegex)) { if (!durationMatcher.str(2).empty() && !durationMatcher.str(3).empty()) return std::stoi(durationMatcher[2]) * 60 + std::stoi(durationMatcher[3]);