⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tinyxml.cpp

📁 一个帮助你学习英语的软件~~很不错的咯~~ 对功能又做了改进~大家支持下哈~
💻 CPP
📖 第 1 页 / 共 3 页
字号:
void TiXmlAttribute::SetDoubleValue( double _value ){	char buf [256];	#if defined(TIXML_SNPRINTF)				TIXML_SNPRINTF( buf, sizeof(buf), "%lf", _value);	#else		sprintf (buf, "%lf", _value);	#endif	SetValue (buf);}int TiXmlAttribute::IntValue() const{	return atoi (value.c_str ());}double  TiXmlAttribute::DoubleValue() const{	return atof (value.c_str ());}TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::COMMENT ){	copy.CopyTo( this );}void TiXmlComment::operator=( const TiXmlComment& base ){	Clear();	base.CopyTo( this );}void TiXmlComment::Print( FILE* cfile, int depth ) const{	assert( cfile );	for ( int i=0; i<depth; i++ )	{		fprintf( cfile,  "    " );	}	fprintf( cfile, "<!--%s-->", value.c_str() );}void TiXmlComment::CopyTo( TiXmlComment* target ) const{	TiXmlNode::CopyTo( target );}bool TiXmlComment::Accept( TiXmlVisitor* visitor ) const{	return visitor->Visit( *this );}TiXmlNode* TiXmlComment::Clone() const{	TiXmlComment* clone = new TiXmlComment();	if ( !clone )		return 0;	CopyTo( clone );	return clone;}void TiXmlText::Print( FILE* cfile, int depth ) const{	assert( cfile );	if ( cdata )	{		int i;		fprintf( cfile, "\n" );		for ( i=0; i<depth; i++ ) {			fprintf( cfile, "    " );		}		fprintf( cfile, "<![CDATA[%s]]>\n", value.c_str() );	// unformatted output	}	else	{		TIXML_STRING buffer;		PutString( value, &buffer );		fprintf( cfile, "%s", buffer.c_str() );	}}void TiXmlText::CopyTo( TiXmlText* target ) const{	TiXmlNode::CopyTo( target );	target->cdata = cdata;}bool TiXmlText::Accept( TiXmlVisitor* visitor ) const{	return visitor->Visit( *this );}TiXmlNode* TiXmlText::Clone() const{		TiXmlText* clone = 0;	clone = new TiXmlText( "" );	if ( !clone )		return 0;	CopyTo( clone );	return clone;}TiXmlDeclaration::TiXmlDeclaration( const char * _version,									const char * _encoding,									const char * _standalone )	: TiXmlNode( TiXmlNode::DECLARATION ){	version = _version;	encoding = _encoding;	standalone = _standalone;}#ifdef TIXML_USE_STLTiXmlDeclaration::TiXmlDeclaration(	const std::string& _version,									const std::string& _encoding,									const std::string& _standalone )	: TiXmlNode( TiXmlNode::DECLARATION ){	version = _version;	encoding = _encoding;	standalone = _standalone;}#endifTiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy )	: TiXmlNode( TiXmlNode::DECLARATION ){	copy.CopyTo( this );	}void TiXmlDeclaration::operator=( const TiXmlDeclaration& copy ){	Clear();	copy.CopyTo( this );}void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const{	if ( cfile ) fprintf( cfile, "<?xml " );	if ( str )	 (*str) += "<?xml ";	if ( !version.empty() ) {		if ( cfile ) fprintf (cfile, "version=\"%s\" ", version.c_str ());		if ( str ) { (*str) += "version=\""; (*str) += version; (*str) += "\" "; }	}	if ( !encoding.empty() ) {		if ( cfile ) fprintf (cfile, "encoding=\"%s\" ", encoding.c_str ());		if ( str ) { (*str) += "encoding=\""; (*str) += encoding; (*str) += "\" "; }	}	if ( !standalone.empty() ) {		if ( cfile ) fprintf (cfile, "standalone=\"%s\" ", standalone.c_str ());		if ( str ) { (*str) += "standalone=\""; (*str) += standalone; (*str) += "\" "; }	}	if ( cfile ) fprintf( cfile, "?>" );	if ( str )	 (*str) += "?>";}void TiXmlDeclaration::CopyTo( TiXmlDeclaration* target ) const{	TiXmlNode::CopyTo( target );	target->version = version;	target->encoding = encoding;	target->standalone = standalone;}bool TiXmlDeclaration::Accept( TiXmlVisitor* visitor ) const{	return visitor->Visit( *this );}TiXmlNode* TiXmlDeclaration::Clone() const{		TiXmlDeclaration* clone = new TiXmlDeclaration();	if ( !clone )		return 0;	CopyTo( clone );	return clone;}void TiXmlUnknown::Print( FILE* cfile, int depth ) const{	for ( int i=0; i<depth; i++ )		fprintf( cfile, "    " );	fprintf( cfile, "<%s>", value.c_str() );}void TiXmlUnknown::CopyTo( TiXmlUnknown* target ) const{	TiXmlNode::CopyTo( target );}bool TiXmlUnknown::Accept( TiXmlVisitor* visitor ) const{	return visitor->Visit( *this );}TiXmlNode* TiXmlUnknown::Clone() const{	TiXmlUnknown* clone = new TiXmlUnknown();	if ( !clone )		return 0;	CopyTo( clone );	return clone;}TiXmlAttributeSet::TiXmlAttributeSet(){	sentinel.next = &sentinel;	sentinel.prev = &sentinel;}TiXmlAttributeSet::~TiXmlAttributeSet(){	assert( sentinel.next == &sentinel );	assert( sentinel.prev == &sentinel );}void TiXmlAttributeSet::Add( TiXmlAttribute* addMe ){    #ifdef TIXML_USE_STL	assert( !Find( TIXML_STRING( addMe->Name() ) ) );	// Shouldn't be multiply adding to the set.	#else	assert( !Find( addMe->Name() ) );	// Shouldn't be multiply adding to the set.	#endif	addMe->next = &sentinel;	addMe->prev = sentinel.prev;	sentinel.prev->next = addMe;	sentinel.prev      = addMe;}void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe ){	TiXmlAttribute* node;	for( node = sentinel.next; node != &sentinel; node = node->next )	{		if ( node == removeMe )		{			node->prev->next = node->next;			node->next->prev = node->prev;			node->next = 0;			node->prev = 0;			return;		}	}	assert( 0 );		// we tried to remove a non-linked attribute.}#ifdef TIXML_USE_STLconst TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const{	for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )	{		if ( node->name == name )			return node;	}	return 0;}/*TiXmlAttribute*	TiXmlAttributeSet::Find( const std::string& name ){	for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )	{		if ( node->name == name )			return node;	}	return 0;}*/#endifconst TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const{	for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )	{		if ( strcmp( node->name.c_str(), name ) == 0 )			return node;	}	return 0;}/*TiXmlAttribute*	TiXmlAttributeSet::Find( const char* name ){	for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )	{		if ( strcmp( node->name.c_str(), name ) == 0 )			return node;	}	return 0;}*/#ifdef TIXML_USE_STL	std::istream& operator>> (std::istream & in, TiXmlNode & base){	TIXML_STRING tag;	tag.reserve( 8 * 1000 );	base.StreamIn( &in, &tag );	base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING );	return in;}#endif#ifdef TIXML_USE_STL	std::ostream& operator<< (std::ostream & out, const TiXmlNode & base){	TiXmlPrinter printer;	printer.SetStreamPrinting();	base.Accept( &printer );	out << printer.Str();	return out;}std::string& operator<< (std::string& out, const TiXmlNode& base ){	TiXmlPrinter printer;	printer.SetStreamPrinting();	base.Accept( &printer );	out.append( printer.Str() );	return out;}#endifTiXmlHandle TiXmlHandle::FirstChild() const{	if ( node )	{		TiXmlNode* child = node->FirstChild();		if ( child )			return TiXmlHandle( child );	}	return TiXmlHandle( 0 );}TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const{	if ( node )	{		TiXmlNode* child = node->FirstChild( value );		if ( child )			return TiXmlHandle( child );	}	return TiXmlHandle( 0 );}TiXmlHandle TiXmlHandle::FirstChildElement() const{	if ( node )	{		TiXmlElement* child = node->FirstChildElement();		if ( child )			return TiXmlHandle( child );	}	return TiXmlHandle( 0 );}TiXmlHandle TiXmlHandle::FirstChildElement( const char * value ) const{	if ( node )	{		TiXmlElement* child = node->FirstChildElement( value );		if ( child )			return TiXmlHandle( child );	}	return TiXmlHandle( 0 );}TiXmlHandle TiXmlHandle::Child( int count ) const{	if ( node )	{		int i;		TiXmlNode* child = node->FirstChild();		for (	i=0;				child && i<count;				child = child->NextSibling(), ++i )		{			// nothing		}		if ( child )			return TiXmlHandle( child );	}	return TiXmlHandle( 0 );}TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const{	if ( node )	{		int i;		TiXmlNode* child = node->FirstChild( value );		for (	i=0;				child && i<count;				child = child->NextSibling( value ), ++i )		{			// nothing		}		if ( child )			return TiXmlHandle( child );	}	return TiXmlHandle( 0 );}TiXmlHandle TiXmlHandle::ChildElement( int count ) const{	if ( node )	{		int i;		TiXmlElement* child = node->FirstChildElement();		for (	i=0;				child && i<count;				child = child->NextSiblingElement(), ++i )		{			// nothing		}		if ( child )			return TiXmlHandle( child );	}	return TiXmlHandle( 0 );}TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const{	if ( node )	{		int i;		TiXmlElement* child = node->FirstChildElement( value );		for (	i=0;				child && i<count;				child = child->NextSiblingElement( value ), ++i )		{			// nothing		}		if ( child )			return TiXmlHandle( child );	}	return TiXmlHandle( 0 );}bool TiXmlPrinter::VisitEnter( const TiXmlDocument& ){	return true;}bool TiXmlPrinter::VisitExit( const TiXmlDocument& ){	return true;}bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ){	DoIndent();	buffer += "<";	buffer += element.Value();	for( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() )	{		buffer += " ";		attrib->Print( 0, 0, &buffer );	}	if ( !element.FirstChild() ) 	{		buffer += " />";		DoLineBreak();	}	else 	{		buffer += ">";		if (    element.FirstChild()->ToText()			  && element.LastChild() == element.FirstChild()			  && element.FirstChild()->ToText()->CDATA() == false )		{			simpleTextPrint = true;			// no DoLineBreak()!		}		else		{			DoLineBreak();		}	}	++depth;		return true;}bool TiXmlPrinter::VisitExit( const TiXmlElement& element ){	--depth;	if ( !element.FirstChild() ) 	{		// nothing.	}	else 	{		if ( simpleTextPrint )		{			simpleTextPrint = false;		}		else		{			DoIndent();		}		buffer += "</";		buffer += element.Value();		buffer += ">";		DoLineBreak();	}	return true;}bool TiXmlPrinter::Visit( const TiXmlText& text ){	if ( text.CDATA() )	{		DoIndent();		buffer += "<![CDATA[";		buffer += text.Value();		buffer += "]]>";		DoLineBreak();	}	else if ( simpleTextPrint )	{		buffer += text.Value();	}	else	{		DoIndent();		buffer += text.Value();		DoLineBreak();	}	return true;}bool TiXmlPrinter::Visit( const TiXmlDeclaration& declaration ){	DoIndent();	declaration.Print( 0, 0, &buffer );	DoLineBreak();	return true;}bool TiXmlPrinter::Visit( const TiXmlComment& comment ){	DoIndent();	buffer += "<!--";	buffer += comment.Value();	buffer += "-->";	DoLineBreak();	return true;}bool TiXmlPrinter::Visit( const TiXmlUnknown& unknown ){	DoIndent();	buffer += "<";	buffer += unknown.Value();	buffer += ">";	DoLineBreak();	return true;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -