structure, layout, parser and its modules

This commit is contained in:
2024-08-19 02:35:16 +03:00
parent d41144a634
commit ffbc929472
258 changed files with 5830 additions and 461 deletions

43
parser/module.cpp Normal file
View File

@@ -0,0 +1,43 @@
#include "module.h"
#include <fstream>
#include <nlohmann/json.hpp>
#include <regex>
Module::Module() {}
Module::Module(std::string path) {
std::ifstream settings_file(path);
nlohmann::json settings = nlohmann::json::parse(settings_file);
this->name = settings["name"];
this->goods_name_regex = settings["goods_name_regex"];
this->goods_price_regex = settings["goods_price_regex"];
this->goods_quantity_regex = settings["goods_quantity_regex"];
}
std::smatch Module::parse_name(std::string str) {
std::regex r(this->goods_name_regex);
std::smatch m;
regex_search(str, m, r);
return m;
}
std::smatch Module::parse_price(std::string str) {
std::regex r(this->goods_price_regex);
std::smatch m;
regex_search(str, m, r);
return m;
}
std::smatch Module::parse_quantity(std::string str) {
std::regex r(this->goods_quantity_regex);
std::smatch m;
regex_search(str, m, r);
return m;
}
std::string Module::get_name() { return this->name; }