[ encode [ , interface-attribute-list] ] interface interface-name
[ encode [ , op-attribute-list] ] proc-name
typedef [encode [ , type-attribute-list] ] type-name
/*
ACF file example;
Assumes MyType1, MyType2, MyType3, MyProc1, MyProc2, MyProc3 defined
in IDL file
MyType1, MyType2, MyProc1, MyProc2 have encode and decode
serialization support
MyType3 and MyProc3 have encode serialization support only
*/
[ encode, implicit_handle(handle_t bh) ] interface regress
{
typedef [ decode ] MyType1;
typedef [ encode, decode ] MyType2;
[ decode ] MyProcc1();
[ encode ] MyProc2();
}
The encode attribute specifies that a procedure or a data type needs serialization support. This attribute causes the MIDL compiler to generate code that an application can use to serialize data into a buffer. The decode attribute provides deserialization support, generating the code for retrieving data from a buffer.
Use the encode and decode attributes in an ACF to generate serialization code for procedures or types defined in the IDL file of an interface. When used as an interface attribute, encode applies to all the types and procedures defined in the IDL file. When used as an operational attribute, encode applies only to the specified procedure. When used as a type attribute, encode applies only to the specified type.
When the encode or decode attribute is applied to a procedure, the MIDL compiler generates a serialization stub in a similar fashion as remote stubs are generated for remote routines. A procedure can be either a remotable or a serializing procedure, but it cannot be both. The prototype of the generated routine is sent to the STUB.H file while the stub itself goes into the STUB_C.C file.
The MIDL compiler generates two functions for each type the encode attribute applies to, and one additional function for each type the decode attribute applies to. For example, for a user-defined type named MyType, the compiler generates code for the MyType_Encode, MyType_Decode, and MyType_AlignSize functions. For these functions, the compiler writes prototypes to STUB.H and source code to STUB_C.C.
For additional information about serialization handles and encoding or decoding data, see Using Encoding Services.