gtpc2me2 | C/C++ Language Support User's Guide |
This function retrieves a pointer to a string that identifies the type of the collection.
Format
#include <c$to2.h> char * TO2_getCollectionType (const TO2_PID_PTR pid_ptr, TO2_ENV_PTR env_ptr);
Normal Return
The normal return is a pointer to a C string, TYPE is the type of the collection and CODE is the string returned:
Error Return
An error return is indicated by a NULL pointer. When a NULL pointer is returned, use the TO2_getErrorCode function to determine the specific error code. For more information, see Error Handling.
The following error codes are common for this function:
TO2_ERROR_ENV
TO2_ERROR_METHOD
TO2_ERROR_PID
TO2_ERROR_ZERO_PID
Programming Considerations
This function does not use TPF transaction services on behalf of the caller.
Examples
The following example retrieves a string-identifier type for the specified TPFCS collection.
#include <c$to2.h> /* TO2 API function prototypes */ #include <string.h> /* strcmp() */ #include <stdio.h> /* APIs for standard I/O functions */ void processVariousCollectionTypes (TO2_ENV_PTR env_ptr, TO2_PID_PTR pid_ptr) { char *objecttype = TO2_getCollectionType(pid_ptr, env_ptr); if (objecttype = NULL) { printf("TO2_getCollectionType failed!\n"); process_error(env_ptr); } else { if (strcmp(objecttype, "ARRAY") == 0) { /* Processing for ARRAY type collection */ } else if (strcmp(objecttype, "BAG") == 0) { /* Processing for BAG type collection */ } else if (strcmp(objecttype, "BYTEARRAY") == 0) { /* Processing for BLOB type collection */ }
·
·
·
printf("TO2_getCollectionType successful!-n"); } }
Related Information