Data Representation

Computing environments can differ significantly, as can network architectures. To accommodate these differences, MIDL enables you to modify the way you represent data. You can sometimes simplify development by converting data into a format that your application can more easily handle. You can alter your application's data format so that it can be more efficiently transmitted over the network.

The [transmit_as] and [represent_as] attributes instruct the compiler to associate a transmissible type that the stub passes between client and server, with a user type that the client and server applications use. You must supply the routines that carry out the conversion between the user type and the transmissible type, and the routines to release the memory that was used to hold the converted data. Using the [transmit_as] IDL attribute or the [represent_as] ACF attribute instructs the stub to call these conversion routines before and after transmission. The [transmit_as] attribute lets you convert one data type to another data type for transmission over the network. The [represent_as] attribute lets you control the way data from the network is presented to the application.

The [wire_marshal] and [user_marshal] attributes are Microsoft extensions to the OSF-DCE IDL. Their syntax and functionality are similar to that of the DCE-specified [transmit_as] and [represent_as] attributes, respectively. The difference is that, instead of converting the data from one type to another, you marshal the data directly. To do this, you must supply the external routines for sizing the data buffer on the client and server sides, marshaling and unmarshaling the data on the client and server sides, and freeing the data on the server side. The MIDL compiler generates format codes that instruct the NDR engine to call these external routines when needed.

The [wire_marshal] and [user_marshal] attributes make it possible to marshal data types that otherwise could not be transmitted across process boundaries. Also, because there is less overhead associated with the type conversion, [wire_marshal] and [user_marshal] provide improved performance at run time, when compared to [transmit_as] and [represent_as]. The [wire_marshal] and [user_marshal] attributes are mutually exclusive with respect to each other and with respect to the [transmit_as] and [represent_as] attributes for a given type.

It is important to note that the implementation of the [wire_marshal] and [user_marshal] attributes must follow the marshalling rules dictated by OSF-DCE specification. For that reason, the use of these attributes is not recommended if you are not familiar with the wire protocol. More information regarding the NDR Syntax Transfer can be found at www.opengroup.org.

This section provides a brief overview of these for MIDL attributes, in the following topics: