-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfut_data.bas
More file actions
113 lines (113 loc) · 4.22 KB
/
Copy pathfut_data.bas
File metadata and controls
113 lines (113 loc) · 4.22 KB
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
112
113
Rem This file is part of the 'File Update Tool' program.
Rem Copyright (C) 2025 Ihar S. Areshchankau
Rem
Rem This program is free software: you can redistribute it and/or modify
Rem it under the terms of the GNU General Public License as published by
Rem the Free Software Foundation, either version 3 of the License, or
Rem (at your option) any later version.
Rem
Rem This program is distributed in the hope that it will be useful,
Rem but WITHOUT ANY WARRANTY; without even the implied warranty of
Rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Rem GNU General Public License for more details.
Rem
Rem You should have received a copy of the GNU General Public License
Rem along with this program. If not, see <https://www.gnu.org/licenses/>.
Rem
Rem ==================================
Rem Õðàíèëèùå äàííûõ íà îñíîâå ñòðîêè.
Rem ßçûê ïðîãðàììèðîâàíèÿ: FreeBASIC.
Rem ==================================
#include once "fut_data.bai"
Rem ==================================================
Rem Êîíñòðóêòîð õðàíèëèùà èíôîðìàöèè íà îñíîâå ñòðîêè.
Rem Âûçîâ: ChunkSize - ðàçìåð âûäåëÿåìîãî áëîêà,
Rem Separator - ðàçäåëèòåëü çàïèñåé.
Rem ==================================================
Public Constructor StringData (ByVal ChunkSize As Integer, ByRef Separator As Const String)
this.chunkSize = ChunkSize
this.separator = Separator
this.pbuf = 1
this.pcur = 1
End Constructor
Rem ========================================================
Rem Îïåðàòîð ïðèñâàèâàíèÿ õðàíèëèùà.
Rem Âûçîâ: that - õðàíèëèùå, êîòîðîå ïðèñâàèâàåòñÿ òåêóùåìó.
Rem ========================================================
Public Operator StringData.Let (ByRef that As Const StringData)
this.sbuf = that.sbuf
this.nbuf = that.nbuf
this.pbuf = that.pbuf
this.pcur = that.pcur
this.cnt = that.cnt
this.chunkSize = that.ChunkSize
this.separator = that.Separator
End Operator
Rem =======================================
Rem Ïîìåùåíèå ñòðîêè â õðàíèëèùå.
Rem Âûçîâ: s - äîáàâëÿåìàÿ ñòðîêà.
Rem Âîçâðàò: -1 - ñòðîêà äîáàâëåíà,
Rem 0 - îøèáêà äîáàâëåíèÿ ñòðîêè.
Rem =======================================
Public Function StringData.Store (ByRef s As Const String) As Integer
Dim res As Integer, l1 As Integer, l2 As Integer
Rem Ïðîâåðêà îòñóòñòâèÿ ðàçäåëèòåëÿ â äîáàâëÿåìîé ñòðîêå.
res = 0 = InStr (s, this.separator)
If -1 = res Then
Rem Ïîäãîòîâêà äîñòàòî÷íîãî ïðîñòðàíñòâà äëÿ ðàçìåùåíèÿ ñòðîêè.
l1 = Len (s) ' äëèíà äîáàâëÿåìîé ñòðîêè
l2 = Len (this.separator) ' äëèíà ðàçäåëèòåëÿ
While this.nbuf < this.pbuf + l1 + l2 - 1
this.sbuf += Space (this.chunksize)
this.nbuf += this.chunksize
Wend
Rem Ðàçìåùåíèå ñòðîêè â õðàíèëèùå è çàâåðøåíèå å¸ ðàçäåëèòåëåì.
Mid (this.sbuf, this.pbuf, l1) = s
this.pbuf += l1
Mid (this.sbuf, this.pbuf, l2) = this.separator
this.pbuf += l2
this.cnt += 1
End If
StringData.Store = res
End Function
Rem ==============================
Rem Ïîëó÷åíèå ñòðîêè èç õðàíèëèùà.
Rem Âîçâðàò: î÷åðåäíàÿ ñòðîêà.
Rem ==============================
Public Function StringData.Read As String
Dim res As String, p As Integer
If this.pcur < this.pbuf Then
p = InStr (this.pcur, this.sbuf, this.separator)
res = Mid (this.sbuf, this.pcur, p - this.pcur)
this.pcur = p + Len (this.separator)
End If
StringData.Read = res
End Function
Rem ====================================
Rem Ñáðîñ óêàçàòåëÿ íà íà÷àëî õðàíèëèùà.
Rem ====================================
Public Sub StringData.Restore
this.pcur = 1
End Sub
Rem =======================================
Rem Ïîëó÷åíèå êîëè÷åñòâà ñòðîê â õðàíèëèùå.
Rem Âîçâðàò: êîëè÷åñòâî ñòðîê â õðàíèëèùå.
Rem =======================================
Public Function StringData.Count As Integer
StringData.Count = this.cnt
End Function
Rem ======================================
Rem Óäàëåíèå âñåé èíôîðìàöèè èç õðàíèëèùà.
Rem ======================================
Public Sub StringData.Wipe
this.sbuf = ""
this.nbuf = 0
this.pbuf = 1
this.pcur = 1
this.cnt = 0
End Sub
Rem =============================================
Rem Äåñòðóêòîð õðàíèëèùà äàííûõ íà îñíîâå ñòðîêè.
Rem =============================================
Public Destructor StringData
End Destructor