diff --git a/CMakeLists.txt b/CMakeLists.txt index 990569c..6eb4f46 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,7 @@ if (BUILD_OFD_BINARYEYE_SCAN) endif() SET(CMAKE_BUILD_TYPE Debug) +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) @@ -215,6 +216,16 @@ endif() target_link_libraries(checks-parser PRIVATE -lcurl) +find_package(Boost 1.45.0 COMPONENTS boost_regex) + +if(Boost_FOUND) + include_directories(${Boost_INCLUDE_DIRS}) + target_link_libraries(checks-parser PUBLIC ${Boost_LIBRARIES}) +else() + message(FATAL_ERROR "No BOOST library found. Please, install one. If you beleive this is an error, please, contact the developer.") + return() +endif() + if (BUILD_OCR_MODE OR BUILD_OFD_LOCAL_QR_SCAN OR BUILD_OFD_BINARYEYE_SCAN) find_package(OpenCV REQUIRED COMPONENTS core imgproc imgcodecs) target_link_libraries(checks-parser PRIVATE ${OpenCV_LIBS}) diff --git a/deploy/appimage/Dockerfile b/deploy/appimage/Dockerfile index edb4211..ebcc56f 100644 --- a/deploy/appimage/Dockerfile +++ b/deploy/appimage/Dockerfile @@ -13,19 +13,20 @@ RUN DEBIAN_FRONTEND=noninteractive apt install -y libmpc-dev libmpfr-dev libgmp- WORKDIR / -RUN wget https://mirror.linux-ia64.org/gnu/gcc/releases/gcc-12.3.0/gcc-12.3.0.tar.gz -RUN tar xf gcc-12.3.0.tar.gz +#RUN wget https://mirror.linux-ia64.org/gnu/gcc/releases/gcc-12.3.0/gcc-12.3.0.tar.gz +RUN wget https://mirror.linux-ia64.org/gnu/gcc/releases/gcc-13.3.0/gcc-13.3.0.tar.gz +RUN tar xf gcc-13.3.0.tar.gz -RUN rm gcc-12.3.0.tar.gz +RUN rm gcc-13.3.0.tar.gz -WORKDIR /gcc-12.3.0 +WORKDIR /gcc-13.3.0 RUN ./configure --disable-multilib --prefix=/usr RUN make -j $(nproc) && make install RUN cp /lib64/* /lib/x86_64-linux-gnu || : WORKDIR / -RUN rm -rf gcc-12.3.0 +RUN rm -rf gcc-13.3.0 # Download linuxdeployqt RUN wget https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage -O /usr/bin/linuxdeployqt && \ @@ -65,13 +66,13 @@ RUN cmake -DBUILD_TRANSLATIONS=on .. && make -j 8 WORKDIR /appimage/AppDir/usr/bin -RUN cp /appimage/build/checks-parser +RUN cp /appimage/build/checks-parser . WORKDIR /appimage -RUN linuxdeployqt --appimage-extract-and-run AppDir/usr/bin/checks-parser -no-copy-copyright-files -appimage +RUN linuxdeployqt --appimage-extract-and-run AppDir/usr/bin/checks-parser -no-copy-copyright-files -appimage || : -RUN mkdir -p /output -RUN cp Checks_parser-x86_64.AppImage /output +RUN mkdir -p /output || : +RUN cp Checks_parser-x86_64.AppImage /output || : ENTRYPOINT bash diff --git a/main.cpp b/main.cpp index 540366a..cb0a4dc 100644 --- a/main.cpp +++ b/main.cpp @@ -50,12 +50,10 @@ int main(int argc, char *argv[]) { QTranslator translator; QString lang = "en_US"; + bool languageSettingPresent = false; -#if NLOHMANN_JSON_VERSION_MAJOR < 3 && NLOHMANN_JSON_VERSION_MINOR < 6 && NLOHMANN_JSON_VERSION_PATCH < 0 languageSettingPresent = s.get_all_settings().find("language") != s.get_all_settings().end(); -#else - languageSettingPresent = s.get_all_settings().contains("language"); -#endif + if (languageSettingPresent) { lang = QString::fromStdString(s.get_all_settings()["language"]); } else if (translator.load(":/translation/"+QLocale::system().name()+".qm")) { diff --git a/net/net.cpp b/net/net.cpp index 7f03557..b68dbc5 100644 --- a/net/net.cpp +++ b/net/net.cpp @@ -4,6 +4,7 @@ #include #include #include +#include struct data {}; @@ -23,11 +24,11 @@ void write_modules(void *buffer, size_t size, size_t nmemb, void *modules) { (std::vector *)modules; std::string to_parse = std::string((char*)buffer); - std::regex r("(?!\\\")\\w+\\.json(?!\\\")", std::regex::collate); - std::smatch res; + boost::regex r("(?!\\\")\\w+\\.json(?!\\\")", boost::regex::collate); + boost::smatch res; std::string::const_iterator search(to_parse.cbegin()); - while (std::regex_search(search, to_parse.cend(), res, r)) { + while (boost::regex_search(search, to_parse.cend(), res, r)) { modules_vector->push_back(res[0]); search = res.suffix().first; } diff --git a/parser/module.cpp b/parser/module.cpp index dba8d44..7c4ba5d 100644 --- a/parser/module.cpp +++ b/parser/module.cpp @@ -1,10 +1,9 @@ #include "module.h" #include #include -#include #include #include "../utils/utils.h" - +#include StoreModule::StoreModule() {} StoreModule::StoreModule(std::string path) { @@ -31,9 +30,9 @@ StoreModule::StoreModule(std::string path) { std::vector StoreModule::parse_name(std::wstring str) { std::vector 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 StoreModule::parse_name(std::wstring str) { std::vector StoreModule::parse_price(std::wstring str) { std::vector 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 StoreModule::parse_price(std::wstring str) { std::vector StoreModule::parse_quantity(std::wstring str) { std::vector 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; diff --git a/utils/utils.cpp b/utils/utils.cpp index e652cf3..f274d58 100644 --- a/utils/utils.cpp +++ b/utils/utils.cpp @@ -19,9 +19,9 @@ #endif #include #include -#include "settings/settings.h" #include #include +#include #ifdef BUILD_OFD_BINARYEYE_SCAN @@ -97,10 +97,10 @@ std::wstring substring_from_to(std::wstring& text, std::wstring from, std::wstri std::wstring substring; - std::wregex start_regex(from); - std::wregex end_regex(to); + boost::wregex start_regex(from); + boost::wregex end_regex(to); - for (std::wsregex_iterator it{text.begin(), text.end(), start_regex}, end{}; + for (boost::wsregex_iterator it{text.begin(), text.end(), start_regex}, end{}; it != end; it++) { start_pos = it->position() + it->str().size(); break; @@ -109,7 +109,7 @@ std::wstring substring_from_to(std::wstring& text, std::wstring from, std::wstri if(text == from_utf8("")) return text; substring = text.substr(start_pos, text.size()); - for (std::wsregex_iterator it{substring.begin(), substring.end(), end_regex}, end{}; + for (boost::wsregex_iterator it{substring.begin(), substring.end(), end_regex}, end{}; it != end; it++) { end_pos = it->position(); break; @@ -131,10 +131,10 @@ std::wstring trim_html_response(std::wstring& check) { } std::vector find_in_html(std::string& html, std::string regex, std::string html_start, std::string html_end) { - std::regex searching_regex(regex); + boost::regex searching_regex(regex); std::vector parsed; - for (std::sregex_iterator it{html.begin(), html.end(), searching_regex}, end{}; + for (boost::sregex_iterator it{html.begin(), html.end(), searching_regex}, end{}; it != end; it++) { std::wstring found_entry = from_utf8(it->str());