/
Alexandr_Pidkasisty
/
froma2
Обзор
Документация
Войти
/
Alexandr_Pidkasisty
/
froma2
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
libsource/Impex_module.h
215 строк
16 KB
Alexandr Pidkasisty
Скорректировал комментарии у метода Import_Recipes
03 авг 2026, 21:45
Верифицирован
03 авг 2026, 21:45
96a4263
Код
Авторство
О чём код?
/** ���� ���� �������� ������ ���������� ������������ ����������� ��� �������������� �������������, ����������� ������� � ������������ ������������ ������������ ����������� "Free Operation Manager 2" (���������� FROMA2). **/ /****************************************************************************************************/ /****************************************************************************************************/ /*** ***/ /*** Copyright � 2025 ����������� ��������� �������� ***/ /*** ***/ /*** ������ �������� ��������� �����, ���������� ����� ������� ������������ ����������� � ***/ /*** ������������� ������������ (����� � ����������� �����������), ������������ ������������ ***/ /*** ����������� ����������� ��� �����������, ������� �������������� ����� �� �������������, ***/ /*** �����������, ���������, �������, ����������, ���������������, ����������������� �/��� ***/ /*** ������� ����� ������������ �����������, � ����� �����, ������� ��������������� ������ ***/ /*** ����������� �����������, ��� ���������� ��������� �������: ***/ /*** ***/ /*** ��������� ���� ����������� �� ��������� ����� � ������ ������� ������ ���� �������� �� ***/ /*** ��� ����� ��� �������� ����� ������� ������������ �����������. ***/ /*** ***/ /*** ������ ����������� ����������� ��������������� ���� ���ܻ, ��� �����-���� ��������, ���� ***/ /*** ���������� ��� ���������������, ������� �������� �������� �����������, ������������ �� ***/ /*** ��� ����������� ���������� � ���������� ���������, �� �� ������������� ���. �� � ����� ***/ /*** ������ ������ ��� ��������������� �� ����� ��������������� �� �����-���� �����, �� ����� ***/ /*** ��� �� ���� �����������, � ��� �����, ��� �������� ���������, ������� ��� ���� ��������, ***/ /*** ��������� ��-�� ������������� ������������ ����������� ��� ���� �������� � ����������� ***/ /*** ������������. ***/ /*** ***/ /****************************************************************************************************/ /****************************************************************************************************/ #ifndef FROMA2_CLSIMPEX_H #define FROMA2_CLSIMPEX_H #include <iostream> #include <fstream> #include <string> #include <sstream> #include <vector> #include <iomanip> #include <limits> // ���������� �������� ��������������� ����� #include <filesystem> // ������ � ������� � ������������ #include <regex> // ������ � ����������� ����������� #include "common_values.hpp" #include "LongReal_module.h" #include "manufact_module.h" // ���������� ��� clsRecipeItem namespace fs = std::filesystem; // ������� �������� ����� using namespace std; const size_t constexpr ex_precision = (std::is_same<decimal, LongReal>::value) ? manDigits : \ (std::numeric_limits<decimal>::max_digits10); /** ���� � �������� ������������ ������������ ����� ���� LongReal, �� ����� �������� ����� manDigits, ���� ���������� ����, - �� max_digits10. ������������ � ������� clsImpex::csvExport � clsImpex::Import. **/ template<typename U> // ����������� ���� ��� Get-������� constexpr bool is_decimal_bool_or_size_t_v = std::is_same<U, decimal>::value || std::is_same<U, bool>::value || std::is_same<U, size_t>::value; /*************************************************************************************************************************/ /** ����� clsImpex ��� ������� � �������� ���������� �� cvs-������ **/ /** � ���������� �������� ������ ��� �������� ���� clsStorage � clsManufactory **/ /*************************************************************************************************************************/ class clsImpex { private: vector<std::vector<std::string>> m_data; // ������ ��� �������� ������ �� ����� size_t m_rowcount, m_colcount; // ���������� ����� � �������� ������� char separator; // ����������� public: clsImpex(); // ����������� �� ��������� clsImpex(ifstream& ifs, const char& ch); // ����������� � ����������� ��� ������� �� ��������� ������. // ���������: ifs - �������� ����� �� ������, ch - ������ ����������� // ����� ������� � ����� clsImpex(const size_t ncount, const nmBPTypes::strNameMeas names[],\ const nmBPTypes::strItem data[], const size_t dcount, nmBPTypes::ReportData flg); // ����������� � ����������� ��� ������� �� ��������. ���������: // ncount - ����� �����, ������ ����� ��������� ������� names[], // names[] - ������ � �������������� ����� � ��������� ���������, // data[] - ���������� ������,������ ��������� ������� �������� // ncount*dcount � �������; dcount - ����� �������� �������; // flg - ����, ������������ ��� ������: volume, price ��� value clsImpex(const clsImpex& other); // ����������� ����������� clsImpex(clsImpex&& other); // ����������� ����������� void swap(clsImpex& other) noexcept; // ������� ������ ���������� ����� ��������� clsImpex& operator=(const clsImpex& other); // ���������� ��������� ������������ ������������ clsImpex& operator=(clsImpex &&obj); // ���������� ��������� ������������ ������������ void reset(); // ���������� ��������� ������� �� �������� �� ��������� bool is_Empty() const; // ���������� true, ���� m_data ������ /** ������ ������� **/ bool Import(ifstream& ifs, const char& ch); // ����� ������� ������ �� ��������� ������. ����������: // ifs - �������� ����� �� ������, ch - ������ ����������� bool Import(const size_t ncount, const nmBPTypes::strNameMeas names[],\ const nmBPTypes::strItem data[], const size_t dcount, nmBPTypes::ReportData flg); // ����� ������� ������ �� ��������. // ���������: ncount - ����� �����, ������ ����� ��������� ������� names[], // names[] - ������ � �������������� ����� � ��������� ���������, // data[] - ���������� ������,������ ��������� ������� �������� // ncount*dcount � �������; dcount - ����� �������� �������; // flg - ����, ������������ ��� ������: volume, price ��� value /** ������ �������������� **/ void Transpon(); // ����� ������������� ������� m_data /** ������ �������� **/ void csvExport(ofstream& ofs) const; // ����� �������� ������� � csv-���� � ������������, // �������� � ���������� separator /** ������ Get **/ decimal* GetDecimal(const size_t brow, const size_t erow, const size_t bcol,\ const size_t ecol) const; // ����� ���������� ��������� � ������� ������, // ���������������� � ��� decimal. ���������: // brow - ��������� ������ ������, erow - �������� ������, // bcol - ��������� �������, ecol - �������� �������. // ����� ���������� ���������� ������������ ������, // ���������� �������� ��������� ������� �������� // (erow-brow+1)*(ecol-bcol+1). // ��������!!! ��� ������������� � ����������� ������� ������� clsStorage � clsManufactory ������� // (� ������� m_data) � ���������������� ������� ������ ����� �������������� ���������� (������ ������� // - � ������ ��������). � ��������� ������ ����� ����������� ���������� ������ ������� ���������� ���������������. template<typename T, class=std::enable_if_t<is_decimal_bool_or_size_t_v<T>>> T* GetData(const size_t brow, const size_t erow, const size_t bcol, const size_t ecol) const; /** ����� ���������� ��������� � ������� ������, ���������������� � ��� decimal, bool ��� size_t. ���������: brow - ��������� ������ ������, erow - �������� ������, bcol - ��������� �������, ecol - �������� �������. ����� ���������� ���������� ������������ ������, ���������� �������� ��������� ������� �������� (erow-brow+1)*(ecol-bcol+1). **/ nmBPTypes::strNameMeas* GetNames(const size_t brow, const size_t erow,const size_t idName,\ const size_t idMeas) const; // ����� ���������� ��������� � ������� ������ // ���������������� � ��� strNameMeas. ���������: // brow - ��������� ������ ������, erow - �������� ������, // idName - ����� ������� � ����������, idMeas - ����� ������� // � ��������� ���������. ����� ���������� ���������� // ������������ ������ �������� (erow-brow+1). // ��������!!! ��� ������������� � ����������� ������� ������� clsStorage � clsManufactory ������� // (� ������� m_data) � ���������������� ������� ������ ����� �������������� ���������� (������ ������� // - � ������ ��������). � ��������� ������ ����� ����������� ���������� ������ ������� ���������� ���������������. string* GetNames(const size_t brow, const size_t erow, const size_t idName) const; // ����� ���������� ��������� � ������� ������ // ���� string (��� ������ ����������� ���������). ���������: // brow - ��������� ������ ������, erow - �������� ������, // idName - ����� ������� � ����������. ����� ���������� ���������� // ������������ ������ �������� (erow-brow+1). // ��������!!! ��� ������������� � ����������� ������� ������� clsStorage � clsManufactory ������� // (� ������� m_data) � ���������������� ������� ������ ����� �������������� ���������� (������ ������� // - � ������ ��������). � ��������� ������ ����� ����������� ���������� ������ ������� ���������� ���������������. nmBPTypes::strItem* GetstrItem(const size_t brow, const size_t erow, const size_t bcol,\ const size_t ecol, nmBPTypes::ReportData flg) const; // ����� ���������� ��������� � ������� ������ // ���������������� � ��� strItem. ���������: // brow - ��������� ������ ������, erow - �������� ������, // bcol - ��������� �������, ecol - �������� �������, // flg - - ����, ������������ ��� ������: volume, price ��� value // ����� ���������� ���������� ������������ ������, // ���������� �������� ��������� ������� �������� // (erow-brow+1)*(ecol-bcol+1). // ��������!!! ��� ������������� � ����������� ������� ������� clsStorage � clsManufactory ������� // (� ������� m_data) � ���������������� ������� ������ ����� �������������� ���������� (������ ������� // - � ������ ��������). � ��������� ������ ����� ����������� ���������� ������ ������� ���������� ���������������. size_t GetRowCount() const; // ����� ���������� ����� ����� ������� size_t GetColCount() const; // ����� ���������� ����� �������� ������� /** ������ ����������� �������� **/ void View(ostream& os) const; // ����� ����������� �������� protected: }; /*************************************************************************************************************************/ /** ������������ ������� **/ /*************************************************************************************************************************/ using namespace nmBPTypes; bool ImportSingleArray(const string _filename, const char _ch, size_t hcols, size_t hrows, ReportData flg,\ strItem* &_data, strNameMeas* &_names, size_t& ColCount, size_t& RowCount); /** ����� ������ ���������� �� ����� � ������ _filename � ������������� ����� ������ _ch � ��������� ����: RowCount - ����� �������������� ������� (�������� ��� ���������), ColCount - ����� �������� �������, _names - ������ �� ��������� �� ������ � �������������� �������������� ������� � ������ �� ���������, _data - ������ �� ��������� �� ����������� ������, flg - ����, ������������ ��� ������������� ������: "volume" - ������ � ����������� ���������, "price" - ����, "value" - ���������; hcols � hrows - ���������� �������� � ����� � �����������, ���������� �������� �������� � ������ �������� �������. **/ template<typename U> // ����������� ���� ��� ������� ImportSingleArray constexpr bool is_decimal_bool_or_PurchaseCalc_v = std::is_same<U, decimal>::value || std::is_same<U, bool>::value || std::is_same<U, size_t>::value; template<typename T, class=std::enable_if_t<is_decimal_bool_or_PurchaseCalc_v<T>>> bool ImportSingleArray(const string _filename, const char _ch, size_t hcols, size_t hrows, \ T* &_data, strNameMeas* &_names, size_t& ColCount, size_t& RowCount); /** ����� ������ ���������� �� ����� � ������ _filename � ������������� ����� ������ _ch � ��������� ����: RowCount - ����� �������������� ������� (�������� ��� ���������), ColCount - ����� �������� �������, _names - ������ �� ��������� �� ������ � �������������� �������������� ������� � ������ �� ���������, _data - ������ �� ��������� �� ����������� ������; hcols � hrows - ���������� �������� � ����� � �����������, ���������� �������� �������� � ������ �������� �������. **/ bool Import_Recipes(const string _prefixname, const char _ch, size_t hcols, size_t hrows,vector<clsRecipeItem>\ &_Recipe, size_t _Count, const string& msks, const string& V_DIR_INPUTDATA); /** ����� ������ ���������� �� ������ � �������, ����������� ������� ����� ���������/ ��������������� ����� _prefixname. �������������� ��� �����, ��������������� ����� msks � ������� � ����� �����. ����� ��������� ��������� �������� _Recipe �������� _Count. ���������: _prefixname - ������� ���� ������ ���.����, _ch - �����������, ������������ � ������ ���� CSV, hcols - ���������� �������� � �����������, hrows - ���������� ����� � ����������� � ������, _Recipe - �������� ���������, _Count - ������ ����� ����������, msks - ����� ����������� ��������� ��� ������ ���������� ������, V_DIR_INPUTDATA - �����, ��� ����� ����������� ����� ������. **/ #endif // FROMA2_CLSIMPEX_H