本文整理汇总了C++中XMLParser::Error方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLParser::Error方法的具体用法?C++ XMLParser::Error怎么用?C++ XMLParser::Error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLParser
的用法示例。
在下文中一共展示了XMLParser::Error方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ElementHandlerEnd
/*!
* Handling of element end
*/
void XMLParser::ElementHandlerEnd(void *data, const char *el)
{
XMLParser* p = (XMLParser*)data;
if (p == NULL)
{
#ifdef PYTHON_WRAPPER
PyErr_SetString(PyExc_RuntimeError, "Missing Parser!");
#else
Tracer::Error("Missing Parser!");
#endif
return;
}
if (p->m_bErrorDetectedStopParsing)
return;
if (!strcmp(el, "Category"))
{
if (p->m_pCategory)
{
p->m_pDef->setCategory(p->m_pCategory);
p->m_pCategory = NULL;
}
else
{
p->Error("Closing unopened tag: ", el);
}
}
else if (!strcmp(el, "DataItem"))
{
if (p->m_pDataItem)
{
p->m_pDataItem = NULL;
}
else
{
p->Error("Closing unopened tag: ", el);
}
}
else if (!strcmp(el, "Fixed"))
{
if (p->m_pFormat != NULL && p->m_pFormat->isFixed())
{
/* We do not check for fx bit any more because there are some formats that
do not have fx bit in primary part of variable item (e.g. I021/271).
Now if the fx is not defined it means that this is the last primary field.
if (p->m_pFormat->m_pParentFormat && p->m_pFormat->m_pParentFormat->isVariable())
{ // check if fx bit is set
std::list<DataItemFormat*>::iterator it;
bool fxFound = false;
for ( it=p->m_pFormat->m_lSubItems.begin() ; it != p->m_pFormat->m_lSubItems.end(); it++ )
{
DataItemBits* dip = (DataItemBits*)(*it);
if (dip->m_bExtension == true)
{
fxFound = true;
break;
}
}
if (!fxFound)
{
p->Error("Missing fx=1 in primary part of Variable item.");
}
}
*/
p->m_pFormat = p->m_pFormat->m_pParentFormat;
}
else
{
p->Error("Closing unopened tag: ", el);
}
}
else if (!strcmp(el, "Variable"))
{
if (p->m_pFormat != NULL && p->m_pFormat->isVariable())
{
p->m_pFormat = p->m_pFormat->m_pParentFormat;
}
else
{
p->Error("Closing unopened tag: ", el);
}
}
else if (!strcmp(el, "Explicit"))
{
if (p->m_pFormat != NULL && p->m_pFormat->isExplicit())
{
p->m_pFormat = p->m_pFormat->m_pParentFormat;
}
else
{
p->Error("Closing unopened tag: ", el);
}
}
else if (!strcmp(el, "Repetitive"))
//.........这里部分代码省略.........
示例2: ElementHandlerStart
/*!
* Handling of element start
*/
void XMLParser::ElementHandlerStart(void *data, const char *el, const char **attr)
{
int i;
XMLParser* p = (XMLParser*)data;
if (p == NULL)
{
#ifdef PYTHON_WRAPPER
PyErr_SetString(PyExc_RuntimeError, "Missing Parser!");
#else
Tracer::Error("Missing Parser!");
#endif
return;
}
if (p->m_bErrorDetectedStopParsing)
return;
if (!strcmp(el, "Category"))
{ // <!ELEMENT Category (CatID,CatName,CatVer,DataItemDescription*,UAP)>
for (i = 0; attr[i]; i += 2)
{
if (!strcmp(attr[i], "id"))
{ // <!ATTLIST id CDATA #REQUIRED>
int id = 0;
if (!strcmp(attr[i+1], "BDS"))
id = BDS_CAT_ID;
else
id = atoi(attr[i+1]);
if (id >= 0 && id <= MAX_CATEGORIES)
{
p->m_pCategory = new Category(id);
}
else
{
p->Error("XMLParser : Wrong category: ", attr[i+1]);
break;
}
}
else if (!strcmp(attr[i], "name"))
{ // <!ATTLIST name CDATA #REQUIRED>
p->m_pCategory->m_strName = attr[i+1];
}
else if (!strcmp(attr[i], "ver"))
{ // <!ATTLIST ver CDATA #REQUIRED>
p->m_pCategory->m_strVer = attr[i+1];
}
else
{
p->Error("XMLParser : Unknown attribute: ", attr[i]);
}
}
}
else if (!strcmp(el, "DataItem"))
{ // <!ELEMENT DataItemDescription (DataItemName,DataItemDefinition,DataItemFormat,DataItemNote?)>
if (p->m_pCategory == NULL)
{
p->Error("XMLParser : <DataItem> without <Category> ");
}
else
{
for (i = 0; attr[i]; i += 2)
{
if (!strcmp(attr[i], "id"))
{ //<!ATTLIST DataItemDescription id CDATA #REQUIRED>
p->m_pDataItem = p->m_pCategory->getDataItemDescription(attr[i+1]);
}
else if (!strcmp(attr[i], "rule"))
{ // <!ATTLIST DataItemDescription rule (mandatory|optional|unknown) "unknown">
if (p->m_pDataItem)
{
if (!strcmp(attr[i+1], "optional"))
p->m_pDataItem->m_eRule = DataItemDescription::DATAITEM_OPTIONAL;
else if (!strcmp(attr[i+1], "mandatory"))
p->m_pDataItem->m_eRule = DataItemDescription::DATAITEM_MANDATORY;
else
p->m_pDataItem->m_eRule = DataItemDescription::DATAITEM_UNKNOWN;
}
else
{
p->Error("XMLParser : DataItem missing for rule");
}
}
else
{
p->Error("XMLParser : Unknown attribute: ", attr[i]);
}
}
}
}
else if (p->GetAttribute(el, "DataItemName", p->m_pDataItem ? &p->m_pDataItem->m_strName : NULL))
{ // <!ELEMENT DataItemName (#PCDATA)>
}
else if (p->GetAttribute(el, "DataItemDefinition", p->m_pDataItem ? &p->m_pDataItem->m_strDefinition : NULL))
{ // <!ELEMENT DataItemDefinition (#PCDATA)>
//.........这里部分代码省略.........