고정 버퍼 직렬화

고정 버퍼 스타일을 사용하는 경우 핸들로 수행되는 인코딩(마샬링) 작업을 수용할 수 있을 만큼 큰 버퍼를 지정합니다. 경계를 해제할 때 디코딩할 모든 데이터가 포함된 버퍼를 제공합니다.

직렬화의 고정 버퍼 스타일은 다음 루틴을 사용합니다.

MesEncodeFixedBufferHandleCreate 함수는 인코딩 핸들에 필요한 메모리를 할당한 다음 초기화합니다. 애플리케이션은 MesBufferHandleReset 을 호출하여 핸들을 다시 초기화하거나 MesHandleFree 를 호출하여 핸들의 메모리를 해제할 수 있습니다. 고정 스타일 인코딩 핸들에 해당하는 디코딩 핸들을 만들려면 MesDecodeBufferHandleCreate를 사용해야 합니다.

애플리케이션은 MesHandleFree 를 호출하여 인코딩 또는 디코딩 버퍼 핸들을 해제합니다.

고정 버퍼 인코딩의 예

다음 섹션에서는 프로시저 인코딩에 고정 버퍼 스타일 직렬화 핸들을 사용하는 방법의 예를 제공합니다.

/*This is a fragment of the IDL file defining MooProc */

...
void __RPC_USER
MyProc( [in] handle_t Handle, [in,out] MyType * pMyObject,
        [in, out] ThisType * pThisObject);
...

/*This is an ACF file. MyProc is defined in the IDL file */

[
    explicit_handle
]
interface regress
{
    [ encode,decode ] MyProc();
}

다음 발췌문은 애플리케이션의 일부를 나타냅니다.

if (MesEncodeFixedBufferHandleCreate (
        Buffer, BufferSize, 
        pEncodedSize, &Handle) == RPC_S_OK)
{
    ...
    /* Manufacture a MyObject and a ThisObject */
    ...
    /* The serialization works from the beginning of the buffer because 
   the handle is in the initial state. The function MyProc does the    
   following when called with an encoding handle:
     - sizes all the parameters for marshalling,
     - marshalls into the buffer (and sets the internal state 
    appropriately) 
    */

    MyProc ( Handle, pMyObject, pThisObject );
    ...
    MesHandleFree ();
}
if (MesDecodeBufferHandleCreate (Buffer, BufferSize, &Handle) ==
    RPC_S_OK)
{

    /* The MooProc does the following for you when called with a decoding 
    handle:
     - unmarshalls the objects from the buffer into *pMooObject and 
       *pBarObject
*/

MyProc ( Handle, pMyObject, pThisObject);
...
MesHandleFree ( Handle );
}

다음 섹션에서는 형식 인코딩에 고정 버퍼 스타일 직렬화 핸들을 사용하는 방법의 예를 제공합니다.

/* This is an ACF file. MyType is defined in the IDL file */

[    
    explicit_handle
]
interface regress
{
    typedef [ encode,decode ] MyType;
}

다음 발췌문은 관련 애플리케이션 조각을 나타냅니다.

if (MesEncodeFixedBufferHandleCreate (Buffer, BufferSize, 
    pEncodedSize, &Handle) == RPC_S_OK)
{
    //...
    /* Manufacture a MyObject and a pMyObject */
    //...
    MyType_Encode ( Handle, pMyObject );
    //...
    MesHandleFree ();
}
if (MesDecodeBufferHandleCreate (Buffer, BufferSize, &Handle) ==
    RPC_S_OK )
{
    MooType_Decode (Handle, pMooObject);
    //...
    MesHandleFree ( Handle );
}