user_marshal
typedef
[user_marshal(userm_type)] wire-type;
unsigned
long __RPC_USER < userm_type >_UserSize(
unsigned long __RPC_FAR
*pFlags,
unsigned long StartingSize,
< userm_type > __RPC_FAR * pUser_typeObject );
unsigned
char __RPC_FAR * __RPC_USER < userm_type
>_UserMarshal(
unsigned long __RPC_FAR
*pFlags,
unsigned char __RPC_FAR *
Buffer,
< userm_type > __RPC_FAR * pUser_typeObject);
unsigned
char __RPC_FAR * __RPC_USER < userm_type >_UserUnmarshal(
unsigned long __RPC_FAR * pFlags,
unsigned char __RPC_FAR * Buffer,
< userm_type > __RPC_FAR * pUser_typeObject);
void
__RPC_USER < userm_type >_UserFree(
unsigned long __RPC_FAR * pFlags,
< userm_type > __RPC_FAR * pUser_typeObject);
userm-type
Specifies the
id of the user data type to be marshaled. The userm-type need not be
remotable and need not be a type known to the MIDL compiler.
wire-type
Specifies the
named transfer data type that is actually transferred between client and
server. the wire-type must be a MIDL base type, predefined type, or a
type identifier of a remotable.
pFlags
Specifies a
pointer to a flag field(unsigned long). The high-order word specifies NDR data
representation flags as defined by DCE for floating point, big- or little-endian,
and character representation. The low-order word specifies a marshaling context
flag. The exact layout of the flags is described in The type_UserSize
Function
StartingSize
Specifies the
current buffer size (offset) before sizing the object.
Buffer
Specifies the
current buffer pointer.
pUser_typeObject
Specifies a
pointer to an object of userm_type.
Example
// Marshal a long as a structure containing two
shorts.
typedef unsigned long FOUR_BYTE_DATA;
typedef struct _TWO_X_TWO_BYTE_DATA {
unsigned
short low;
unsigned
short high;
} TWO_X_TWO_BYTE_DATA;
//in ACFL file:
typedef [user_marshal(FOUR_BYTE_DATA)]
TWO_X_TWO_BYTE_DATA;
//Marshaling functions:
unsigned long __RPC_USER FOUR_BYTE_DATA_UserSize(
ULONG
__RPC_FAR * pulFlags,
char
__RPC_FAR * pBufferStart,
FOUR_BYTE_DATA __RPC_FAR * pul
);//calculate size that converted data will
//
require in the buffer
unsigned long __RPC_USER FOUR_BYTE_DATA_UserMarshal(
ULONG
__RPC_FAR *pulFlags,
char
__RPC_FAR * pBufferStart,
FOUR_BYTE_DATA __RPC_FAR * pul
);//copy
FOUR_BYTE_DATA into buffer as
//TWO_X_TWO_BYTE_DATA
unsigned long __RPC_USER
FOUR_BYTE_DATA_UserUnmarshal(
ULONG
__RPC_FAR * pulFlags,
char
__RPC_FAR * pBufferStart,
FOUR_BYTE_DATA
__RPC_FAR * pul
);//recreate FOUR_BYTE_DATA from TWO_X_TWO_BYTE_DATA
//in
buffer
void __RPC_USER FOUR_BYTE_DATA_UserFree(
ULONG
__RPC_FAR * pulFlags,
FOUR_BYTE_DATA __RPC_FAR * pul
);//nothing to do here as the engine frees the
// top
node and FOUR_BYTE_DATA is a flat data
//type.
Remarks
The user_marshal
attribute associates a named local type in the target language (userm-type)
with a transfer type (wire-type) that is transferred between client
and server. Each userm-type has a one-to-one correspondence with a wire-type
that defines the wire representation of the type. You must supply routines to
size the data for marshaling, to marshal and unmarshal the data, and to free
memory. For more information on these routines, see The user_marshal
Attribute
The wire-type
cannot be an interface pointer or a full pointer. The wire-type must
have a well-defined memory size. See Marshaling Rules for user_marshal and
wire_marshal
The userm-type
should not be an interface pointer as these can be marshaled directly. If the
user type is a full pointer, you must manage the aliasing yourself.
See Also