Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ __history/
*.dproj.local
*.cbproj.local
Compile
.vscode

# Deployment files
*.deployproj
Expand All @@ -83,4 +84,6 @@ Compile
*.bpl
*.drc
*.res
*.rc
*.rc
docs/
*.ps1
2 changes: 2 additions & 0 deletions src/AccountingRegisters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ __fastcall TAccountingRegisters::TAccountingRegisters(v8catalog *_parent, const
: MetadataObjectInformationRegister(_parent, _guid)
{
initializeFromTree();
root_data.reset();
}

__fastcall TAccountingRegisters::TAccountingRegisters(v8catalog *_parent, const String& _guid, const String& _name)
: MetadataObjectInformationRegister(_parent, _guid, _name)
{
initializeFromTree();
root_data.reset();
}

__fastcall TAccountingRegisters::~TAccountingRegisters()
Expand Down
2 changes: 2 additions & 0 deletions src/AccumulationRegisters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ __fastcall TAccumulationRegisters::TAccumulationRegisters(v8catalog *_parent, co
: MetadataObjectInformationRegister(_parent, _guid)
{
initializeFromTree();
root_data.reset();
}

__fastcall TAccumulationRegisters::TAccumulationRegisters(v8catalog *_parent, const String& _guid, const String& _name)
: MetadataObjectInformationRegister(_parent, _guid, _name)
{
initializeFromTree();
root_data.reset();
}

__fastcall TAccumulationRegisters::~TAccumulationRegisters()
Expand Down
11 changes: 3 additions & 8 deletions src/BaseMetadataObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ __fastcall BaseMetadataObject::BaseMetadataObject(v8catalog* _parent, const Stri
{
guid = _guid;
parent = _parent;
root_data = get_treeFromV8file(parent->GetFile(_guid));
root_data.reset(get_treeFromV8file(parent->GetFile(_guid)));
name = ""; // Имя будет инициализировано в производных классах
}

Expand All @@ -27,17 +27,12 @@ __fastcall BaseMetadataObject::BaseMetadataObject(v8catalog* _parent, const Stri
name = _name;
guid = _guid;
parent = _parent;
root_data = get_treeFromV8file(parent->GetFile(_guid));
root_data.reset(get_treeFromV8file(parent->GetFile(_guid)));
}

__fastcall BaseMetadataObject::~BaseMetadataObject()
{
// Освобождение ресурсов, если необходимо
if (root_data)
{
delete root_data;
//root_data = nullptr;
}
// unique_ptr автоматически освобождает память
}

String __fastcall BaseMetadataObject::GetName()
Expand Down
3 changes: 2 additions & 1 deletion src/BaseMetadataObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
//---------------------------------------------------------------------------

#include <vector>
#include <memory>
#include "Class_1CD.h"
#include "APIcfBase.h"
#include "Parse_tree.h"
Expand All @@ -23,7 +24,7 @@ class BaseMetadataObject : public TObject
// Общие поля
String name;
String guid;
tree* root_data;
std::unique_ptr<tree> root_data;
v8catalog* parent;

// Конструкторы
Expand Down
3 changes: 3 additions & 0 deletions src/Bots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@
__fastcall TBots::TBots() : BaseMetadataObject()
{
botName = "";
root_data.reset();
}

__fastcall TBots::TBots(v8catalog* _parent, const String& _guid) : BaseMetadataObject(_parent, _guid)
{
botName = "";
root_data.reset();
}

__fastcall TBots::TBots(v8catalog* _parent, const String& _guid, const String& _name) : BaseMetadataObject(_parent, _guid, _name)
{
botName = _name;
root_data.reset();
}

__fastcall TBots::~TBots()
Expand Down
2 changes: 2 additions & 0 deletions src/CalculationRegisters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ __fastcall TCalculationRegisters::TCalculationRegisters(v8catalog *_parent, cons
: MetadataObjectInformationRegister(_parent, _guid)
{
initializeFromTree();
root_data.reset();
}

//---------------------------------------------------------------------------
__fastcall TCalculationRegisters::TCalculationRegisters(v8catalog *_parent, const String& _guid, const String& _name)
: MetadataObjectInformationRegister(_parent, _guid, _name)
{
initializeFromTree();
root_data.reset();
}

//---------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/Catalogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ __fastcall TCatalogs::TCatalogs(v8catalog *_parent, const String& _guid)
: MetadataObjectWithSections(_parent, _guid)
{
initializeFromTree();
root_data.reset();
}

__fastcall TCatalogs::TCatalogs(v8catalog *_parent, const String& _guid, const String& _name)
: MetadataObjectWithSections(_parent, _guid, _name)
{
initializeFromTree();
root_data.reset();
}

__fastcall TCatalogs::~TCatalogs()
Expand Down
56 changes: 29 additions & 27 deletions src/ChartOfAccounts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,44 @@


__fastcall TChartOfAccounts::TChartOfAccounts()
: BaseMetadataObject()
{
guid = "";
name = "";
parent = NULL;
root_data.reset();
}

__fastcall TChartOfAccounts::TChartOfAccounts(v8catalog *_parent, const String& _guid)
: BaseMetadataObject(_parent, _guid)
{
guid = _guid;
parent = _parent;
root_data = get_treeFromV8file(parent->GetFile(_guid));
initializeFromTree();
root_data.reset();
}

__fastcall TChartOfAccounts::TChartOfAccounts(v8catalog *_parent, const String& _guid, const String& _name)
: BaseMetadataObject(_parent, _guid, _name)
{
name = _name;
guid = _guid;
parent = _parent;
root_data = get_treeFromV8file(parent->GetFile(_guid));
initializeFromTree();
root_data.reset();
}

__fastcall TChartOfAccounts::~TChartOfAccounts()
{
}

void __fastcall TChartOfAccounts::initializeFromTree()
{
if (!root_data) return;

// Получаем имена реквизитов
attributes.clear();
tree* node_att = root_data;
tree* node_att = root_data.get();

node_att = &(*node_att)[0][7][1]; // количество элементов
int CountAtt = node_att->get_value().ToInt();
int Delta = CountAtt - 2;
for (int i = 0; i < CountAtt; i++)
{
try {
tree* node_att_att = root_data;
tree* node_att_att = root_data.get();
node_att_att = &(*node_att_att)[0][7][i+CountAtt-Delta][0][1][1][1][2];
String NameAtt = node_att_att->get_value();
attributes.push_back(std::make_unique<TRequisite>(NameAtt, ""));
Expand All @@ -49,27 +56,27 @@ __fastcall TChartOfAccounts::TChartOfAccounts(v8catalog *_parent, const String&

// получаем признаки учета
accflags.clear();
tree* node_acc = root_data;
tree* node_acc = root_data.get();
node_acc = &(*node_acc)[0][8][1]; // количество элементов
int CountAcc = node_acc->get_value().ToInt();
int DeltaAcc = CountAcc - 2;
for (int i = 0; i < CountAcc; i++)
{
tree* node_acc_acc = root_data;
tree* node_acc_acc = root_data.get();
node_acc_acc = &(*node_acc_acc)[0][8][i+CountAcc-DeltaAcc][0][1][1][1][2];
String NameAcc = node_acc_acc->get_value();
accflags.push_back(std::make_unique<TAccountingFlag>(NameAcc, ""));
}

// получаем признаки учета субконто
dimaccflags.clear();
tree* node_acc_dim = root_data;
tree* node_acc_dim = root_data.get();
node_acc_dim = &(*node_acc_dim)[0][9][1]; // количество элементов
int CountAcc_dim = node_acc_dim->get_value().ToInt();
int DeltaAcc_dim = CountAcc_dim - 2;
for (int i = 0; i < CountAcc_dim; i++)
{
tree* node_acc_acc_dim = root_data;
tree* node_acc_acc_dim = root_data.get();
node_acc_acc_dim = &(*node_acc_acc_dim)[0][9][i+CountAcc_dim-DeltaAcc_dim][0][1][1][1][2];
String NameAcc_dim = node_acc_acc_dim->get_value();
dimaccflags.push_back(std::make_unique<TDimensionAccountingFlag>(NameAcc_dim, ""));
Expand All @@ -78,21 +85,21 @@ __fastcall TChartOfAccounts::TChartOfAccounts(v8catalog *_parent, const String&

// Получаем табличные части
tabulars.clear();
tree* node_att_t = root_data;
tree* node_att_t = root_data.get();
node_att_t = &(*node_att_t)[0][5][1]; // количество элементов
int CountAttTab = node_att_t->get_value().ToInt();
int DeltaTab = CountAttTab - 2;
for (int i = 0; i < CountAttTab; i++)
{
tree* node_att_tab = root_data;
tree* node_att_tab = root_data.get();
node_att_tab = &(*node_att_tab)[0][5][i+CountAttTab-DeltaTab][0][1][5][1][2];
String NameAttTab = node_att_tab->get_value();
tabulars.push_back(std::make_unique<TTabular>(NameAttTab, ""));
}

// Получаем имена форм
forms.clear();
tree* node = root_data;
tree* node = root_data.get();
node = &(*node)[0][6][0];

int CountChild = (node->get_next())->get_value().ToInt();
Expand All @@ -109,22 +116,22 @@ __fastcall TChartOfAccounts::TChartOfAccounts(v8catalog *_parent, const String&

// Получаем имена команд
comands.clear();
tree* node_att_c = root_data;
tree* node_att_c = root_data.get();

node_att_c = &(*node_att_c)[0][3][1]; // количество элементов

int CountCom = node_att_c->get_value().ToInt();
int DeltaCom = CountCom - 2;
for (int i = 0; i < CountCom; i++)
{
tree* node_com = root_data;
tree* node_com = root_data.get();
node_com = &(*node_com)[0][3][i+CountCom-DeltaCom][0][1][3][2][9][2];
String NameCom = node_com->get_value();
comands.push_back(std::make_unique<TComand>(NameCom, ""));
}
// Получаем макеты
moxels.clear();
tree* node_mox = root_data;
tree* node_mox = root_data.get();
node_mox = &(*node_mox)[0][4][0];

int CountMox = (node_mox->get_next())->get_value().ToInt();
Expand All @@ -140,8 +147,3 @@ __fastcall TChartOfAccounts::TChartOfAccounts(v8catalog *_parent, const String&
}
}

__fastcall TChartOfAccounts::~TChartOfAccounts()
{

}

21 changes: 13 additions & 8 deletions src/ChartOfAccounts.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,21 @@
#define ChartOfAccountsH
//---------------------------------------------------------------------------
#include <vector>
#include <memory>
#include "Class_1CD.h"
#include "APIcfBase.h"
#include "Parse_tree.h"
#include "MDObject.h"
#include "BaseMetadataObject.h"
#include "Requisite.h"
#include "Comand.h"
#include "Moxel.h"
#include "Tabular.h"
#include "Form.h"

class TChartOfAccounts : public TObject
class TChartOfAccounts : public BaseMetadataObject
{
public:
tree* root_data;
v8catalog* parent;

String name;
String guid;

std::vector<std::unique_ptr<TRequisite>> attributes; // список реквизитов
std::vector<std::unique_ptr<TAccountingFlag>> accflags; // список признаков учета
std::vector<std::unique_ptr<TDimensionAccountingFlag>> dimaccflags; // список признаков учета субконто
Expand All @@ -35,7 +31,16 @@ class TChartOfAccounts : public TObject
__fastcall TChartOfAccounts(v8catalog *_parent, const String& _guid);
__fastcall TChartOfAccounts(v8catalog *_parent, const String& _guid, const String& _name);

__fastcall ~TChartOfAccounts();
virtual __fastcall ~TChartOfAccounts();

// Реализация виртуальных методов BaseMetadataObject
virtual std::vector<std::unique_ptr<TRequisite>>& getAttributes() override { return attributes; }
virtual std::vector<std::unique_ptr<TComand>>& getCommands() override { return comands; }
virtual std::vector<std::unique_ptr<TMoxel>>& getLayouts() override { return moxels; }
virtual std::vector<std::unique_ptr<TTabular>>& getTabularSections() override { return tabulars; }
virtual std::vector<std::unique_ptr<TForm1C>>& getForms() override { return forms; }

virtual void __fastcall initializeFromTree() override;
};

#endif
2 changes: 2 additions & 0 deletions src/ChartOfCalculationTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ __fastcall TChartOfCalculationTypes::TChartOfCalculationTypes(v8catalog *_parent
: MetadataObjectWithSections(_parent, _guid)
{
initializeFromTree();
root_data.reset();
}

__fastcall TChartOfCalculationTypes::TChartOfCalculationTypes(v8catalog *_parent, const String& _guid, const String& _name)
: MetadataObjectWithSections(_parent, _guid, _name)
{
initializeFromTree();
root_data.reset();
}

__fastcall TChartOfCalculationTypes::~TChartOfCalculationTypes()
Expand Down
Loading
Loading