cpiWriteBufferFormatted

用途

此函数是现有 cpiWriteBuffer() 实施函数提供的能力扩展,它提供:
  1. 译码和编码字符集,当解析器按顺序将其元素树解析为输出位流时,应使用此字符集表示输出消息。
  2. 输出消息的消息集、类型和格式,那些解析器需要此类信息,以正确地按顺序将其元素树解析为输出位流。

如果不需要进行序列化(例如,当输出基于输入位流并且树未经更改时),则代理不会调用此实施函数。

如果在 CPI_VFT 结构中提供了此实施函数,则既不能指定 cpiWriteBuffer() 也不能指定 cpiWriteBufferEncoded(),因为 cpiDefineParserClass() 函数将失败,返回代码为 CCI_INVALID_IMPL_FUNCTION。

在其中定义 类型 成员
CPI_VFT 有条件的 iFpWriteBufferFormatted

语法

int cpiWriteBufferFormatted(
    CciParser*  parser,
    CciContext* context,                
    int         encoding,
    int                        ccsid,
    CciChar*       set,
    CciChar*       type,
    CciChar*       format); 

参数

parser
解析器对象的地址(输入)。
context
解析器对象拥有的上下文的地址(输入)。
encoding
消息缓冲区的编码(输入)。
ccsid
消息缓冲区的 ccsid(输入)。
set
消息(输入)所属的消息集。
type
消息类型(输入)。
format
消息格式(输入)。

返回值

追加在缓冲区中位流后面的数据大小(以字节为单位)。

样本

int cpiWriteBufferFormatted(
    CciParser*  parser,
    CciContext* context,                
    int         encoding,
    int         ccsid
    CciChar*       set,
    CciChar*       type,
    CciChar*       format
){
    PARSER_CONTEXT_ST* pc = (PARSER_CONTEXT_ST *)context ;
    int                initialSize = 0;
    int                rc = 0;
    const void* a;
    CciByte b;

  
    initialSize = cpiBufferSize(&rc, parser);
    a = cpiBufferPointer(&rc, parser);
    b = cpiBufferByte(&rc, parser, 0);

    cpiAppendToBuffer(&rc, parser, (char *)"Some test data", 14);

    return cpiBufferSize(0, parser) - initialSize;
}
相关概念
用户定义的解析器
用户定义的扩展
相关任务
使用 C 创建解析器
相关参考
cpiWriteBuffer
cpiWriteBufferEncoded
C 解析器实施函数
声明 | 商标 | 下载 | 书库 | 支持 | 反馈
Copyright IBM Corporation 1999, 2006 最后一次更新时间:2006/08/14
as08230_