mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 18:29:27 +02:00
+ Initial implementation
This commit is contained in:
parent
cdabf66ae1
commit
4ac979a4f0
@ -145,6 +145,7 @@ end;
|
||||
destructor TSTrings.Destroy;
|
||||
|
||||
begin
|
||||
inherited destroy;
|
||||
end;
|
||||
|
||||
|
||||
@ -152,6 +153,8 @@ end;
|
||||
Function TStrings.Add(const S: string): Integer;
|
||||
|
||||
begin
|
||||
Result:=Count;
|
||||
Insert (Count,S);
|
||||
end;
|
||||
|
||||
|
||||
@ -159,6 +162,8 @@ end;
|
||||
Function TStrings.AddObject(const S: string; AObject: TObject): Integer;
|
||||
|
||||
begin
|
||||
Result:=Add(S);
|
||||
Objects[result]:=AObject;
|
||||
end;
|
||||
|
||||
|
||||
@ -166,13 +171,18 @@ end;
|
||||
Procedure TStrings.Append(const S: string);
|
||||
|
||||
begin
|
||||
Add (S);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
Procedure TStrings.AddStrings(TheStrings: TStrings);
|
||||
|
||||
Var Runner : longint;
|
||||
|
||||
begin
|
||||
For Runner:=0 to TheStrings.Count-1 do
|
||||
self.AddObject (Thestrings[Runner],TheStrings.Objects[Runner]);
|
||||
end;
|
||||
|
||||
|
||||
@ -180,6 +190,13 @@ end;
|
||||
Procedure TStrings.Assign(Source: TPersistent);
|
||||
|
||||
begin
|
||||
If Source is TStrings then
|
||||
begin
|
||||
clear;
|
||||
AddStrings(TStrings(Source));
|
||||
exit;
|
||||
end;
|
||||
Inherited Assign(Source);
|
||||
end;
|
||||
|
||||
|
||||
@ -200,14 +217,32 @@ end;
|
||||
|
||||
Function TStrings.Equals(TheStrings: TStrings): Boolean;
|
||||
|
||||
Var Runner,Nr : Longint;
|
||||
|
||||
begin
|
||||
Result:=False;
|
||||
Nr:=Self.Count;
|
||||
if Nr<>TheStrings.Count then exit;
|
||||
For Runner:=0 to Nr-1 do
|
||||
If Strings[Runner]<>TheStrings[Runner] then exit;
|
||||
Result:=True;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
Procedure TStrings.Exchange(Index1, Index2: Integer);
|
||||
|
||||
Var
|
||||
Obj : TObject;
|
||||
Str : String;
|
||||
|
||||
begin
|
||||
Obj:=Objects[Index1];
|
||||
Str:=Strings[Index1];
|
||||
Objects[Index1]:=Objects[Index2];
|
||||
Strings[Index1]:=Strings[Index2];
|
||||
Objects[Index2]:=Obj;
|
||||
Strings[Index2]:=Str;
|
||||
end;
|
||||
|
||||
|
||||
@ -215,20 +250,35 @@ end;
|
||||
Function TStrings.GetText: PChar;
|
||||
|
||||
begin
|
||||
//!! Result:=StrNew(Pchar(Self.Text));
|
||||
end;
|
||||
|
||||
|
||||
|
||||
Function TStrings.IndexOf(const S: string): Integer;
|
||||
|
||||
|
||||
begin
|
||||
Result:=0;
|
||||
While (Result<Count) and (Strings[Result]<>S) do Result:=Result+1;
|
||||
if Result=Count then Result:=-1;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
Function TStrings.IndexOfName(const Name: string): Integer;
|
||||
|
||||
Var len : longint;
|
||||
|
||||
begin
|
||||
Result:=0;
|
||||
while (Result<Count) do
|
||||
begin
|
||||
len:=pos('=',Strings[Result])-1;
|
||||
if (len>0) and (Name=Copy(Strings[Result],1,Len)) then exit;
|
||||
inc(result);
|
||||
end;
|
||||
result:=-1;
|
||||
end;
|
||||
|
||||
|
||||
@ -236,6 +286,9 @@ end;
|
||||
Function TStrings.IndexOfObject(AObject: TObject): Integer;
|
||||
|
||||
begin
|
||||
Result:=0;
|
||||
While (Result<count) and (Objects[Result]<>AObject) do Result:=Result+1;
|
||||
If Result=Count then Result:=-1;
|
||||
end;
|
||||
|
||||
|
||||
@ -244,13 +297,20 @@ Procedure TStrings.InsertObject(Index: Integer; const S: string;
|
||||
AObject: TObject);
|
||||
|
||||
begin
|
||||
Insert (Index,S);
|
||||
Objects[Index]:=AObject;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
Procedure TStrings.LoadFromFile(const FileName: string);
|
||||
|
||||
Var TheStream : TFileStream;
|
||||
|
||||
begin
|
||||
TheStream:=TFileStream.Create(FileName,fmOpenRead);
|
||||
LoadFromStream(TheStream);
|
||||
TheStream.Free;
|
||||
end;
|
||||
|
||||
|
||||
@ -258,20 +318,33 @@ end;
|
||||
Procedure TStrings.LoadFromStream(Stream: TStream);
|
||||
|
||||
begin
|
||||
Text:=Stream.ReadAnsiString;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
Procedure TStrings.Move(CurIndex, NewIndex: Integer);
|
||||
|
||||
Var Obj : TObject;
|
||||
Str : String;
|
||||
|
||||
begin
|
||||
Obj:=Objects[CurIndex];
|
||||
Str:=Strings[CurIndex];
|
||||
Delete(Curindex);
|
||||
InsertObject(NewIndex,Str,Obj);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
Procedure TStrings.SaveToFile(const FileName: string);
|
||||
|
||||
Var TheStream : TFileStream;
|
||||
|
||||
begin
|
||||
TheStream:=TFileStream.Create(FileName,fmCreate);
|
||||
SaveToStream(TheStream);
|
||||
TheStream.Free;
|
||||
end;
|
||||
|
||||
|
||||
@ -279,6 +352,7 @@ end;
|
||||
Procedure TStrings.SaveToStream(Stream: TStream);
|
||||
|
||||
begin
|
||||
Stream.WriteAnsiString(Text);
|
||||
end;
|
||||
|
||||
|
||||
@ -462,7 +536,10 @@ begin
|
||||
end;
|
||||
{
|
||||
$Log$
|
||||
Revision 1.1 1998-05-04 14:30:12 michael
|
||||
Revision 1.2 1998-05-06 12:58:53 michael
|
||||
+ Initial implementation
|
||||
|
||||
Revision 1.1 1998/05/04 14:30:12 michael
|
||||
* Split file according to Class; implemented dummys for all methods, so unit compiles.
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user