mcTBextK, mcTBextI, mcTBextE, mcTBextC, mcTBextF, mcTBextZ, mcTBextArrayK, mcTBextArrayI, mcTBextArrayJ, mcTBextArrayE, mcTBextArrayC, mcTBextArrayF, mcTBextArrayZ — Extract data from relational table
The mcTBext
functions extract data from a
relational table to memory. mcTBextK
and
mcTBextArrayK
extract a string from the
relational table (the string is NULL-terminated and thus implicitly
dimensioned). mcTBextI
and
mcTBextArrayI
extract
mcInt32
data from the relational table.
mcTBextJ
and mcTBextArrayJ
extract mcInt64
data from the relational table.
mcTBextE
and mcTBextArrayE
extract mcFloat32
data from the relational table.
mcTBextC
and mcTBextArrayC
extract mcComplexFloat32
data from the relational
table. mcTBextF
and
mcTBextArrayF
extract
mcFloat64
data from the relational table.
mcTBextZ
and mcTBextArrayZ
extract mcComplexFloat64
data from the relational
table.
If completed successfully, the dynamic data allocation version
returns a pointer to a new array containing the requested data and
the array version returns the error status. On failure,
NULL
is returned and the error code can be
retrieved by the function mcErrStatus
. A warning
is issued if the key has not been found, i.e the status is set to a
positive value.
Note that data allocated by the dynamic data allocation
version of mcTBext
must be released with the
function mcDBfree
.
Note that there are two versions of the extraction functions, a pointer version and an array version. The pointer version is safe, since MemCom allocates the correct space for the key. The array version is controlled by the application, i.e the application must make sure that the proper space has been allocated for the key to be extracted. The array version is slightly faster.
#include <memcom.h> char* mcTBextK(const char* key, mcRTable* rt); mcInt32* mcTBextI(const char* key, int* nelem, mcRTable* rt); mcInt64* mcTBextJ(const char* key, int* nelem, mcRTable* rt); mcFloat32* mcTBextE(const char* key, int* nelem, mcRTable* rt); mcComplexFloat32* mcTBextC(const char* key, int* nelem, mcRTable* rt); mcFloat64* mcTBextF(const char* key, int* nelem, mcRTable* rt); mcComplexFloat64* mcTBextZ(const char* key, int* nelem, mcRTable* rt);
key
Keyword assigned to data to be extracted (input).
nelem
Number of elements of array to be extracted (input,
output). If set to 0, the whole array will be loaded and the
effective number of elements will be returned in
nelem
. If mcTBext
fails, nelem
remains unchanged if it has
been set to 0 by the calling program.
rt
Pointer to relational table in memory (input).
#include <memcom.h> int mcTBextArrayK(const char* key, char* array, int* nelem, mcRTable* rt); int mcTBextArrayI(const char* key, mcInt32* array, int* nelem, mcRTable* rt); int mcTBextArrayJ(const char* key, mcInt64* array, int* nelem, mcRTable* rt); int mcTBextArrayE(const char* key, mcFloat32* array, int* nelem, mcRTable* rt); int mcTBextArrayC(const char* key, mcComplexFloat32* array, int* nelem, mcRTable* rt); int mcTBextArrayF(const char* key, mcFloat64* array, int* nelem, mcRTable* rt); int mcTBextArrayZ(const char* key, mcComplexFloat64* array, int* nelem, mcRTable* rt);
key
Keyword assigned to data to be extracted (input).
array
Address of array to store the extracted data (input).
The array has to be allocated by the calling function and it
must be large enough to store nelem
elements of the current type.
nelem
Number of elements of array to be extracted (input,
output). If set to 0, the whole array will be loaded and the
effective number of elements will be returned in
nelem
. If mcTBext
fails, nelem
remains unchanged if it has
been set to 0 by the calling program.
rt
Pointer to relational table in memory (input).