-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathuStringObject.pas
More file actions
83 lines (57 loc) · 1.59 KB
/
uStringObject.pas
File metadata and controls
83 lines (57 loc) · 1.59 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
unit uStringObject;
// Ths source is distributed under Apache 2.0
// Copyright (C) 2019-2020 Herbert M Sauro
// Author Contact Information:
// email: hsauro@gmail.com
interface
uses Classes, uMemoryManager;
type
TStringObject = class (TRhodusObject)
value : string;
function isEqualTo (str1 : TStringObject) : boolean;
class function add (str1, str2 : TStringObject) : TStringObject;
function clone : TStringObject;
constructor createConstantObj (value : string);
function getSize() : integer;
constructor create (value : string);
destructor Destroy; override;
end;
implementation
function createStringObject (value : string) : TStringObject;
begin
result := TStringObject.Create (value);
end;
constructor TStringObject.createConstantObj (value : string);
begin
blockType := btConstant;
self.value := value;
end;
constructor TStringObject.Create (value : string);
begin
blockType := btGarbage;
self.value := value;
memoryList.addNode (self);
end;
destructor TStringObject.Destroy;
begin
value := '';
inherited;
end;
function TStringObject.clone : TStringObject;
begin
result := TStringObject.Create (value);
end;
function TStringObject.getSize() : integer;
begin
result := self.InstanceSize;
result := result + Length (value);
end;
function TStringObject.isEqualTo (str1 : TStringObject) : boolean;
begin
result := self.value = str1.value;
end;
class function TStringObject.add (str1, str2 : TStringObject) : TStringObject;
begin
result := TStringObject.Create (str1.value + str2.value);
end;
end.