Reads the specified elements from the specified aggregate and store the result as a memory buffer in the calling application.
The space required to hold the memory buffer and optionally the <elementsValueSet> array are allocated by the operation and should be released by the caller when appropriate by invoking the edmiFree operation.
The memory buffer will be an array of the <elementType> data type, i.e., an array of SdaiInteger, SdaiReal, SdaiString, SdaiInstance, SdaiAggr, SdaiBoolean, SdaiLogical, SdaiBinary, SdaiEnumeration or SdaiSelect.
Related functions: edmiWriteAggrElements, edmiGetAggrElement, edmiFindAggrElements
Header:
#include "sdai.h"
Prototype:
EdmiError edmiReadAggrElements(SdaiAggr aggrId,
SdaiInteger firstElementIndex,
SdaiInteger maxElementsToRead,
SdaiInteger *actualElementsRead,
SdaiPrimitiveType *elementType,
SdaiBoolean **elementsValueSet,
void **dataAddress);
Arguments:
aggrId |
A numeric aggregateID that uniquely identifies the aggregate of interest in the EDMdatabase. |
firstElementIndex |
Specifies the index of the first aggregate element to read. The legal index range for all aggregate types are: |
maxElementsToRead |
Specifies max number of elements to read. |
actualElementsRead |
Address of a SdaiInteger variable that receives the actual number of elements read. |
elementType |
Address of a SdaiPrimitiveType variable that receives the data type (primitive type) of the elements in the memory buffer. |
elementsValueSet |
Address of a SdaiBoolean array. The index range of this array is: |
dataAddress |
Address of a void* variable that receives the address of the returned memory buffer. This address should be used as the argument in the edmiFree operation to release the virtual memory holding the memory buffer. |
Returns:
A completion code of datatype EdmiError is the returned function value. The completion code has the following values:
Completion code = 0 : Operation successfully performed.
Completion code != 0: Error in operation. Completion code is an EDMinterface error code. Use edmiGetErrorText to get the error text corresponding to the error code.
EXAMPLE
EdmiError rstat;
SdaiAggr aggrId;
SdaiInteger firstElementIndex,maxElementsToRead,actualElementsRead;
SdaiPrimitiveType elementType;
SdaiBoolean *elementsValueSet;
SdaiString *p,*dataAddress;
int i;
. . .
firstElementIndex = 0;
maxElementsToRead = 1000;
if (rstat = edmiReadAggrElements (aggrId,
firstElementIndex,
maxElementsToRead,
&actualElementsRead,
&elementType,
&elementsValueSet,
(void *) &dataAdress)) {
/* Error in operation */
printf("\nError: %s in edmiReadAggrElements\n",
edmiGetErrorText(rstat));
goto error;
}
/* Expecting a memory buffer of SdaiString data type */
if (elementType == sdaiSTRING) {
/* Print out the returned strings */
p = dataAdress;
for (i = 0; i < actualElementsRead; i++) {
printf("\n%s",*p);
++p;
}
}
edmiFree(dataAddress);
. . .