gtpc2mbqC/C++ Language Support User's Guide

TO2_addAllFrom-Add All from Source Collection

This function adds all the elements from the source collection to the target collection in the most correct way. Because this function uses either a TO2_add or TO2_atNewKeyPut function depending on the target collection type, all the rules for the two functions and the target collection are followed. For this function, the source and target do not have to be the same type.

Note:
This function does not support all collections. See Table 47 for collections that are supported for this function.

Format

#include <c$to2.h>
long TO2_addAllFrom (const TO2_PID_PTR  target_pid_ptr,
                           TO2_ENV_PTR  env_ptr,
                     const TO2_PID_PTR  source_pid_ptr);

target_pid_ptr
The pointer to the persistent identifier (PID) assigned to the target collection. The target collection must have been previously created. The target and source collections do not have to be the same collection type.

env_ptr
The pointer to the environment as returned by the TO2_createEnv function.

source_pid_ptr
The pointer to the PID of the source collection that has elements that will be added to the target collection. The source collection is unchanged.

Normal Return

The normal return is a positive value.

Error Return

An error return is indicated by a zero. When zero 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_DATA_LGH

TO2_ERROR_ENV

TO2_ERROR_LOCATOR_LGH

TO2_ERROR_METHOD

TO2_ERROR_NOT_INIT

TO2_ERROR_PID

TO2_ERROR_UPDATE_NOT_ALLOWED

TO2_ERROR_ZERO_PID

Programming Considerations

Examples

The following example adds an item to a bag collection.

  #include <c$to2.h>               /* Needed for TO2 API functions    */
  #include <stdio.h>               /* APIs for standard I/O functions */
 
  TO2_ENV_PTR    env_ptr;          /* Pointer to the TO2 environment  */
  TO2_PID        bag, bag_temp;    /*  will hold bag PIDs             */

  ·
  ·
  ·
/**********************************************************************/ /* Make sure the bags referenced by bag and bag_temp are */ /* created before arriving here.... */ /* Add all from bag to bag_temp */ /**********************************************************************/ if (TO2_addAllFrom(&bag_temp, env_ptr, &bag) == TO2_ERROR) { printf("TO2_addAllFrom failed!\n"); process_error(env_ptr); } else { printf("TO2_addAllFrom successful!\n"); }

Related Information