Previous Table of Contents Next


3.11.3 Template Types


   The template types are:

   (47) <template_type_spec> ::= <sequence_type>| <string_type>| <wide_string_type>| <fixed_pt_type>

   3.11.3.1 Sequences

   OMG IDL defines the sequence type sequence. A sequence is a one-dimensional array with two characteristics: a maximum size (which is fixed at compile time) and a length (which is determined at run time).

   The syntax is:

   (80) <sequence_type> ::= “sequence? “<? <simple_type_spec> “,?

   <positive_int_const> “>? | “sequence? “<? <simple_type_spec> “>?

   The second parameter in a sequence declaration indicates the maximum size of the sequence. If a positive integer constant is specified for the maximum size, the sequence is termed a bounded sequence. If no maximum size is specified, size of the sequence is unspecified (unbounded).

   Prior to passing a bounded or unbounded sequence as a function argument (or as a field in a structure or union), the length of the sequence must be set in a language-mapping dependent manner. After receiving a sequence result from an operation invocation, the length of the returned sequence will have been set; this value may be obtained in a language-mapping dependent manner.

   A sequence type may be used as the type parameter for another sequence type. For example, the following:

   typedef sequence< sequence<long> > Fred;

   declares Fred to be of type “unbounded sequence of unbounded sequence of long.? Note that for nested sequence declarations, white space must be used to separate the two “>? tokens ending the declaration so they are not parsed as a single “>>? token.

   3.11.3.2 Strings

   OMG IDL defines the string type string consisting of all possible 8-bit quantities except null. A string is similar to a sequence of char. As with sequences of any type, prior to passing a string as a function argument (or as a field in a structure or union), the length of the string must be set in a language-mapping dependent manner. The syntax is:

   (81) <string_type> ::= “string? “<? <positive_int_const> “>? | “string?

   The argument to the string declaration is the maximum size of the string. If a positive integer maximum size is specified, the string is termed a bounded string; if no maximum size is specified, the string is termed an unbounded string.

   Strings are singled out as a separate type because many languages have special built-in functions or standard library functions for string manipulation. A separate string type may permit substantial optimization in the handling of strings compared to what can be done with sequences of general types.

   3.11.3.3 Wstrings

   The wstring data type represents a sequence of wchar, except the wide character null. The type wstring is similar to that of type string, except that its element type is wchar instead of char. The actual length of a wstring is set at run-time and, if the bounded form is used, must be less than or equal to the bound.

   The syntax for defining a wstring is:

   (82) <wide_string_type> ::= “wstring? “<? <positive_int_const> “>? | “wstring?

   3.11.3.4 Fixed Type

   The fixed data type represents a fixed-point decimal number of up to 31 significant digits. The scale factor is a non-negative integer less than or equal to the total number of digits (note that constants with effectively negative scale, such as 10000, are always permitted).

   The fixed data type will be mapped to the native fixed point capability of a programming language, if available. If there is not a native fixed point type, then the IDL mapping for that language will provide a fixed point data type. Applications that use the IDL fixed point type across multiple programming languages must take into account differences between the languages in handling rounding, overflow, and arithmetic precision.

   The syntax of fixed type is:

   (96) <fixed_pt_type> ::= “fixed? “<“ <positive_int_const> “,? <positive_int_const> “>? (97) <fixed_pt_const_type> ::= “fixed?