[Overview][Constants][Types][Classes][Procedures and functions][Variables] Reference for unit 'Classes' (#fcl)

TStrings

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Class to manage arrays or collections of strings

Declaration

type TStrings = class(TPersistent)

protected

  procedure DefineProperties(); override;

  

Method to stream the contents of the string collection

  procedure Error();

  

Raises an EStringListError exception.

  function Get(); virtual; abstract;

  

Abstract read handler for the TStrings.Strings property.

  function GetCapacity; virtual;

  

Abstract Read handler for the TStrings.Capacity property.

  function GetCount; virtual; abstract;

  

Abstract read handler for the TStrings.Count property.

  function GetObject(); virtual;

  

Abstract read handler for the TStrings.Objects property.

  function GetTextStr; virtual;

  

Read handler for the TStrings.Text property.

  procedure Put(); virtual;

  

Write handler for the TStrings.Strings property.

  procedure PutObject(); virtual;

  

Write handler for the TStrings.Objects property.

  procedure SetCapacity(); virtual;

  

Write handler for the TStrings.Capacity property.

  procedure SetTextStr(); virtual;

  

Write handler for the TStrings.Text property.

  procedure SetUpdateState(); virtual;

  

Sets the update state.

public

  destructor Destroy; override;

  

Frees all strings and objects, and removes the list from memory.

  function Add(); virtual;

  

Add a string to the list

  function AddObject(); virtual;

  

Add a string and associated object to the list.

  procedure Append();

  

Add a string to the list.

  procedure AddStrings(); virtual;

  

Add contents of another stringlist to this list.

  procedure Assign(); override;

  

Assign the contents of another stringlist to this one.

  procedure BeginUpdate;

  

Mark the beginning of an update batch.

  procedure Clear; virtual; abstract;

  

Removes all strings and associated objects from the list.

  procedure Delete(); virtual; abstract;

  

Delete a string from the list.

  procedure EndUpdate;

  

Mark the end of an update batch.

  function Equals();

  

Compares the contents of two stringlists.

  procedure Exchange(); virtual;

  

Exchanges two strings in the list.

  function GetText; virtual;

  

Returns the contents as a PChar

  function IndexOf(); virtual;

  

Find a string in the list and return its position.

  function IndexOfName();

  

Finds the index of a name in the name-value pairs.

  function IndexOfObject();

  

Finds an object in the list and returns its index.

  procedure Insert(); virtual; abstract;

  

Insert a string in the list.

  procedure InsertObject();

  

Insert a string and associated object in the list.

  procedure LoadFromFile(); virtual;

  

Load the contents of a file as a series of strings.

  procedure LoadFromStream(); virtual;

  

Load the contents of a stream as a series of strings.

  procedure Move(); virtual;

  

Move a string from one place in the list to another.

  procedure SaveToFile(); virtual;

  

Save the contents of the list to a file.

  procedure SaveToStream(); virtual;

  

Save the contents of the string to a stream.

  procedure SetText(); virtual;

  

Set the contents of the list from a PChar.

  property Capacity: Integer; [rw]

  

Capacity of the list, i.e. number of strings that the list can currently hold before it tries to expand.

  property CommaText: String; [rw]

  

Contents of the list as a comma-separated string.

  property Count: Integer; [r]

  

Number of strings in the list.

  property Names: String; [r]

  

Name parts of the name-value pairs in the list.

  property Objects: TObject; [rw]

  

Indexed access to the objects associated with the strings in the list.

  property Values: String; [rw]

  

Value parts of the name-value pairs in the list.

  property Strings: String; default; [rw]

  

Indexed access to teh strings in the list.

  property Text: String; [rw]

  

Contents of the list as one big string.

  property StringsAdapter: IStringsAdapter; [rw]

  

Not implemented in Free Pascal.

end;

Inheritance

TStrings

  

Class to manage arrays or collections of strings

|

TPersistent

  

Base class for streaming system and persistent properties.

|

TObject

Description

TStrings implements an abstract class to manage an array of strings. It introduces methods to set and retrieve strings in the array, searching for a particular string, concatenating the strings and so on. It also allows an arbitrary object to be associated with each string.

It also introduces methods to manage a series of name=value settings, as found in many configuration files.

An instance of TStrings is never created directly, instead a descendent class such as TStringList should be created. This is because TStrings is an abstract class which does not implement all methods; TStrings also doesn't store any strings, this is the functionality introduced in descendents such as TStringList.

See also

TStringList

  

Standard implementation of the TStrings class.