TROArray

Overview

TROArray forms the base class for all array types defined in your library.

Use Case

You will usually not instantiate instances of this class itself, but use the descendant classes that will be auto-generated in your _Intf unit for every array defined in your RODL file. These descendant classes will contain strongly-typed properties and methods to access the array elements as defined in your RODL.

Location

 

constructor Create  reintroduce overload virtual    (declared in TROComplexType)

Creates a new instance.

constructor Create

constructor Create (TCollection)  overload override    (declared in TROComplexType)

Creates a new instance with given parameter.

constructor Create(aCollection: TCollection)

Parameters:

  • aCollection: collection

Assign  override

Copies data from a given source.

procedure Assign(iSource: TPersistent)

Parameters:

  • iSource: Instance whose properties will be copied

AssignTo  override    (declared in TROComplexType)

Copies the properties of an object to a destination object.

procedure AssignTo(iDest: TPersistent)

Parameters:

  • iDest: destination object.

Clear  virtual abstract

Empties the entire array and sets its size to zero. If the elements of the array are structs, binaries or other arrays, they will be freed before the array is cleared.

procedure Clear

Clone

Will create and return a second copy of the Array. The new instance will be a deep copy of the original array; if the members are structs, binaries or arrays themselves, they too will be duplicated as part of the cloning process, so that the new instance and its members will be completely independent of the original class.

function Clone: TROArray

ContentAsString    (declared in TROComplexType)

Returns the structure of the type in a string format.

property ContentAsString: string read write

ContentAsXml    (declared in TROComplexType)

Returns the XML structure of the type in a string format.

property ContentAsXml: ROUTF8String read write

Count

Contains the count of elements in the array.

property Count: integer read write

Delete  virtual abstract

Deletes the i-th element of the array. If it is struct, binary or other array, it will be freed before the element is deleted.

procedure Delete(Index: integer)

Parameters:

  • Index: Index

FieldCount    (declared in TROComplexType)

property FieldCount: integer read write

FieldInfo    (declared in TROComplexType)

property FieldInfo[Index: integer]: PTypeInfo read write

FieldName    (declared in TROComplexType)

property FieldName[Index: integer]: string read write

FreeInternalProperties  protected virtual    (declared in TROComplexType)

procedure FreeInternalProperties

GetAttributeCount  virtual    (declared in TROComplexType)

Returns the number of custom attributes defined for the class.

class function GetAttributeCount: Integer

GetAttributeName  virtual    (declared in TROComplexType)

Returns the name of custom attribute defined for the class, with the specified index.

class function GetAttributeName(aIndex: Integer): string

Parameters:

  • aIndex: The index of attribute.

GetAttributeValue  virtual    (declared in TROComplexType)

Returns the value of custom attribute defined for the class, with the specified index.

class function GetAttributeValue(aIndex: Integer): string

Parameters:

  • aIndex: The index of attribute.

GetContentAsXml  protected    (declared in TROComplexType)

Returns the xml structure of the struct in a string format.

function GetContentAsXml: ROUTF8String

GetContentAsXml2  protected override

procedure GetContentAsXml2(const aXMLNode: IUnknown)

Parameters:

  • aXMLNode:

GetFieldNames    (declared in TROComplexType)

procedure GetFieldNames(aList: TStrings)

Parameters:

  • aList:

GetFieldValue    (declared in TROComplexType)

function GetFieldValue(const aFieldName: string): Variant

Parameters:

  • aFieldName:

GetIndex (string, Variant, integer, TROSearchOptions): integer  overload virtual

Searches for an item with a aPropertyName property, which is accessible via |GetPropValue and is equal to aPropertyValue. Returns the index of the first item found or -1.

function GetIndex(const aPropertyName: string; const aPropertyValue: Variant; StartFrom: integer; Options: TROSearchOptions): integer

Parameters:

  • aPropertyName: Name of the published property
  • aPropertyValue: Value of the property
  • StartFrom: Item index to start from
  • Options: Set of TROSearchOption

GetItemClass  virtual

Returns item class for non-simple arrays

class function GetItemClass: TClass

GetItemRef  virtual abstract

Returns the pointer to the array element specified by the index.

function GetItemRef(Index: integer): pointer

Parameters:

  • Index: Item position

GetItemSize  virtual abstract

Returns the size of the data type stored in the array.

class function GetItemSize: integer

GetItemType  virtual abstract

Returns TypeInfo of the data type stored in the array.

class function GetItemType: PTypeInfo

ReadComplex  override

Deserializes current class instance using provided serializer.

procedure ReadComplex(ASerializer: TObject)

Parameters:


Resize

Resizes the array to the specified size.

Since arrays are not a very dynamic data structure, repeatedly adding single elements can be a costly procedure, since memory needs to be reallocated for the grown array with each addittion. If the final size of the array is known in advance, it will perform better if you size it to the proper count in advance, and then simply fill the new vacancies.

procedure Resize(ElementCount: integer)

Parameters:

  • ElementCount: new size

Search (string, Variant, integer, TROSearchOptions): TCollectionItem  overload

Searches item with specified properties

function Search(const aPropertyName: string; const aPropertyValue: Variant; StartFrom: integer; Options: TROSearchOptions): TCollectionItem

Parameters:

  • aPropertyName: property name
  • aPropertyValue: property value
  • StartFrom: index
  • Options: options

SetFieldValue    (declared in TROComplexType)

procedure SetFieldValue(const aFieldName: string; const aValue: Variant)

Parameters:

  • aFieldName:
  • aValue:

SetItemRef  virtual

MUST be overwritten for arrays of non-simple types.

procedure SetItemRef(Index: integer; Ref: pointer)

Parameters:

  • Index: Item position
  • Ref: Reference to object

SmartAssign    (declared in TROComplexType)

Copies specific data from a given source.

procedure SmartAssign(Source: TPersistent; TypeKinds: TTypeKinds)

Parameters:

  • Source: Instance whose properties will be copied
  • TypeKinds: Specifies which properties should be copied

TryGetAttribute    (declared in TROComplexType)

class function TryGetAttribute(aName: string; out aValue: string): Boolean

Parameters:

  • aName:
  • aValue:

WriteComplex  override

Serializes current class instance using provided serializer.

procedure WriteComplex(ASerializer: TObject)

Parameters:

 

ContentAsString    (declared in TROComplexType)

Returns the structure of the type in a string format.

property ContentAsString: string read write

ContentAsXml    (declared in TROComplexType)

Returns the XML structure of the type in a string format.

property ContentAsXml: ROUTF8String read write

Count

Contains the count of elements in the array.

property Count: integer read write

FieldCount    (declared in TROComplexType)

property FieldCount: integer read write

FieldInfo    (declared in TROComplexType)

property FieldInfo[Index: integer]: PTypeInfo read write

FieldName    (declared in TROComplexType)

property FieldName[Index: integer]: string read write

 

GetAttributeCount  virtual    (declared in TROComplexType)

Returns the number of custom attributes defined for the class.

class function GetAttributeCount: Integer

GetAttributeName  virtual    (declared in TROComplexType)

Returns the name of custom attribute defined for the class, with the specified index.

class function GetAttributeName(aIndex: Integer): string

Parameters:

  • aIndex: The index of attribute.

GetAttributeValue  virtual    (declared in TROComplexType)

Returns the value of custom attribute defined for the class, with the specified index.

class function GetAttributeValue(aIndex: Integer): string

Parameters:

  • aIndex: The index of attribute.

GetItemClass  virtual

Returns item class for non-simple arrays

class function GetItemClass: TClass

GetItemSize  virtual abstract

Returns the size of the data type stored in the array.

class function GetItemSize: integer

GetItemType  virtual abstract

Returns TypeInfo of the data type stored in the array.

class function GetItemType: PTypeInfo

TryGetAttribute    (declared in TROComplexType)

class function TryGetAttribute(aName: string; out aValue: string): Boolean

Parameters:

  • aName:
  • aValue:

 

constructor Create  reintroduce overload virtual    (declared in TROComplexType)

Creates a new instance.

constructor Create

constructor Create (TCollection)  overload override    (declared in TROComplexType)

Creates a new instance with given parameter.

constructor Create(aCollection: TCollection)

Parameters:

  • aCollection: collection

Assign  override

Copies data from a given source.

procedure Assign(iSource: TPersistent)

Parameters:

  • iSource: Instance whose properties will be copied

AssignTo  override    (declared in TROComplexType)

Copies the properties of an object to a destination object.

procedure AssignTo(iDest: TPersistent)

Parameters:

  • iDest: destination object.

Clear  virtual abstract

Empties the entire array and sets its size to zero. If the elements of the array are structs, binaries or other arrays, they will be freed before the array is cleared.

procedure Clear

Clone

Will create and return a second copy of the Array. The new instance will be a deep copy of the original array; if the members are structs, binaries or arrays themselves, they too will be duplicated as part of the cloning process, so that the new instance and its members will be completely independent of the original class.

function Clone: TROArray

Delete  virtual abstract

Deletes the i-th element of the array. If it is struct, binary or other array, it will be freed before the element is deleted.

procedure Delete(Index: integer)

Parameters:

  • Index: Index

FreeInternalProperties  protected virtual    (declared in TROComplexType)

procedure FreeInternalProperties

GetContentAsXml  protected    (declared in TROComplexType)

Returns the xml structure of the struct in a string format.

function GetContentAsXml: ROUTF8String

GetContentAsXml2  protected override

procedure GetContentAsXml2(const aXMLNode: IUnknown)

Parameters:

  • aXMLNode:

GetFieldNames    (declared in TROComplexType)

procedure GetFieldNames(aList: TStrings)

Parameters:

  • aList:

GetFieldValue    (declared in TROComplexType)

function GetFieldValue(const aFieldName: string): Variant

Parameters:

  • aFieldName:

GetIndex (string, Variant, integer, TROSearchOptions): integer  overload virtual

Searches for an item with a aPropertyName property, which is accessible via |GetPropValue and is equal to aPropertyValue. Returns the index of the first item found or -1.

function GetIndex(const aPropertyName: string; const aPropertyValue: Variant; StartFrom: integer; Options: TROSearchOptions): integer

Parameters:

  • aPropertyName: Name of the published property
  • aPropertyValue: Value of the property
  • StartFrom: Item index to start from
  • Options: Set of TROSearchOption

GetItemRef  virtual abstract

Returns the pointer to the array element specified by the index.

function GetItemRef(Index: integer): pointer

Parameters:

  • Index: Item position

ReadComplex  override

Deserializes current class instance using provided serializer.

procedure ReadComplex(ASerializer: TObject)

Parameters:


Resize

Resizes the array to the specified size.

Since arrays are not a very dynamic data structure, repeatedly adding single elements can be a costly procedure, since memory needs to be reallocated for the grown array with each addittion. If the final size of the array is known in advance, it will perform better if you size it to the proper count in advance, and then simply fill the new vacancies.

procedure Resize(ElementCount: integer)

Parameters:

  • ElementCount: new size

Search (string, Variant, integer, TROSearchOptions): TCollectionItem  overload

Searches item with specified properties

function Search(const aPropertyName: string; const aPropertyValue: Variant; StartFrom: integer; Options: TROSearchOptions): TCollectionItem

Parameters:

  • aPropertyName: property name
  • aPropertyValue: property value
  • StartFrom: index
  • Options: options

SetFieldValue    (declared in TROComplexType)

procedure SetFieldValue(const aFieldName: string; const aValue: Variant)

Parameters:

  • aFieldName:
  • aValue:

SetItemRef  virtual

MUST be overwritten for arrays of non-simple types.

procedure SetItemRef(Index: integer; Ref: pointer)

Parameters:

  • Index: Item position
  • Ref: Reference to object

SmartAssign    (declared in TROComplexType)

Copies specific data from a given source.

procedure SmartAssign(Source: TPersistent; TypeKinds: TTypeKinds)

Parameters:

  • Source: Instance whose properties will be copied
  • TypeKinds: Specifies which properties should be copied

WriteComplex  override

Serializes current class instance using provided serializer.

procedure WriteComplex(ASerializer: TObject)

Parameters:

See Also