写一个与解析器相关的消息缓冲区的语法元素树。它使用当前语法元素树作为源,在与解析器对象相关的消息缓冲区中的位流追加数据。在执行此实施函数期间不应该修改元素树。cpiAppendToBuffer 实用程序函数可用于将来自元素树的数据追加到消息缓冲区(位流)。
如果在 CPI_VFT 结构中提供了此实施函数,则既不能指定 cpiWriteBufferEncoded() 也不能指定 cpiWriteBufferFormatted(),因为 cpiDefineParserClass() 函数将失败,返回代码为 CCI_INVALID_IMPL_FUNCTION。
在其中定义 | 类型 | 成员 |
CPI_VFT | 有条件的 | iFpWriteBuffer |
int cpiWriteBuffer( CciParser* parser, CciContext* context);
追加在缓冲区中位流后面的数据大小(以字节为单位)。
int cpiWriteBuffer( CciParser* parser, CciContext* context ){ 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; }