TROStrings

Overview

The TROStrings class wraps the access to a Delphi TStrings instance to provide a reference-counted, interface-based reference that can be freed automatically as it goes out of scope. TROStrings exposes all the basic methods and properties of TStrings, but also exposes the underlying wrapped object via the Strings property.

Location

  • Unit: uROStrings.pas
  • Ancestry: TInterfacedObject | TROStrings

Implements

Instance Methods


constructor Create  overload

Creates a new instance.

constructor Create

constructor Create (TStrings, boolean)  overload virtual

Creates a new instance and determines whether it has own list; otherwise it will be referenced to aList.

constructor Create(aList: TStrings; OwnsList: boolean)

Parameters:

  • aList: String list that should be used as initial values.
  • OwnsList: Specifies whether the string list owns the objects it contains.

constructor CreateCopy (TStrings)  overload virtual

Creates a new instance and fill it with values from aList

constructor CreateCopy(aList: TStrings)

Parameters:

  • aList: String list that will be copied.

Add  protected

Adds a string to the list and returns the index of the new string.

function Add(const aString: string): integer

Parameters:

  • aString: string that should be inserted.

AddObject  protected

Adds a string to the list and associates an object with the string. It returns the index of the new string and object.

function AddObject(const aString: string; aObject: TObject): Integer

Parameters:

  • aString: string that should be inserted.
  • aObject: object that should be inserted.

AddStrings  protected

Adds a group of strings to the list.

procedure AddStrings(aList: TStrings)

Parameters:

  • aList: a group of strings

Clear  protected

Deletes all the strings from the list. All references to associated objects are also removed. However, the objects themselves are not freed.

procedure Clear

CustomSort  protected

Sorts the strings in the list for which the sort order is defined by the Compare parameter.

procedure CustomSort(Compare: TStringListSortCompare)

Parameters:

  • Compare: function for comparing.

Delete  protected

Deletes a specified string from the list.

procedure Delete(Index: integer)

Parameters:

  • Index: position

ExtractValue  protected

Returns the string associated with the given name and deletes it from the list, on strings that are name-value pairs.

function ExtractValue(const aName: string): string

Parameters:

  • aName: the given name

Find  protected

Locates the index for a string in a sorted list.

function Find(const aString: string): integer

Parameters:

  • aString: the given string

IndexOf  protected

Returns the position of a string in the list.

function IndexOf(const aString: string): integer

Parameters:

  • aString: string whose index will be returned.

IndexOfName  protected

Returns the position of the first name-value pair with the specified name.
IndexOfName returns the 0-based index of the string. If no string in the list has the indicated name, IndexOfName returns -1.
Note: If there is more than one name-value pair with a name portion matching the aName parameter, IndexOfName returns the position of the first string found.

function IndexOfName(const aName: string): integer

Parameters:

  • aName: specified name

Insert  protected

Inserts the string S into the list at the position specified by the Index. If Index is 0, the string is inserted at the beginning of the list. If Index is 1, the string is put in the second position of the list, and so on.

procedure Insert(Index: Integer; const S: string)

Parameters:

  • Index: position
  • S: string that should be inserted

InsertObject  protected

Inserts the string S into the list at the position identified by the Index, and associates it with the object AObject.

procedure InsertObject(Index: Integer; const S: string; AObject: TObject)

Parameters:

  • Index: position
  • S: string that should be inserted
  • AObject: object that should be inserted

RenameName  protected

Sets a new name for name-value pairs specified in aName parameter. This function is useful when you want to change a register of some letters.

function RenameName(const aName: string): boolean

Parameters:

  • aName: a new name

See Also

IROStrings