![]() |
Overview Replaces the data value and TypeCode held by an Any. Original class CORBA::Any
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.
IDL Syntax
void replace (CORBA::TypeCode_ptr tc, void * value, CORBA::Boolean release = 0);
Parameters
- tc
- The TypeCode describing the value parameter. The Any duplicates this TypeCode, so the caller retained ownership of the input TypeCode.
- value
- The new data to be stored in the Any. The type of this data must be described by the tc parameter. This parameter can be NULL.
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.
- release
- Specifies whether the Any should assume ownership of the value parameter (whether the value should be deallocated when the Any is released). Default is zero (meaning that the Any does not assume ownership of the value).
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); ...
Related reference... | |
CORBA module in Object Request Broker | |
Parent: CORBA module: Any Class | |
Any::_nil | |
Any::operator<< | |
Any::operator>> | |
Any::type | |