Sign in Join
FPDoc Onlineexperiment

TStrings class

In unit Classes

Class to manage arrays or collections of strings.

Declaration

pascal
TStrings = class(TPersistent)

Inheritance

  1. TStrings
  2. TPersistent
  3. TObject

Descends from it: TCustomMemoStrings TNBBasePages TStringGridStrings TStringList TTabControlStrings TUNBPages

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 descendant 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 descendants such as TStringList.

TStrings implements the IFPObserved interface: when the stringlist is changed, a ooChanged notification is sent to all observers.

See also

Properties

UpdateCountprotected
AlwaysQuotepublicAlways quote strings in DelimitedText.
CapacitypublicCapacity of the list, i.e. number of strings that the list can currently hold before it tries to expand.
CommaTextpublicContents of the list as a comma-separated string.
CountpublicNumber of strings in the list.
DefaultEncodingpublicDefault encoding of stringlist.
DelimitedTextpublicGet or set all strings in the list in a delimited form.
DelimiterpublicDelimiter character used in DelimitedText.
EncodingpublicCurrent encoding of stringlist.
LineBreakpublicLineBreak character to use.
MissingNameValueSeparatorActionpublicWhat to do if NameValueSeparator is missing in a string.
NamespublicName parts of the name-value pairs in the list.
NameValueSeparatorpublicValue of the character used to separate name,value pairs.
ObjectspublicIndexed access to the objects associated with the strings in the list.
OptionspublicA set of - various boolean properties.
QuoteCharpublicQuote character used in DelimitedText.
SkipLastLineBreakpublicDo not add a linebreak to the last item.
TrailingLineBreakpublicAdd a linebreak to the last item.
StrictDelimiterpublicShould only the delimiter character be considered a delimiter.
StringspublicIndexed access to the strings in the list.
StringsAdapterpublicNot implemented in Free Pascal.
TextpublicContents of the list as one big string.
TextLineBreakStylepublicDetermines which line breaks to use in the Text property.
UseLocalepublicDetermines what methods are used in strings comparison.
ValueFromIndexpublicReturn the value part of a string based on it's index.
ValuespublicValue parts of the name-value pairs in the list.
WriteBOMpublicWrite BOM when writing stringlist to stream.

Methods

CompareStringsprotected
DefinePropertiesprotectedMethod to stream the contents of the string collection.
ErrorprotectedRaises an exception.
GetprotectedAbstract read handler for the property.
GetCapacityprotectedAbstract Read handler for the property.
GetCountprotectedAbstract read handler for the property.
GetObjectprotectedAbstract read handler for the property.
GetTextStrprotectedRead handler for the property.
PutprotectedWrite handler for the property.
PutObjectprotectedWrite handler for the property.
SetCapacityprotectedWrite handler for the property.
SetTextStrprotectedWrite handler for the property.
SetUpdateStateprotectedSets the update state.
DoCompareTextprotected
GetDelimitedTextprotected
SetDelimitedTextprotected
GetValueFromIndexprotected
SetValueFromIndexprotected
CheckSpecialCharsprotected
GetNextLineprotected
GetNextLinebreakprotected
CreatepublicInitializ a new TStrings instance.
DestroypublicFrees all strings and objects, and removes the list from memory.
ToObjectArraypublicReturn the objects as an array of object.
ToStringArraypublicReturn the strings as an array of string.
AddpublicAdd a string to the list.
AddObjectpublicAdd a string and associated object to the list.
AddPairpublicAdd a name-value pair.
AddStringspublicAdd contents of another stringlist to this list.
SetStringspublicReplace the strings with the passed strings.
AddTextpublicAdd text to the string list.
AddCommaTextpublicAdds a comma-separated list of strings.
AddDelimitedtextpublicAdds a separator-delimited list of strings.
AppendpublicAdd a string to the list.
AssignpublicAssign the contents of another stringlist to this one.
BeginUpdatepublicMark the beginning of an update batch.
ClearpublicRemoves all strings and associated objects from the list.
DeletepublicDelete a string from the list.
EndUpdatepublicMark the end of an update batch.
EqualspublicCompares the contents of two stringlists.
ExchangepublicExchanges two strings in the list.
ExtractNamepublicExtract the name part of a string.
FilterpublicReturn a filtered list.
FillpublicSet a range of strings in the list to the specified value.
ForEachpublicCall a callback for each string in the list.
GetEnumeratorpublicCreate an IEnumerator instance.
GetNameValuepublicReturn both name and value of a name,value pair based on it's index.
GetTextpublicReturns the contents as a PChar.
Containspublic
ContainsObjectpublic
IndexOfpublicFind a string in the list and return its position.
ContainsNamepublic
IndexOfNamepublicFinds the index of a name in the name-value pairs.
IndexOfObjectpublicFinds an object in the list and returns its index.
InsertpublicInsert a string in the list.
InsertObjectpublicInsert a string and associated object in the list.
LastIndexOfpublicReturn the index of the last occurrence of a string.
LoadFromFilepublicLoad the contents of a file as a series of strings.
LoadFromStreampublicLoad the contents of a stream as a series of strings.
MappublicCall a map routine for each string in the list.
MovepublicMove a string from one place in the list to another.
PoppublicRemove the last string of the list and return it.
ReducepublicGet a reduced value from the string list.
ReversepublicReverse the order of the strings in the list.
SaveToFilepublicSave the contents of the list to a file.
SaveToStreampublicSave the contents of the string to a stream.
ShiftpublicReturn and remove the first string in the list.
SlicepublicReturn a subrange of strings starting at a given index.
SetTextpublicSet the contents of the list from a PChar.

Inherited

From TPersistent (6)

AssignTo FPOAttachObserver FPODetachObserver FPONotifyObservers GetNamePath GetOwner

From TObject (39)

AfterConstruction BeforeDestruction CheckDisposed ClassInfo ClassName ClassNameIs ClassParent ClassType CleanupInstance DefaultHandler DefaultHandlerStr Dispatch DispatchStr Disposed DisposeOf FieldAddress Free FreeInstance GetDisposed GetHashCode GetInterface GetInterfaceByStr GetInterfaceEntry GetInterfaceEntryByStr GetInterfaceTable GetInterfaceWeak GetLastCastErrorInfo InheritsFrom InitInstance InstanceSize MethodAddress MethodName newinstance QualifiedClassName SafeCallException StringMessageTable SystemHasExtendedRTTI ToString UnitName

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.