source: ObjectBaseTypes/Level 2/UObjectString.pas

Last change on this file was 14, checked in by george, 15 years ago
  • Upraveno: Rozšíření sady tříd objektových typů.
File size: 2.4 KB
Line 
1unit UObjectString;
2
3interface
4
5uses
6 SysUtils, UObjectTypeBase, UObjectBoolean, UObjectInteger, StrUtils;
7
8type
9 TString = class(TInterfacedObject, IAssignable, IComparable)
10 Value: string;
11 procedure Assign(Source: TInterfacedObject);
12 function EqualTo(Operand: IComparable): TBoolean;
13 function HigherThen(Operand: TInterfacedObject): TBoolean;
14 function LowerThan(Operand: TInterfacedObject): TBoolean;
15 function Length: TInteger;
16 procedure UpperCase;
17 procedure LowerCase;
18 procedure Delete(Index: TInteger; Count: TInteger);
19 procedure Insert(Index: TInteger; SubString: TString);
20 function Pos(SubString: TString): TInteger;
21 procedure Reverse;
22 function LeftString(Count: TInteger): TString;
23 function RightString(Count: TInteger): TString;
24 end;
25
26implementation
27
28{ TString }
29
30procedure TString.Assign(Source: TInterfacedObject);
31begin
32
33end;
34
35procedure TString.Delete(Index, Count: TInteger);
36begin
37 System.Delete(Value, Index.Value, Count.Value);
38end;
39
40function TString.EqualTo(Operand: IComparable): TBoolean;
41begin
42 if TInterfacedObject(Operand) is TString then begin
43 Result := TBoolean.Create;
44 Result.Value := Value = TString(Operand).Value;
45 end else raise EInvalidCast.Create('Typecast error.');
46end;
47
48function TString.HigherThen(Operand: TInterfacedObject): TBoolean;
49begin
50
51end;
52
53procedure TString.Insert(Index: TInteger; SubString: TString);
54begin
55 System.Insert(SubString.Value, Value, Index.Value);
56end;
57
58function TString.LeftString(Count: TInteger): TString;
59begin
60 Result := TString.Create;
61 Result.Value := StrUtils.LeftStr(Value, Count.Value);
62end;
63
64function TString.Length: TInteger;
65begin
66 Result.Value := System.Length(Value);
67end;
68
69procedure TString.LowerCase;
70begin
71 Value := SysUtils.LowerCase(Value);
72end;
73
74function TString.LowerThan(Operand: TInterfacedObject): TBoolean;
75begin
76
77end;
78
79function TString.Pos(SubString: TString): TInteger;
80begin
81 Result := TInteger.Create;
82 Result.Value := System.Pos(SubString.Value, Value);
83end;
84
85procedure TString.Reverse;
86begin
87 Value := StrUtils.ReverseString(Value);
88end;
89
90function TString.RightString(Count: TInteger): TString;
91begin
92 Result := TString.Create;
93 Result.Value := StrUtils.RightStr(Value, Count.Value);
94end;
95
96procedure TString.UpperCase;
97begin
98 Value := SysUtils.UpperCase(Value);
99end;
100
101
102end.
Note: See TracBrowser for help on using the repository browser.