Previous Table of Contents Next


7.1.1 Common Data Structures


   The type NamedValue is a well-known data type in OMG IDL. It can be used either as a parameter type directly or as a mechanism for describing arguments to a request. The types are described in OMG IDL as:

   module CORBA {

   typedef unsigned long Flags;

   struct NamedValue { PIDL Identifier name; // argument name any argument; // argument long len; // length/count of argument value Flags arg_modes;// argument mode flags

   };

   };

   For out parameters, applications can set the argument member of the NamedValue structure to a value that includes either a NULL or a non-NULL storage pointer. If a non-null storage pointer is provided for an out parameter, the ORB will attempt to use the storage pointed to for holding the value of the out parameter. If the storage pointed to is not sufficient to hold the value of the out parameter, the behavior is undefined.

   A named value includes an argument name, argument value (as an any), length of the argument, and a set of argument mode flags. When named value structures are used to describe arguments to a request, the names are the argument identifiers specified in the OMG IDL definition for a specific operation.

   As described in Section 19.7, “Mapping for Basic Data Types,? on page 19-10, an any consists of a TypeCode and a pointer to the data value. The TypeCode is a well-known opaque type that can encode a description of any type specifiable in OMG IDL. See this section for a full description of TypeCodes.

   For most data types, len is the actual number of bytes that the value occupies. For object references, len is 1. Table 7-1shows the length of data values for the C language binding. The behavior of a NamedValue is undefined if the len value is inconsistent with the TypeCode.

   Table 7-1 C Type Lengths

Data type: X Length (X)
short sizeof (CORBA_short)
unsigned short sizeof (CORBA_unsigned_short)
long sizeof (CORBA_long)
unsigned long sizeof (CORBA_unsigned_long)
long long sizeof (CORBA_long_long)
unsigned long long sizeof (CORBA_unsigned_long_long)
float sizeof (CORBA_float)
double sizeof (CORBA_double)
long double sizeof (CORBA_long_double)
fixed<d,s> sizeof (CORBA_fixed_d_s)
char sizeof (CORBA_char)
wchar sizeof (CORBA_wchar)
boolean sizeof (char)
octet sizeof (CORBA_octet)
string strlen (string) /* does NOT include ‘\0’ byte! */
wstring number of wide characters in string, not including wide null terminator
enum E {}; sizeof (CORBA_enum)
union U { }; sizeof (U)
struct S { }; sizeof (S)
Object 1
array N of type T1 Length (T1) * N
sequence V of type T2 Length (T2) * V /* V is the actual, dynamic, number of elements */

   The arg_mode field is of type Flags which is an unsigned long. This field is used as follows in this structure. It should be noted that Flags type is used as parameter type in many operations and the meaning of the constants passed in those cases are specific to those operations. Those values should not be confused with the specific use of this type in the context of the NamedValue structure. These values are reserved, as are the high order 16 bits of the unsigned long.:

CORBA::ARG_IN 1 The associated value is an input only argument.
CORBA::ARG_OUT 2 The associated value is an output only argument.
CORBA::ARG_INOUT 3 The associated value is an in/out argument.

   The specific usage of Flags in other contexts are described as part of the description of the operation that uses this type of parameters.