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

TStrings

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

Class to manage arrays or collections of strings

Declaration

Source position: classesh.inc line 428

type TStrings = class(TPersistent)

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(); virtual;

  

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

  function IndexOfObject(); virtual;

  

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.

  procedure GetNameValue();

  

Return both name and value of a name,value pair based on it's index.

  property Delimiter: Char; [rw]

  

Delimiter character used in DelimitedText.

  property DelimitedText: String; [rw]

  

Get or set all strings in the list in a delimited form.

  property QuoteChar: Char; [rw]

  

Quote character used in DelimitedText.

  property NameValueSeparator: Char; [rw]

  

Value of the character used to separate name,value pairs

  property ValueFromIndex: String; [rw]

  

  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.