本文整理汇总了C++中TiXmlAttributeA::SetValue方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlAttributeA::SetValue方法的具体用法?C++ TiXmlAttributeA::SetValue怎么用?C++ TiXmlAttributeA::SetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlAttributeA
的用法示例。
在下文中一共展示了TiXmlAttributeA::SetValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetAttribute
void TiXmlElementA::SetAttribute( const char * name, const char * _value )
{
TiXmlAttributeA* node = attributeSet.Find( name );
if ( node )
{
node->SetValue( _value );
return;
}
TiXmlAttributeA* attrib = new TiXmlAttributeA( name, _value );
if ( attrib )
{
attributeSet.Add( attrib );
}
else
{
TiXmlDocumentA* document = GetDocument();
if ( document ) document->SetError( TIXMLA_ERROR_OUT_OF_MEMORY, 0, 0 );
}
}
示例2: Parse
//.........这里部分代码省略.........
{
if ( document ) document->SetError( TIXMLA_ERROR_PARSING_ELEMENT, p, data );
return 0;
}
p = SkipWhiteSpace( p+1 );
// Read the name.
const char* pErr = p;
p = ReadName( p, &value );
if ( !p || !*p )
{
if ( document ) document->SetError( TIXMLA_ERROR_FAILED_TO_READ_ELEMENT_NAME, pErr, data );
return 0;
}
TIXMLA_STRING endTag ("</");
endTag += value;
endTag += ">";
// Check for and read attributes. Also look for an empty
// tag or an end tag.
while ( p && *p )
{
pErr = p;
p = SkipWhiteSpace( p );
if ( !p || !*p )
{
if ( document ) document->SetError( TIXMLA_ERROR_READING_ATTRIBUTES, pErr, data );
return 0;
}
if ( *p == '/' )
{
++p;
// Empty tag.
if ( *p != '>' )
{
if ( document ) document->SetError( TIXMLA_ERROR_PARSING_EMPTY, p, data );
return 0;
}
return (p+1);
}
else if ( *p == '>' )
{
// Done with attributes (if there were any.)
// Read the value -- which can include other
// elements -- read the end tag, and return.
++p;
p = ReadValue( p, data ); // Note this is an Element method, and will set the error if one happens.
if ( !p || !*p )
return 0;
// We should find the end tag now
if ( StringEqual( p, endTag.c_str(), false ) )
{
p += endTag.length();
return p;
}
else
{
if ( document ) document->SetError( TIXMLA_ERROR_READING_END_TAG, p, data );
return 0;
}
}
else
{
// Try to read an attribute:
TiXmlAttributeA* attrib = new TiXmlAttributeA();
if ( !attrib )
{
if ( document ) document->SetError( TIXMLA_ERROR_OUT_OF_MEMORY, pErr, data );
return 0;
}
attrib->SetDocument( document );
const char* pErr = p;
p = attrib->Parse( p, data );
if ( !p || !*p )
{
if ( document ) document->SetError( TIXMLA_ERROR_PARSING_ELEMENT, pErr, data );
delete attrib;
return 0;
}
// Handle the strange case of double attributes:
TiXmlAttributeA* node = attributeSet.Find( attrib->Name() );
if ( node )
{
node->SetValue( attrib->Value() );
delete attrib;
return 0;
}
attributeSet.Add( attrib );
}
}
return p;
}