设置指定的元素的值的可选函数。当要设置语法元素的值时,它由代理调用。它使得用户定义的解析器能覆盖设置元素值的行为。
在其中定义 | 类型 | 成员 |
CPI_VFT | 可选 | iFpSetElementValue |
void cpiSetElementValue( CciParser* parser, CciElement* currentElement, CciElementValue* value);
无。
此示例取自样本解析器文件 BipSampPluginParser.c(675 到 698 行):
void cpiSetElementValue( CciParser* parser, CciElement* element, CciElementValue* value ){ CciElement* newElement; int rc; if ((cpiElementType(&rc, element) == CCI_ELEMENT_TYPE_VALUE) || (cpiElementType(&rc, element) == CCI_ELEMENT_TYPE_NAME_VALUE)) { cpiSetElementValueValue(&rc, element, value); } else if (cpiElementType(&rc, element) == CCI_ELEMENT_TYPE_NAME) { /* Create a new value element, add as a first child, and set the value */ newElement = cpiCreateElement(&rc, parser); cpiSetElementType(&rc, newElement, CCI_ELEMENT_TYPE_VALUE); cpiSetElementValueValue(&rc, newElement, value); cpiAddAsFirstChild(&rc, element, newElement); } else { } return; }