Beispiel #1
0
void TiXmlUnknown::Print(NXU_FILE	*cfile,	int	depth)const
{
	for	(int i = 0;	i	<	depth; i++)
	{
		nxu_fprintf(cfile, "		");
	}
	nxu_fprintf(cfile, "<%s>", value.c_str());
}
Beispiel #2
0
  void TiXmlAttribute::Print(NXU_FILE *cfile, int /*depth*/)const
  {
    TIXML_STRING n, v;
    PutString(name, &n);
    PutString(value, &v);

    if(value.find('\"') == TIXML_STRING::npos)
    {
      nxu_fprintf(cfile, "%s=\"%s\"", n.c_str(), v.c_str());
    }
    else
    {
      nxu_fprintf(cfile, "%s='%s'", n.c_str(), v.c_str());
    }
  }
Beispiel #3
0
void TiXmlComment::Print(NXU_FILE	*cfile,	int	depth)const
{
	for	(int i = 0;	i	<	depth; i++)
	{
		nxu_fputs("		 ",	cfile);
	}
	nxu_fprintf(cfile, "<!--%s-->",	value.c_str());
}
Beispiel #4
0
void TiXmlDeclaration::Print(NXU_FILE	*cfile,	int	/*depth*/)const
{
	nxu_fprintf(cfile, "<?xml	");

	if (!version.empty())
	{
		nxu_fprintf(cfile, "version=\"%s\" ",	version.c_str());
	}
	if (!encoding.empty())
	{
		nxu_fprintf(cfile, "encoding=\"%s\"	", encoding.c_str());
	}
	if (!standalone.empty())
	{
		nxu_fprintf(cfile, "standalone=\"%s\"	", standalone.c_str());
	}
	nxu_fprintf(cfile, "?>");
}
Beispiel #5
0
void TiXmlDocument::Print(NXU_FILE *cfile, int depth)const
{
	const	TiXmlNode	*node;
	for	(node	=	FirstChild();	node;	node = node->NextSibling())
	{
		node->Print(cfile, depth);
		nxu_fprintf(cfile, "\n");
	}
}
Beispiel #6
0
void TiXmlText::Print(NXU_FILE *cfile, int depth)const
{
	if (cdata)
	{
		int	i;
		nxu_fprintf(cfile, "\n");
		for	(i = 0;	i	<	depth; i++)
		{
			nxu_fprintf(cfile, "		");
		}
		nxu_fprintf(cfile, "<![CDATA[");
		nxu_fprintf(cfile, "%s", value.c_str()); //	unformatted	output
		nxu_fprintf(cfile, "]]>\n");
	}
	else
	{
		TIXML_STRING buffer;
		PutString(value, &buffer);
		nxu_fprintf(cfile, "%s", buffer.c_str());
	}
}
Beispiel #7
0
void TiXmlElement::Print(NXU_FILE	*cfile,	int	depth)const
{
	int	i;
	for	(i = 0;	i	<	depth; i++)
	{
		nxu_fprintf(cfile, "		");
	}

	nxu_fprintf(cfile, "<%s",	value.c_str());

	const	TiXmlAttribute *attrib;
	for	(attrib	=	attributeSet.First();	attrib;	attrib = attrib->Next())
	{
		nxu_fprintf(cfile, " ");
		attrib->Print(cfile, depth);
	}

	// There are 3 different formatting	approaches:
	// 1)	An element without children	is printed as	a	<foo />	node
	// 2)	An element with	only a text	child	is printed as	<foo>	text </foo>
	// 3)	An element with	children is	printed	on multiple	lines.
	TiXmlNode	*node;
	if (!firstChild)
	{
		nxu_fprintf(cfile, " />");
	}
	else if	(firstChild	== lastChild &&	firstChild->ToText())
	{
		nxu_fprintf(cfile, ">");
		firstChild->Print(cfile, depth + 1);
		nxu_fprintf(cfile, "</%s>",	value.c_str());
	}
	else
	{
		nxu_fprintf(cfile, ">");

		for	(node	=	firstChild;	node;	node = node->NextSibling())
		{
			if (!node->ToText())
			{
				nxu_fprintf(cfile, "\n");
			}
			node->Print(cfile, depth + 1);
		}
		nxu_fprintf(cfile, "\n");
		for	(i = 0;	i	<	depth; ++i)
		{
			nxu_fprintf(cfile, "		");
		}
		nxu_fprintf(cfile, "</%s>",	value.c_str());
	}
}