Intended Usage
This method is intended to be used to reiniitalize an Any to hold a new TypeCode and data value. This method is not type-safe (no checking is done to insure that the given TypeCode actually matches the given data value.) This method is intended to be used only when the type-safe Any insertion operators cannot be used.
The replace interface mirrors the interface to Any's non-default constructor.
If the Any previously owned the value it contained, that value is deleted and the new value is stored in the Any. The TypeCode previously contained by the Any is released, and the input TypeCode is duplicated and stored in the Any. If the release parameter is nonzero, then the Any assumes ownership of the new value, and the application should make no assumptions about the continued lifetime of the value.
Syntax
void replace (CORBA::TypeCode_ptr tc, void * value, CORBA::Boolean release = 0);
Parameters
If the value is a simple type (char, octet, float, etc.), the value parameter should be a pointer to the data. If the value is a string, the value parameter should be of type char**. If the value is an object corresponding to an IDL interface (such as MyInterface), the value parameter should be of type MyInterface_ptr. If the value is a TypeCode, the value parameter should be of type CORBA::TypeCode_ptr. If the value is a constructed IDL type (struct, sequence, union), the value parameter should be a pointer to the data. If the value is an Any, the value parameter should be of type CORBA::Any*. If the value is an IDL array, the value parameter should be a pointer to the first element of the array.
Example
#include "corba.h" ... CORBA::Any any; const Val7 = 7; CORBA::ULong ul_val = Val7; /* release == > any owns value memory */ CORBA::Boolean any_owns_p = 0; /* put a Ulong into any */ any. replace(CORBA::_tc_ulong, (void*) &ul_val, any_owns_p); ...