MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / Print

Method Print

cpp/tinyxml/tinyxml.cpp:773–823  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

VisitEnterMethod · 0.45
VisitMethod · 0.45

Calls 7

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

Tested by

no test coverage detected