MICO: An Open Source CORBA Implementation

This chapter features some highlights of the IDL to C++ mapping. Sometimes we just quote facts from the CORBA standard; sometimes we describe details that are specific to MICO. Generally, we encourage using the CORBA standard as a second source. Although it certainly does not replace a good CORBA textbook, it provides invaluable details often missing in other publications.
The following sections do not cover the complete IDL to C++ mapping. Instead, we focus on some details that are often not well explained. We already assume some familiarity with the IDL to C++ mapping.
Strings have always been a source of confusion. The CORBA standard adopts a mapping for strings for the C++ language that is not necessarily intuitive. Bounded and unbounded strings are always mapped to char* in C++. String data is null terminated. In addition, the CORBA namespace defines a helper class String_var that contains a char* value and automatically frees the pointer when a String_var object is deallocated. When a String_var is constructed or assigned from a char*, the char* is consumed and thus the string data may no longer be accessed through it. Assignment or construction from a const char* or from another String_var causes the string to be copied.
For dynamic allocation of strings, compliant programs must use the following functions from the CORBA namespace:
1: // C++2: namespace CORBA {<a name="198"></a><a name="IDX-98"></a>3: char *string_alloc( ULong len );4: char...