DL Logo

CosArray Functions

CosArrayGet

Header: CosProcs.h:792

Description

Gets the specified element from an array.

Syntax

CosObj CosArrayGet(CosObj array, ASTArraySize index);

Parameters

array
The array from which an element is obtained.
index
The array element to obtain. The first element in an array has an index of zero.

Returns

The Cos object occupying the index element of array. It returns a NULL Cos object if index is outside the array bounds.

CosArrayInsert

Header: CosProcs.h:845

Description

Inserts an object into an array.

An exception is raised if the object to insert is a direct object that is already contained in another object, or if the object to insert belongs to another document.

Syntax

void CosArrayInsert(CosObj array, ASTArraySize pos, CosObj obj);

Parameters

array
The array into which the object is inserted.
pos

The location in the array to insert the object. The object is inserted before the specified location. The first element in an array has a pos of zero. If pos >= CosArrayLength(array), obj is added at the end of the array. The length of the array always increases by 1.

It is not safe to call CosArrayInsert() during a call to CosObjEnum() on that same array (for example, from within the callback procedure).

obj
The object to insert.

CosArrayIsWeakReference

Header: CosProcs.h:2113

Description

Return the state of a weak reference in an array. See CosDictIsWeakReference() for details.

Syntax

ASBool CosArrayIsWeakReference(CosObj array, ASInt32 n);

Parameters

array
An array.
n
The index of an item in the array.

Returns

Returns the value of the isWeak parameter in the most recent call to CosArraySetWeakReference() with these parameters, or false if there has been no such call.

CosArrayLength

Header: CosProcs.h:875

Description

Gets the number of elements in array.

Syntax

ASTArraySize CosArrayLength(CosObj array);

Parameters

array
IN/OUT The array for which the number of elements is determined.

Returns

The number of elements in array.

CosArrayPut

Header: CosProcs.h:819

Description

Puts the specified object into the specified location in an array. The array is extended as much as necessary and NULL objects are stored in empty slots. It sets the PDDocNeedsSave flag (see PDDocSetFlags) flag of the array object's CosDoc if array is indirect or is a direct object with an indirect composite object at the root of its container chain.

It is not safe to call CosArrayPut() during a call to CosObjEnum() on that same array (for example, from within the callback procedure), if doing so would extend the length of the array.

An exception is raised if the object to insert is a direct object that is already contained in another object, or if the object to insert belongs to another document.

Syntax

void CosArrayPut(CosObj array, ASTArraySize index, CosObj obj);

Parameters

array
The array in which obj is stored.
index
The location in array to store obj. The first element of an array has an index of zero.
obj
The Cos object to insert into array.

CosArrayRemove

Header: CosProcs.h:866

Description

Finds the first element, if any, equal to the specified object and removes it from the array. CosObjEqual() is used to determine whether an array element is equal to the specified object.

The array is compressed after removing the element. The compression is accomplished by moving each element following the deleted element to the slot with the next smaller index and decrementing the array's length by 1.

It is not safe to call CosArrayRemove() during a call to CosObjEnum() on that same dictionary (for example, from within the callback procedure).

Related Methods

Syntax

void CosArrayRemove(CosObj array, CosObj obj);

Parameters

array
The array from which obj is removed.
obj
The object to remove.

CosArrayRemoveNth

Header: CosProcs.h:1346

Description

Checks whether the position is within the array bounds, removes it from the array, moves each subsequent element to the slot with the next smaller index, and decrements the array's length by 1. It sets the dirty flag of the array object's CosDoc.

Related Methods

Syntax

void CosArrayRemoveNth(CosObj array, ASTArraySize pos);

Parameters

array
IN/OUT The CosArray from which to remove the member.
pos
IN/OUT The index for the array member to remove. Array indices start at 0.

CosArraySetWeakReference

Header: CosProcs.h:2102

Description

Establishes or removes a weak reference from an array. For a description of weak references, see CosDictSetWeakReference().

Syntax

void CosArraySetWeakReference(CosObj array, ASInt32 n, ASBool isWeak);

Parameters

array
An array.
n
The index of the element that is the weak reference. Note that the weak reference travels with the element; that is, if an item is marked as a weak reference, and an item is subsequently inserted before that item, the weak reference applies to the same element as it did previously.
isWeak
Sets a weak reference for an array.

CosNewArray

Header: CosProcs.h:255

Description

Creates and returns a new array Cos object.

Syntax

CosObj CosNewArray(CosDoc dP, ASBool indirect, ASTArraySize nElements);

Parameters

dP
The document in which the array is used.
indirect
If true, it creates the array as an indirect Cos object, and sets the document's PDDocNeedsSave flag (see PDDocSetFlags). If false, it creates the array as a direct object.
nElements
The number of elements that will be in the array. nElements is only a hint; Cos arrays grow dynamically as needed.

Returns

The newly created array Cos object.