MCPcopy Create free account
hub / github.com/OpenMW/openmw / Print

Method Print

extern/oics/tinyxml/tinyxml.cpp:787–837  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

785
786
787void TiXmlElement::Print( FILE* cfile, int depth ) const
788{
789 int i;
790 assert( cfile );
791 for ( i=0; i<depth; i++ ) {
792 fprintf( cfile, " " );
793 }
794
795 fprintf( cfile, "<%s", value.c_str() );
796
797 const TiXmlAttribute* attrib;
798 for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() )
799 {
800 fprintf( cfile, " " );
801 attrib->Print( cfile, depth );
802 }
803
804 // There are 3 different formatting approaches:
805 // 1) An element without children is printed as a <foo /> node
806 // 2) An element with only a text child is printed as <foo> text </foo>
807 // 3) An element with children is printed on multiple lines.
808 TiXmlNode* node;
809 if ( !firstChild )
810 {
811 fprintf( cfile, " />" );
812 }
813 else if ( firstChild == lastChild && firstChild->ToText() )
814 {
815 fprintf( cfile, ">" );
816 firstChild->Print( cfile, depth + 1 );
817 fprintf( cfile, "</%s>", value.c_str() );
818 }
819 else
820 {
821 fprintf( cfile, ">" );
822
823 for ( node = firstChild; node; node=node->NextSibling() )
824 {
825 if ( !node->ToText() )
826 {
827 fprintf( cfile, "\n" );
828 }
829 node->Print( cfile, depth+1 );
830 }
831 fprintf( cfile, "\n" );
832 for( i=0; i<depth; ++i ) {
833 fprintf( cfile, " " );
834 }
835 fprintf( cfile, "</%s>", value.c_str() );
836 }
837}
838
839
840void TiXmlElement::CopyTo( TiXmlElement* target ) const

Callers 2

VisitEnterMethod · 0.45
VisitMethod · 0.45

Calls 7

c_strMethod · 0.80
FirstMethod · 0.80
NextMethod · 0.45
ToTextMethod · 0.45
NextSiblingMethod · 0.45
findMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected