PreviousNext

Strings

IDL implements strings as one-dimensional arrays to which the string attribute is assigned. The element type of the array must resolve to one of the following:

· Type char

· Type byte

· A structure all of whose members are of type byte or of a named type that resolves to byte

· A named type that resolves to one of the previous three types

· Type unsigned short

· Type unsigned long

· A named type that resolves to unsigned short or unsigned long

Strings built from byte or char data types are referred to as byte-string types while strings built from unsigned short or unsigned long types are called integer-string types. Integer string types allow for multioctet character sets whose characters are represented by 16-bit or 32-bit quantities, rather than as groups of bytes, for example:

/* A structure that contains a fixed string */

/* and a conformant string */

typedef unsigned long PRIVATE_CHAR_32;

typedef struct {

[string] PRIVATE_CHAR_32 fixed[27];

[string] PRIVATE_CHAR_32 conf[];

} two_strings;


/* A structure that contains pointers to two strings */

typedef unsigned short PRIVATE_CHAR_16;

typedef struct {

[string] PRIVATE_CHAR_16 *astring;

[string] PRIVATE_CHAR_16 *bstring;

} stringptrs;

Integer-string types use the array element zero (0) to specify the string terminator, while byte-string types use the NULL character. Both byte-type and integer-type strings conform to the same usage rules (described below).

An array with the string attribute represents a string of characters. The string attribute does not specify the format of the string or the mechanism for determining its length. Implementations of IDL provide string formats and mechanisms for determining string lengths that are compatible with the programming languages in which applications are written. For DCE RPC IDL, the number of characters in a string array includes the NULL terminator (for byte-string types) or the zero (0) terminator (for integer-string types), and the entire terminated string is passed between stubs.

The array_bounds_declarator for a string array determines the maximum number of characters in the array. Note that when you declare a string, you must allocate space for one more than the maximum number of characters the string is to hold. For instance, if a string is to store 80 characters, the string must be declared with a size of 81:

/* A string type that holds 80 characters */

typedef

[string] char string_t [81];

If an array has the string attribute or if the type of an array has the string attribute, the array cannot have the first_is, the last_is, or the length_is attribute.