Output to csv, started work on OFD module
This commit is contained in:
@@ -1,26 +1,13 @@
|
||||
#include "module.h"
|
||||
#include "../settings.h"
|
||||
#include <codecvt>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <locale>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <regex>
|
||||
#include <string>
|
||||
#include "../utils/utils.h"
|
||||
|
||||
std::string to_utf8(std::wstring wide_string) {
|
||||
static std::wstring_convert<std::codecvt_utf8<wchar_t>> utf8_conv;
|
||||
return utf8_conv.to_bytes(wide_string);
|
||||
}
|
||||
StoreModule::StoreModule() {}
|
||||
|
||||
std::wstring from_utf8(std::string string) {
|
||||
static std::wstring_convert<std::codecvt_utf8<wchar_t>> utf8_conv;
|
||||
return utf8_conv.from_bytes(string);
|
||||
}
|
||||
|
||||
Module::Module() {}
|
||||
|
||||
Module::Module(std::string path) {
|
||||
StoreModule::StoreModule(std::string path) {
|
||||
std::ifstream settings_file(path);
|
||||
nlohmann::json settings = nlohmann::json::parse(settings_file);
|
||||
|
||||
@@ -42,7 +29,7 @@ Module::Module(std::string path) {
|
||||
#endif
|
||||
}
|
||||
|
||||
std::vector<std::string> Module::parse_name(std::wstring str) {
|
||||
std::vector<std::string> StoreModule::parse_name(std::wstring str) {
|
||||
std::vector<std::string> result;
|
||||
std::wregex r(this->goods_name_regex, std::regex::collate);
|
||||
|
||||
@@ -54,7 +41,7 @@ std::vector<std::string> Module::parse_name(std::wstring str) {
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::string> Module::parse_price(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);
|
||||
|
||||
@@ -66,7 +53,7 @@ std::vector<std::string> Module::parse_price(std::wstring str) {
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::string> Module::parse_quantity(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);
|
||||
|
||||
@@ -77,7 +64,7 @@ std::vector<std::string> Module::parse_quantity(std::wstring str) {
|
||||
return result;
|
||||
}
|
||||
|
||||
std::wstring Module::trim_check(std::wstring& check) {
|
||||
std::wstring StoreModule::trim_check(std::wstring& check) {
|
||||
unsigned int start_pos;
|
||||
unsigned int end_pos;
|
||||
|
||||
@@ -103,4 +90,4 @@ std::wstring Module::trim_check(std::wstring& check) {
|
||||
return check;
|
||||
}
|
||||
|
||||
std::wstring Module::get_name() { return this->name; }
|
||||
std::wstring StoreModule::get_name() { return this->name; }
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#ifndef MODULE_H
|
||||
#define MODULE_H
|
||||
#ifndef STORE_MODULE_H
|
||||
#define STORE_MODULE_H
|
||||
|
||||
#include <string>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <vector>
|
||||
|
||||
class Module {
|
||||
class StoreModule {
|
||||
std::string path;
|
||||
std::wstring name;
|
||||
std::wstring goods_name_regex;
|
||||
@@ -13,8 +13,8 @@ class Module {
|
||||
std::wstring check_start_regex;
|
||||
std::wstring check_end_regex;
|
||||
public:
|
||||
Module(std::string);
|
||||
Module();
|
||||
StoreModule(std::string);
|
||||
StoreModule();
|
||||
|
||||
std::vector<std::string> parse_name(std::wstring);
|
||||
std::vector<std::string> parse_price(std::wstring);
|
||||
@@ -25,4 +25,4 @@ public:
|
||||
std::wstring get_name();
|
||||
};
|
||||
|
||||
#endif // MODULE_H
|
||||
#endif // STORE_MODULE_H
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
Parser::Parser() {}
|
||||
|
||||
std::vector<std::string> Parser::search_modules() {
|
||||
std::string path = std::string(std::getenv("HOME")) + "/" + MODULES_DIR;
|
||||
std::string path = std::string(std::getenv("HOME")) + "/" + STORES_MODULES_DIR;
|
||||
std::filesystem::directory_entry modules_dir(path);
|
||||
|
||||
if (!modules_dir.exists()) {
|
||||
@@ -27,7 +27,7 @@ std::vector<std::string> Parser::search_modules() {
|
||||
return modules_files;
|
||||
}
|
||||
|
||||
void Parser::set_module(std::string path) { module = Module(path); }
|
||||
void Parser::set_module(std::string path) { module = StoreModule(path); }
|
||||
|
||||
std::vector<Goods> Parser::parse(std::wstring check_plaintext) {
|
||||
std::vector<Goods> result;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#ifndef PARSER_H
|
||||
#define PARSER_H
|
||||
|
||||
#include <iostream>
|
||||
#include "module.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -9,7 +8,7 @@
|
||||
|
||||
class Parser {
|
||||
|
||||
Module module;
|
||||
StoreModule module;
|
||||
public:
|
||||
Parser();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user