migrate to boost::regex
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
#include "module.h"
|
||||
#include <fstream>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <regex>
|
||||
#include <string>
|
||||
#include "../utils/utils.h"
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
StoreModule::StoreModule() {}
|
||||
|
||||
StoreModule::StoreModule(std::string path) {
|
||||
@@ -31,9 +30,9 @@ StoreModule::StoreModule(std::string path) {
|
||||
|
||||
std::vector<std::string> StoreModule::parse_name(std::wstring str) {
|
||||
std::vector<std::string> result;
|
||||
std::wregex r(this->goods_name_regex, std::regex_constants::multiline);
|
||||
boost::wregex r(this->goods_name_regex, boost::regex_constants::extended);
|
||||
|
||||
for (std::wsregex_iterator it{str.begin(), str.end(), r}, end{}; it != end;
|
||||
for (boost::wsregex_iterator it{str.begin(), str.end(), r}, end{}; it != end;
|
||||
it++) {
|
||||
result.push_back(to_utf8(it->str()));
|
||||
}
|
||||
@@ -43,9 +42,9 @@ std::vector<std::string> StoreModule::parse_name(std::wstring str) {
|
||||
|
||||
std::vector<std::string> StoreModule::parse_price(std::wstring str) {
|
||||
std::vector<std::string> result;
|
||||
std::wregex r(this->goods_price_regex, std::regex::collate);
|
||||
boost::wregex r(this->goods_price_regex, boost::regex::collate);
|
||||
|
||||
for (std::wsregex_iterator it{str.begin(), str.end(), r}, end{}; it != end;
|
||||
for (boost::wsregex_iterator it{str.begin(), str.end(), r}, end{}; it != end;
|
||||
it++) {
|
||||
result.push_back(to_utf8(it->str()));
|
||||
}
|
||||
@@ -55,9 +54,9 @@ std::vector<std::string> StoreModule::parse_price(std::wstring str) {
|
||||
|
||||
std::vector<std::string> StoreModule::parse_quantity(std::wstring str) {
|
||||
std::vector<std::string> result;
|
||||
std::wregex r(this->goods_quantity_regex, std::regex::collate);
|
||||
boost::wregex r(this->goods_quantity_regex, boost::regex::collate);
|
||||
|
||||
for (std::wsregex_iterator it{str.begin(), str.end(), r}, end{}; it != end;
|
||||
for (boost::wsregex_iterator it{str.begin(), str.end(), r}, end{}; it != end;
|
||||
it++) {
|
||||
result.push_back(to_utf8(it->str()));
|
||||
}
|
||||
@@ -68,10 +67,10 @@ std::wstring StoreModule::trim_check(std::wstring& check) {
|
||||
unsigned int start_pos;
|
||||
unsigned int end_pos;
|
||||
|
||||
std::wregex start_regex(this->check_start_regex, std::regex::collate);
|
||||
std::wregex end_regex(this->check_end_regex, std::regex::collate);
|
||||
boost::wregex start_regex(this->check_start_regex, boost::regex::collate);
|
||||
boost::wregex end_regex(this->check_end_regex, boost::regex::collate);
|
||||
|
||||
for (std::wsregex_iterator it{check.begin(), check.end(), start_regex}, end{};
|
||||
for (boost::wsregex_iterator it{check.begin(), check.end(), start_regex}, end{};
|
||||
it != end; it++) {
|
||||
start_pos = it->position() + it->str().size();
|
||||
break;
|
||||
@@ -79,7 +78,7 @@ std::wstring StoreModule::trim_check(std::wstring& check) {
|
||||
|
||||
check = check.substr(start_pos, check.size());
|
||||
|
||||
for (std::wsregex_iterator it{check.begin(), check.end(), end_regex}, end{};
|
||||
for (boost::wsregex_iterator it{check.begin(), check.end(), end_regex}, end{};
|
||||
it != end; it++) {
|
||||
end_pos = it->position() - 1;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user