mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 21:10:04 +00:00
Finish migrating std::regex to RE2
This commit is contained in:
parent
2757c51828
commit
2bd5ec8705
4 changed files with 26 additions and 33 deletions
|
|
@ -2,10 +2,10 @@
|
||||||
#include <scwx/util/logger.hpp>
|
#include <scwx/util/logger.hpp>
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <regex>
|
|
||||||
|
|
||||||
#include <boost/json.hpp>
|
#include <boost/json.hpp>
|
||||||
#include <cpr/cpr.h>
|
#include <cpr/cpr.h>
|
||||||
|
#include <re2/re2.h>
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx
|
||||||
{
|
{
|
||||||
|
|
@ -61,16 +61,10 @@ std::string UpdateManager::latest_version() const
|
||||||
std::string
|
std::string
|
||||||
UpdateManager::Impl::GetVersionString(const std::string& releaseName)
|
UpdateManager::Impl::GetVersionString(const std::string& releaseName)
|
||||||
{
|
{
|
||||||
static const std::regex re {"\\d+\\.\\d+\\.\\d+"};
|
static constexpr LazyRE2 re = {"(\\d+\\.\\d+\\.\\d+)"};
|
||||||
std::string versionString {};
|
std::string versionString {};
|
||||||
std::smatch m;
|
|
||||||
|
|
||||||
std::regex_search(releaseName, m, re);
|
RE2::PartialMatch(releaseName, *re, &versionString);
|
||||||
|
|
||||||
if (!m.empty())
|
|
||||||
{
|
|
||||||
versionString = m[0].str();
|
|
||||||
}
|
|
||||||
|
|
||||||
return versionString;
|
return versionString;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
#include <scwx/util/logger.hpp>
|
#include <scwx/util/logger.hpp>
|
||||||
#include <scwx/util/time.hpp>
|
#include <scwx/util/time.hpp>
|
||||||
|
|
||||||
#include <regex>
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include <backends/imgui_impl_opengl3.h>
|
#include <backends/imgui_impl_opengl3.h>
|
||||||
|
|
@ -33,6 +32,7 @@
|
||||||
#include <boost/uuid/random_generator.hpp>
|
#include <boost/uuid/random_generator.hpp>
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
#include <re2/re2.h>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
@ -769,14 +769,14 @@ std::string MapWidgetImpl::FindMapSymbologyLayer()
|
||||||
const std::string layer = qlayer.toStdString();
|
const std::string layer = qlayer.toStdString();
|
||||||
|
|
||||||
// Draw below layers defined in map style
|
// Draw below layers defined in map style
|
||||||
auto it = std::find_if(
|
auto it = std::find_if(currentStyle_->drawBelow_.cbegin(),
|
||||||
currentStyle_->drawBelow_.cbegin(),
|
currentStyle_->drawBelow_.cend(),
|
||||||
currentStyle_->drawBelow_.cend(),
|
[&layer](const std::string& styleLayer) -> bool
|
||||||
[&layer](const std::string& styleLayer) -> bool
|
{
|
||||||
{
|
// Perform case-insensitive matching
|
||||||
std::regex re {styleLayer, std::regex_constants::icase};
|
RE2 re {"(?i)" + styleLayer};
|
||||||
return std::regex_match(layer, re);
|
return RE2::FullMatch(layer, re);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (it != currentStyle_->drawBelow_.cend())
|
if (it != currentStyle_->drawBelow_.cend())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,9 @@
|
||||||
#include <scwx/qt/settings/settings_variable.hpp>
|
#include <scwx/qt/settings/settings_variable.hpp>
|
||||||
#include <scwx/qt/util/color.hpp>
|
#include <scwx/qt/util/color.hpp>
|
||||||
|
|
||||||
#include <regex>
|
|
||||||
|
|
||||||
#include <boost/gil.hpp>
|
#include <boost/gil.hpp>
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
#include <re2/re2.h>
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx
|
||||||
{
|
{
|
||||||
|
|
@ -134,8 +133,8 @@ public:
|
||||||
|
|
||||||
bool PaletteSettings::Impl::ValidateColor(const std::string& value)
|
bool PaletteSettings::Impl::ValidateColor(const std::string& value)
|
||||||
{
|
{
|
||||||
static const std::regex re {"#[0-9A-Za-z]{8}"};
|
static constexpr LazyRE2 re = {"#[0-9A-Fa-f]{8}"};
|
||||||
return std::regex_match(value, re);
|
return RE2::FullMatch(value, *re);
|
||||||
}
|
}
|
||||||
|
|
||||||
PaletteSettings::PaletteSettings() :
|
PaletteSettings::PaletteSettings() :
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,12 @@
|
||||||
#include <scwx/util/environment.hpp>
|
#include <scwx/util/environment.hpp>
|
||||||
#include <scwx/util/logger.hpp>
|
#include <scwx/util/logger.hpp>
|
||||||
|
|
||||||
#include <regex>
|
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QMapLibreGL/QMapLibreGL>
|
#include <QMapLibreGL/QMapLibreGL>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
#include <re2/re2.h>
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx
|
||||||
{
|
{
|
||||||
|
|
@ -108,14 +107,15 @@ TEST_P(ByMapProviderTest, MapProviderLayers)
|
||||||
const std::string layer = qlayer.toStdString();
|
const std::string layer = qlayer.toStdString();
|
||||||
|
|
||||||
// Draw below layers defined in map style
|
// Draw below layers defined in map style
|
||||||
auto it = std::find_if(
|
auto it =
|
||||||
mapStyle.drawBelow_.cbegin(),
|
std::find_if(mapStyle.drawBelow_.cbegin(),
|
||||||
mapStyle.drawBelow_.cend(),
|
mapStyle.drawBelow_.cend(),
|
||||||
[&layer](const std::string& styleLayer) -> bool
|
[&layer](const std::string& styleLayer) -> bool
|
||||||
{
|
{
|
||||||
std::regex re {styleLayer, std::regex_constants::icase};
|
// Perform case insensitive matching
|
||||||
return std::regex_match(layer, re);
|
RE2 re {"(?i)" + styleLayer};
|
||||||
});
|
return RE2::FullMatch(layer, re);
|
||||||
|
});
|
||||||
|
|
||||||
if (it != mapStyle.drawBelow_.cend())
|
if (it != mapStyle.drawBelow_.cend())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue