本文整理汇总了C++中XMLTag::ParseTag方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLTag::ParseTag方法的具体用法?C++ XMLTag::ParseTag怎么用?C++ XMLTag::ParseTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLTag
的用法示例。
在下文中一共展示了XMLTag::ParseTag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseTag
bool XMLTag::ParseTag(StringParser* parser, DTDVerifier* verifier, char* errorBuffer, int errorBufferSize)
{
while (true)
{
if (!parser->GetThru(NULL, '<'))
{
if (errorBuffer != NULL)
qtss_snprintf(errorBuffer, errorBufferSize, "Couldn't find a valid tag");
return false; // couldn't find beginning of tag
}
char c = parser->PeekFast();
if (c == '/')
{
if (errorBuffer != NULL)
qtss_snprintf(errorBuffer, errorBufferSize, "End tag with no begin tag on line %d", parser->GetCurrentLineNumber());
return false; // we shouldn't be seeing a close tag here
}
if ((c != '!') && (c != '?'))
break; // this should be the beginning of a regular tag
ConsumeIfComment(parser);
// otherwise this is a processing instruction or a c-data, so look for the next tag
}
int tagStartLine = parser->GetCurrentLineNumber();
StrPtrLen temp;
parser->ConsumeUntil(&temp, sNonNameMask);
if (temp.Len == 0)
{
if (errorBuffer != NULL)
{
if (parser->GetDataRemaining() == 0)
qtss_snprintf(errorBuffer, errorBufferSize, "Unexpected end of file on line %d", parser->GetCurrentLineNumber());
else
qtss_snprintf(errorBuffer, errorBufferSize,"Unexpected character (%c) on line %d", parser->PeekFast(), parser->GetCurrentLineNumber());
}
return false; // bad file
}
fTag = temp.GetAsCString();
parser->ConsumeWhitespace();
while ((parser->PeekFast() != '>') && (parser->PeekFast() != '/'))
{
// we must have an attribute value for this tag
XMLAttribute* attr = new XMLAttribute;
fAttributes.EnQueue(&attr->fElem);
parser->ConsumeUntil(&temp, sNonNameMask);
if (temp.Len == 0)
{
if (errorBuffer != NULL)
{
if (parser->GetDataRemaining() == 0)
qtss_snprintf(errorBuffer, errorBufferSize, "Unexpected end of file on line %d", parser->GetCurrentLineNumber());
else
qtss_snprintf(errorBuffer, errorBufferSize,"Unexpected character (%c) on line %d", parser->PeekFast(), parser->GetCurrentLineNumber());
}
return false; // bad file
}
attr->fAttrName = temp.GetAsCString();
if (!parser->Expect('='))
{
if (errorBuffer != NULL)
qtss_snprintf(errorBuffer, errorBufferSize,"Missing '=' after attribute %s on line %d", attr->fAttrName, parser->GetCurrentLineNumber());
return false; // bad attribute specification
}
if (!parser->Expect('"'))
{
if (errorBuffer != NULL)
qtss_snprintf(errorBuffer, errorBufferSize,"Attribute %s value not in quotes on line %d", attr->fAttrName, parser->GetCurrentLineNumber());
return false; // bad attribute specification
}
parser->ConsumeUntil(&temp, '"');
attr->fAttrValue = temp.GetAsCString();
if (!parser->Expect('"'))
{
if (errorBuffer != NULL)
qtss_snprintf(errorBuffer, errorBufferSize, "Attribute %s value not in quotes on line %d", attr->fAttrName, parser->GetCurrentLineNumber());
return false; // bad attribute specification
}
if (verifier && !verifier->IsValidAttributeName(fTag, attr->fAttrName))
{
if (errorBuffer != NULL)
qtss_snprintf(errorBuffer, errorBufferSize, "Attribute %s not allowed in tag %s on line %d", attr->fAttrName, fTag, parser->GetCurrentLineNumber());
return false; // bad attribute specification
}
if (verifier && !verifier->IsValidAttributeValue(fTag, attr->fAttrName, attr->fAttrValue))
{
if (errorBuffer != NULL)
qtss_snprintf(errorBuffer, errorBufferSize,"Bad value for attribute %s on line %d", attr->fAttrName, parser->GetCurrentLineNumber());
return false; // bad attribute specification
}
//.........这里部分代码省略.........