Prev Up
Go backward to Sequence
Go up to Overview of the IDL Data Types

Arrays

In IDL, you can declare an array of any IDL data type. IDL arrays can be multi-dimensional and always have a fixed size. For example, you can define an IDL struct with an array member as follows:


    module Finance { 
      interface Account { 
      ... 
      }; 

      struct CustomerAccountInfo { 
        string name; 
        Account accounts[3]; 
      }; 

      interface Bank { 
        getCustomerAccountInfo (in string name, 
        out CustomerAccountInfo accounts); 
       ... 
      }; 
    }; 

In this example, struct CustomerAccountInfo provides access to an array of Account objects for a bank customer, where each customer can have a maximum of three accounts.

An array must be named by an IDL typedef declaration before it can be used as the type of an IDL attribute or operation parameter. The IDL typedef declaration allows you define an alias for a data type, as described in "Defining Data Type Names and Constants" on page 61. The following code illustrates this:


     module Finance { 
       interface Account { 
         ... 
       }; 

       typedef Account AccountArray[100]; 

       interface Bank { 
         readonly attribute AccountArray accounts; 
         ... 
       }; 
     }; 

Note that an array is a less flexible data type than an IDL sequence, because an array always has a fixed length. An IDL sequence always has a variable length, although it may have an associated maximum length value.


 

Prev Up