Previous | Table of Contents | Next |
CORBA currently defines the data type string to represent strings that consist of 8-bit quantities, which are NULL-terminated.
Microsoft IDL and ODL define a number of different data types, which are used to represent both 8-bit character strings and
strings containing wide characters based on Unicode.
Table 18-2 illustrates how to map the string data types in OMG IDL to their
corresponding data types in both Microsoft IDL and ODL.
Table 18-2 OMG IDL to Microsoft IDL/ODL String Mappings
OMG IDL |
Microsoft IDL |
Microsoft ODL |
Description |
||
string | LPSTR [string,unique] char * | LPSTR | Null-terminated 8-bit character string | ||
wstring | LPWSTR [string,unique] wchar t * | LPWSTR | Null-terminated Unicode string |
OMG IDL supports two different types of strings: bounded and unbounded. Bounded strings are defined as strings that have a
maximum length specified; whereas, unbounded strings do not have a maximum length specified.
18.2.4.1 Mapping for Unbounded String Types
The definition of an unbounded string limited to 8-bit quantities in OMG IDL
// OMG IDL typedef string UNBOUNDED_STRING;
is mapped to the following syntax in Microsoft IDL and ODL, which denotes the type of a “stringified unique pointer to character.?
// Microsoft IDL and ODLtypedef [string, unique] char * UNBOUNDED_STRING;
In other words, a value of type UNBOUNDED_STRING is a non-NULL pointer to a one-dimensional null-terminated character array
whose extent and number of valid elements can vary at run-time.
18.2.4.2 Mapping for Bounded String Types
Bounded strings have a slightly different mapping between OMG IDL and Microsoft IDL and ODL. The following OMG IDL definition
for a bounded string:
// OMG IDL const long N = ...; typedef string<N> BOUNDED_STRING;
maps to the following syntax in Microsoft IDL and ODL for a “stringified nonconformant array.?
// Microsoft IDL and ODL const long N = ... ; typedef [string, unique] char (* BOUNDED_STRING) [N];
In other words, the encoding for a value of type BOUNDED_STRING is that of a null-terminated array of characters whose extent
is known at compile time, and the number of valid characters can vary at run-time.