-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresourcestack.h
111 lines (92 loc) · 3.5 KB
/
resourcestack.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*!
Copyright 2017-2019, 2021 Maxim Noltmeer (m.noltmeer@gmail.com)
This file is part of Extern Logic Interpreter.
Extern Logic Interpreter is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Extern Logic Interpreter is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Extern Logic Interpreter. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef RESOURCESTACK_H_INCLUDED
#define RESOURCESTACK_H_INCLUDED
#include <cstdlib>
#include <fstream>
#include <vector>
#include <string.h>
#include "..\work-functions\MyFunc.h"
#define UINT unsigned int
#define NUMSIZE 24
#define MAXBUF 4096 //ìàêñ. áóôåð äëÿ ÷òåíèÿ ñòðîê èç ôàéëà ðåñóðñîâ
#define FIELDSDELIM L"|" //ðàçäåëèòåëü çíà÷åíèé ïîëåé â ôàéëå ðåñóðñîâ
#define SAVEFIELDCOUNT 4 //êîë-âî ïîëåé ñòðóêòóðû RESOURCE ñîõðàíÿåìûõ â ôàéë
#define YES L"1"
#define NO L"0"
//êîíñòàíòû îïðåäåëÿþùèå ñâîéñòâî ðåñóðñà
enum {
indx = 0,
obj_cath = 1,
obj_id = 2,
prop_id = 3,
val_v = 4,
is_keep = 5,
is_save = 6
};
//ñòðóêòóðà îïðåäåëÿþùàÿ ïàðàìåòðû äëÿ âûáîðêè äëÿ ô-é SelectRes() è Aquire()
struct CONDITION
{
UINT type;
std::wstring value;
};
struct RESOURCE
{
UINT Index; //èíäåêñ
std::wstring ObjectCathegory; //êàòåãîðèÿ îáúåêòà-âëàäåëüöà
std::wstring ObjectID; //ID îáúåêòà-âëàäåëüöà
std::wstring PropertyID; //ID ñâîéñòâà
std::wstring Value; //çíà÷åíèå
std::wstring KeepInStack; //õðàíèòü ðåñóðñ â ñòåêå ïîñëå êîìïàêòà
std::wstring SaveInFile; //ñîõðàíÿòü ëè çíà÷åíèå ðåñóðñà â ôàéë íà äèñêå
};
typedef std::vector<std::wstring> (StrList);
//îïðåäåëåíèå äëÿ íàáîðà óêàçàòåëåé íà ðåñóðñû ñòåêà
typedef std::vector<RESOURCE*> (RESRECORDSET);
class RESOURCESTACK
{
private:
UINT next_id;
std::vector<RESOURCE> Stack;
UINT GetNextID();
//äåëàåò âûáîðêó èç ñòåêà ðåñóðñîâ ïî îïðåäåëåííîìó çíà÷åíèþ, âîçâðàùàåò âåêòîð óêàçàòåëåé
//íà òå ýëåìåíòû, êîòîðûå óäîâëåòâîðÿþò àðãóìåíòó value
RESRECORDSET SelectRes(CONDITION cond);
//óòî÷íÿåò âûáîðêó èç ô-èè SelectRes ïî çíà÷åíèþ value, âîçâðàùàåò âåêòîð óêàçàòåëåé
RESRECORDSET Aquire(RESRECORDSET source, CONDITION cond);
//âûãðóæàåò â ñïèñîê òîëüêî òå ðåñóðñû, ó êîòîðûõ SaveInFile = 1
StrList *ExportStrings();
StrList *ExportStrings(std::wstring cath);
public:
RESOURCESTACK();
RESOURCESTACK(const wchar_t *filename);
virtual ~RESOURCESTACK();
UINT StackSize();
const wchar_t *StackInString();
//äåëàåò âûáîðêó ðåñóðñîâ ïî çàäàíîìó íàáîðó óñëîâèé
RESRECORDSET Get(std::vector<CONDITION> *conditions);
RESRECORDSET Get(UINT type, std::wstring val);
RESRECORDSET Get(std::wstring obj_name, std::wstring prop_name);
std::vector<int> *Get(UINT type, const wchar_t *val);
int Add(RESOURCE newres);
int Delete(std::wstring ObjectCathegory, std::wstring ObjectID, std::wstring ResourceID);
int Delete(UINT index);
int CreateResFile(const wchar_t *filepath, bool overwrite);
int CreateResFile(const wchar_t *filepath, const wchar_t *res_cath);
int LoadResFile(const wchar_t *filepath);
void Compact();
void Clear();
};
#endif // RESOURCESTACK_H_INCLUDED