1 | unit DataTypes;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, DbEngine, USqlDatabase;
|
---|
7 |
|
---|
8 | type
|
---|
9 | { TValueString }
|
---|
10 |
|
---|
11 | TValueString = class(TValue)
|
---|
12 | Value: string;
|
---|
13 | procedure Assign(Source: TValue); override;
|
---|
14 | function GetString: string; override;
|
---|
15 | procedure SetString(Value: string); override;
|
---|
16 | end;
|
---|
17 |
|
---|
18 | { TValueInteger }
|
---|
19 |
|
---|
20 | TValueInteger = class(TValue)
|
---|
21 | Value: Integer;
|
---|
22 | procedure Assign(Source: TValue); override;
|
---|
23 | function GetString: string; override;
|
---|
24 | procedure SetString(Value: string); override;
|
---|
25 | end;
|
---|
26 |
|
---|
27 | { TValueDateTime }
|
---|
28 |
|
---|
29 | TValueDateTime = class(TValue)
|
---|
30 | Value: TDateTime;
|
---|
31 | procedure Assign(Source: TValue); override;
|
---|
32 | function GetString: string; override;
|
---|
33 | procedure SetString(Value: string); override;
|
---|
34 | end;
|
---|
35 |
|
---|
36 | { TValueDate }
|
---|
37 |
|
---|
38 | TValueDate = class(TValueDateTime)
|
---|
39 | end;
|
---|
40 |
|
---|
41 | { TValueTime }
|
---|
42 |
|
---|
43 | TValueTime = class(TValueDateTime)
|
---|
44 | end;
|
---|
45 |
|
---|
46 | { TValueBoolean }
|
---|
47 |
|
---|
48 | TValueBoolean = class(TValue)
|
---|
49 | Value: Boolean;
|
---|
50 | procedure Assign(Source: TValue); override;
|
---|
51 | function GetString: string; override;
|
---|
52 | procedure SetString(Value: string); override;
|
---|
53 | end;
|
---|
54 |
|
---|
55 | { TValueFloat }
|
---|
56 |
|
---|
57 | TValueFloat = class(TValue)
|
---|
58 | Value: Double;
|
---|
59 | procedure Assign(Source: TValue); override;
|
---|
60 | function GetString: string; override;
|
---|
61 | procedure SetString(Value: string); override;
|
---|
62 | end;
|
---|
63 |
|
---|
64 | { TValueReference }
|
---|
65 |
|
---|
66 | TValueReference = class(TValueInteger)
|
---|
67 | end;
|
---|
68 |
|
---|
69 | { TFieldString }
|
---|
70 |
|
---|
71 | TFieldString = class(TFieldTypeSpecific)
|
---|
72 | DefaultValue: string;
|
---|
73 | procedure Assign(Source: TFieldTypeSpecific); override;
|
---|
74 | function GetValueClass: TValueClass; override;
|
---|
75 | end;
|
---|
76 |
|
---|
77 | { TFieldInteger }
|
---|
78 |
|
---|
79 | TFieldInteger = class(TFieldTypeSpecific)
|
---|
80 | Min: Integer;
|
---|
81 | Max: Integer;
|
---|
82 | DefaultValue: Integer;
|
---|
83 | procedure Assign(Source: TFieldTypeSpecific); override;
|
---|
84 | function GetValueClass: TValueClass; override;
|
---|
85 | end;
|
---|
86 |
|
---|
87 | { TFieldFloat }
|
---|
88 |
|
---|
89 | TFieldFloat = class(TFieldTypeSpecific)
|
---|
90 | Min: Double;
|
---|
91 | Max: Double;
|
---|
92 | DefaultValue: Double;
|
---|
93 | procedure Assign(Source: TFieldTypeSpecific); override;
|
---|
94 | function GetValueClass: TValueClass; override;
|
---|
95 | end;
|
---|
96 |
|
---|
97 | { TFieldDateTime }
|
---|
98 |
|
---|
99 | TFieldDateTime = class(TFieldTypeSpecific)
|
---|
100 | Min: TDateTime;
|
---|
101 | Max: TDateTime;
|
---|
102 | procedure Assign(Source: TFieldTypeSpecific); override;
|
---|
103 | function GetValueClass: TValueClass; override;
|
---|
104 | end;
|
---|
105 |
|
---|
106 | TFieldDate = class(TFieldTypeSpecific)
|
---|
107 | Min: TDate;
|
---|
108 | Max: TDate;
|
---|
109 | procedure Assign(Source: TFieldTypeSpecific); override;
|
---|
110 | function GetValueClass: TValueClass; override;
|
---|
111 | end;
|
---|
112 |
|
---|
113 | { TFieldTime }
|
---|
114 |
|
---|
115 | TFieldTime = class(TFieldTypeSpecific)
|
---|
116 | Min: TTime;
|
---|
117 | Max: TTime;
|
---|
118 | procedure Assign(Source: TFieldTypeSpecific); override;
|
---|
119 | function GetValueClass: TValueClass; override;
|
---|
120 | end;
|
---|
121 |
|
---|
122 | TFieldImage = class(TFieldTypeSpecific)
|
---|
123 | MinSize: TPoint;
|
---|
124 | MaxSize: TPoint;
|
---|
125 | end;
|
---|
126 |
|
---|
127 | { TFieldReference }
|
---|
128 |
|
---|
129 | TFieldReference = class(TFieldTypeSpecific)
|
---|
130 | TableName: string;
|
---|
131 | Id: Integer;
|
---|
132 | procedure Assign(Source: TFieldTypeSpecific); override;
|
---|
133 | function GetValueClass: TValueClass; override;
|
---|
134 | end;
|
---|
135 |
|
---|
136 | { TFieldBoolean }
|
---|
137 |
|
---|
138 | TFieldBoolean = class(TFieldTypeSpecific)
|
---|
139 | DefaultValue: Boolean;
|
---|
140 | procedure Assign(Source: TFieldTypeSpecific); override;
|
---|
141 | function GetValueClass: TValueClass; override;
|
---|
142 | end;
|
---|
143 |
|
---|
144 | TFieldMapPosition = class(TFieldTypeSpecific)
|
---|
145 | end;
|
---|
146 |
|
---|
147 |
|
---|
148 | implementation
|
---|
149 |
|
---|
150 | { TFieldReference }
|
---|
151 |
|
---|
152 | procedure TFieldReference.Assign(Source: TFieldTypeSpecific);
|
---|
153 | begin
|
---|
154 | if Source is TFieldReference then begin
|
---|
155 | Id := TFieldReference(Source).Id;
|
---|
156 | TableName := TFieldReference(Source).TableName;
|
---|
157 | end;
|
---|
158 | end;
|
---|
159 |
|
---|
160 | function TFieldReference.GetValueClass: TValueClass;
|
---|
161 | begin
|
---|
162 | Result := TValueReference;
|
---|
163 | end;
|
---|
164 |
|
---|
165 | { TFieldTime }
|
---|
166 |
|
---|
167 | procedure TFieldTime.Assign(Source: TFieldTypeSpecific);
|
---|
168 | begin
|
---|
169 | if Source is TFieldTime then begin
|
---|
170 | Min := TFieldTime(Source).Min;
|
---|
171 | Max := TFieldTime(Source).Max;
|
---|
172 | end;
|
---|
173 | end;
|
---|
174 |
|
---|
175 | function TFieldTime.GetValueClass: TValueClass;
|
---|
176 | begin
|
---|
177 | Result := TValueTime;
|
---|
178 | end;
|
---|
179 |
|
---|
180 | { TFieldDate }
|
---|
181 |
|
---|
182 | procedure TFieldDate.Assign(Source: TFieldTypeSpecific);
|
---|
183 | begin
|
---|
184 | if Source is TFieldDate then begin
|
---|
185 | Min := TFieldDate(Source).Min;
|
---|
186 | Max := TFieldDate(Source).Max;
|
---|
187 | end;
|
---|
188 | end;
|
---|
189 |
|
---|
190 | function TFieldDate.GetValueClass: TValueClass;
|
---|
191 | begin
|
---|
192 | Result := TValueDate;
|
---|
193 | end;
|
---|
194 |
|
---|
195 | { TValueFloat }
|
---|
196 |
|
---|
197 | procedure TValueFloat.Assign(Source: TValue);
|
---|
198 | begin
|
---|
199 | if Source is TValueFloat then
|
---|
200 | Value := TValueFloat(Source).Value;
|
---|
201 | end;
|
---|
202 |
|
---|
203 | function TValueFloat.GetString: string;
|
---|
204 | begin
|
---|
205 | Result := FloatToStr(Value);
|
---|
206 | end;
|
---|
207 |
|
---|
208 | procedure TValueFloat.SetString(Value: string);
|
---|
209 | begin
|
---|
210 | Self.Value := StrToFloat(Value);
|
---|
211 | end;
|
---|
212 |
|
---|
213 | { TFieldBoolean }
|
---|
214 |
|
---|
215 | procedure TFieldBoolean.Assign(Source: TFieldTypeSpecific);
|
---|
216 | begin
|
---|
217 | if Source is TFieldBoolean then begin
|
---|
218 | DefaultValue := TFieldBoolean(Source).DefaultValue;
|
---|
219 | end;
|
---|
220 | end;
|
---|
221 |
|
---|
222 | function TFieldBoolean.GetValueClass: TValueClass;
|
---|
223 | begin
|
---|
224 | Result := TValueBoolean;
|
---|
225 | end;
|
---|
226 |
|
---|
227 | { TFieldFloat }
|
---|
228 |
|
---|
229 | procedure TFieldFloat.Assign(Source: TFieldTypeSpecific);
|
---|
230 | begin
|
---|
231 | if Source is TFieldFloat then begin
|
---|
232 | DefaultValue:= TFieldFloat(Source).DefaultValue;
|
---|
233 | Min:= TFieldFloat(Source).Min;
|
---|
234 | Max:= TFieldFloat(Source).Max;
|
---|
235 | end;
|
---|
236 | end;
|
---|
237 |
|
---|
238 | function TFieldFloat.GetValueClass: TValueClass;
|
---|
239 | begin
|
---|
240 | Result := TValueFloat;
|
---|
241 | end;
|
---|
242 |
|
---|
243 | { TFieldInteger }
|
---|
244 |
|
---|
245 | procedure TFieldInteger.Assign(Source: TFieldTypeSpecific);
|
---|
246 | begin
|
---|
247 | if Source is TFieldInteger then begin
|
---|
248 | DefaultValue:= TFieldInteger(Source).DefaultValue;
|
---|
249 | Min:= TFieldInteger(Source).Min;
|
---|
250 | Max:= TFieldInteger(Source).Max;
|
---|
251 | end;
|
---|
252 | end;
|
---|
253 |
|
---|
254 | function TFieldInteger.GetValueClass: TValueClass;
|
---|
255 | begin
|
---|
256 | Result := TValueInteger;
|
---|
257 | end;
|
---|
258 |
|
---|
259 | { TValueBoolean }
|
---|
260 |
|
---|
261 | procedure TValueBoolean.Assign(Source: TValue);
|
---|
262 | begin
|
---|
263 | if Source is TValueBoolean then
|
---|
264 | Value := TValueBoolean(Source).Value;
|
---|
265 | end;
|
---|
266 |
|
---|
267 | function TValueBoolean.GetString: string;
|
---|
268 | begin
|
---|
269 | Result := BoolToStr(Value);
|
---|
270 | end;
|
---|
271 |
|
---|
272 | procedure TValueBoolean.SetString(Value: string);
|
---|
273 | begin
|
---|
274 | Self.Value := StrToBool(Value);
|
---|
275 | end;
|
---|
276 |
|
---|
277 | { TValueInteger }
|
---|
278 |
|
---|
279 | procedure TValueInteger.Assign(Source: TValue);
|
---|
280 | begin
|
---|
281 | if Source is TValueInteger then
|
---|
282 | Value := TValueInteger(Source).Value;
|
---|
283 | end;
|
---|
284 |
|
---|
285 | function TValueInteger.GetString: string;
|
---|
286 | begin
|
---|
287 | Result := IntToStr(Value);
|
---|
288 | end;
|
---|
289 |
|
---|
290 | procedure TValueInteger.SetString(Value: string);
|
---|
291 | var
|
---|
292 | IntVal: Integer;
|
---|
293 | begin
|
---|
294 | if TryStrToInt(Value, IntVal) then Self.Value := IntVal;
|
---|
295 | end;
|
---|
296 |
|
---|
297 | { TFieldDateTime }
|
---|
298 |
|
---|
299 | procedure TFieldDateTime.Assign(Source: TFieldTypeSpecific);
|
---|
300 | begin
|
---|
301 | if Source is TFieldDateTime then begin
|
---|
302 | Min := TFieldDateTime(Source).Min;
|
---|
303 | Max := TFieldDateTime(Source).Max;
|
---|
304 | end;
|
---|
305 | end;
|
---|
306 |
|
---|
307 | function TFieldDateTime.GetValueClass: TValueClass;
|
---|
308 | begin
|
---|
309 | Result := TValueDateTime;
|
---|
310 | end;
|
---|
311 |
|
---|
312 | { TValueDateTime }
|
---|
313 |
|
---|
314 | procedure TValueDateTime.Assign(Source: TValue);
|
---|
315 | begin
|
---|
316 | if Source is TValueDateTime then
|
---|
317 | Value := TValueDateTime(Source).Value;
|
---|
318 | end;
|
---|
319 |
|
---|
320 | function TValueDateTime.GetString: string;
|
---|
321 | begin
|
---|
322 | Result := DateTimeToStr(Value);
|
---|
323 | end;
|
---|
324 |
|
---|
325 | procedure TValueDateTime.SetString(Value: string);
|
---|
326 | begin
|
---|
327 | Self.Value := SQLToDateTime(Value);
|
---|
328 | // if not TryStrToDateTime(Value, Self.Value) then begin
|
---|
329 | // end;
|
---|
330 | end;
|
---|
331 |
|
---|
332 | { TValueString }
|
---|
333 |
|
---|
334 | procedure TValueString.Assign(Source: TValue);
|
---|
335 | begin
|
---|
336 | if Source is TValueString then
|
---|
337 | Value := TValueString(Source).Value;
|
---|
338 | end;
|
---|
339 |
|
---|
340 | function TValueString.GetString: string;
|
---|
341 | begin
|
---|
342 | Result := Value;
|
---|
343 | end;
|
---|
344 |
|
---|
345 | procedure TValueString.SetString(Value: string);
|
---|
346 | begin
|
---|
347 | Self.Value := Value;
|
---|
348 | end;
|
---|
349 |
|
---|
350 | { TFieldString }
|
---|
351 |
|
---|
352 | procedure TFieldString.Assign(Source: TFieldTypeSpecific);
|
---|
353 | begin
|
---|
354 | if Source is TFieldString then
|
---|
355 | DefaultValue:= TFieldString(Source).DefaultValue;
|
---|
356 | end;
|
---|
357 |
|
---|
358 | function TFieldString.GetValueClass: TValueClass;
|
---|
359 | begin
|
---|
360 | Result := TValueString;
|
---|
361 | end;
|
---|
362 |
|
---|
363 | end.
|
---|
364 |
|
---|