rewrite utils with moduled approach, butfixes
This commit is contained in:
@@ -1,24 +1,30 @@
|
||||
#include "utils.h"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#ifdef BUILD_OFD_BINARYEYE_SCAN
|
||||
# include <arpa/inet.h>
|
||||
# include <qrencode.h>
|
||||
# include <ifaddrs.h>
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef BUILD_OFD_MODULE
|
||||
# include "../exceptions/ofdrequestexception.h"
|
||||
#endif
|
||||
#include <codecvt>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <locale>
|
||||
#include <opencv2/core/mat.hpp>
|
||||
#include <opencv2/imgcodecs.hpp>
|
||||
#include <opencv2/imgproc.hpp>
|
||||
#include <qrencode.h>
|
||||
#if defined(BUILD_OCR_MODE) || defined(BUILD_OFD_MODE)
|
||||
# include <opencv2/core/mat.hpp>
|
||||
# include <opencv2/imgcodecs.hpp>
|
||||
# include <opencv2/imgproc.hpp>
|
||||
#endif
|
||||
#include <regex>
|
||||
#include <string>
|
||||
#include "../exceptions/ofdrequestexception.h"
|
||||
#include "settings/settings.h"
|
||||
#include <QWidget>
|
||||
#include <fstream>
|
||||
#include <ifaddrs.h>
|
||||
#include <netinet/in.h>
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
|
||||
#ifdef BUILD_OFD_BINARYEYE_SCAN
|
||||
std::string get_local_ip_address() {
|
||||
struct ifaddrs * ifAddrStruct=NULL;
|
||||
struct ifaddrs * ifa=NULL;
|
||||
@@ -44,6 +50,7 @@ std::string get_local_ip_address() {
|
||||
|
||||
throw std::runtime_error(QWidget::tr("Could not find any usable local IP address. If you beleive that this is problem with the program, please, contact the developer.").toStdString());
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string to_utf8(std::wstring wide_string) {
|
||||
static std::wstring_convert<std::codecvt_utf8<wchar_t>> utf8_conv;
|
||||
@@ -114,7 +121,7 @@ std::wstring substring_from_to(std::wstring& text, std::wstring from, std::wstri
|
||||
|
||||
return substring;
|
||||
}
|
||||
|
||||
#ifdef BUILD_OFD_MODE
|
||||
std::wstring trim_html_response(std::wstring& check) {
|
||||
std::wstring begin_check_marker = from_utf8("<!-- Products -->");
|
||||
std::wstring end_check_marker = from_utf8("<!-- \\/Products -->");
|
||||
@@ -219,7 +226,9 @@ Check parseOfdRuAnswer(std::string html) {
|
||||
|
||||
return c;
|
||||
}
|
||||
#endif // ifdef BUILD_OFD_MODE
|
||||
|
||||
#ifdef BUILD_OFD_BINARYEYE_SCAN
|
||||
void generate_qr_code(std::string data) {
|
||||
QRcode *qrCode = QRcode_encodeString(data.c_str(), 2, QR_ECLEVEL_L, QR_MODE_8, 1);
|
||||
if (qrCode == NULL) {
|
||||
@@ -244,3 +253,4 @@ void generate_qr_code(std::string data) {
|
||||
cv::imwrite(get_path_relative_to_home(".local/share/checks_parser/binaryeye_connection.png"), qrCodeImage);
|
||||
QRcode_free(qrCode);
|
||||
}
|
||||
#endif // ifdef BUILD_OFD_BINARYEYE_SCAN
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <vector>
|
||||
#include "../check/check.h"
|
||||
|
||||
std::string get_local_ip_address();
|
||||
std::string to_utf8(std::wstring wide_string);
|
||||
std::wstring from_utf8(std::string string);
|
||||
|
||||
@@ -16,10 +15,15 @@ bool vector_contains_element(const std::vector<T> &vector, const T &to_find);
|
||||
|
||||
std::vector<std::string> split(std::string, std::string);
|
||||
|
||||
#ifdef BUILD_OFD_MODULE
|
||||
Check parseOfdRuAnswer(std::string);
|
||||
|
||||
std::wstring trim_html_response(std::wstring& check);
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_OFD_BINARYEYE_SCAN
|
||||
void generate_qr_code(std::string data);
|
||||
std::string get_local_ip_address();
|
||||
#endif
|
||||
|
||||
#endif // UTILS_H
|
||||
|
||||
Reference in New Issue
Block a user