The dump_to_stdout example from the TinyXML tutorial does not work with TinyXML++.

已查看 326 次
跳至第一个未读帖子

KimJarvis

未读,
2009年7月2日 15:31:302009/7/2
收件人 TinyXML++
The dump_to_stdout example from the TinyXML tutorial does not work
with TinyXML++.

Using tinyxml_2_4_2 with TinyXML++ from the read only repository. The
checks in xmltest.cpp completed successfully. However:

The tutorial example with headers:

#define TIXML_USE_TICPP
#include "tinyxml/ticpp.h"

Produces:

example.xml:
Document
+ Declaration
+ Element [Hello]

The tutorial example with headers:

//#define TIXML_USE_STL
//#include "tinyxml/tinyxml.h"

example.xml:
Document
+ Declaration
+ Element [Hello]
(No attributes)
+ Text: [World]

The error occurs in tinystr.h
// Convert a TiXmlString into a null-terminated char *
const char * c_str () const { return rep_->str; }

The line of the example being executed is:
printf( "%s%s: value=[%s]", pIndent, pAttrib->Name(), pAttrib->Value
());

Ryan Pusztai

未读,
2009年7月2日 20:41:102009/7/2
收件人 ti...@googlegroups.com
I think that is part of TinyXML and not of TinyXML++ so I think you should post this bug on there mailing list. Unless I misunderstand you. We wrap TinyXML so if there is a tutorial that is specific to just TinyXML then we don't touch it.

The TinyXML++ example should work flawlessly. Let me know if you have othre thoughts.
--
Regards,
Ryan

KimJarvis

未读,
2009年7月6日 12:24:462009/7/6
收件人 TinyXML++
This problem is specific to TinyXML++. The problem is that the
TinyXML copy-and-paste demo program from the tutorial fails during
execution when TIXML_USE_TICPP is defined.

http://www.grinninglizard.com/tinyxmldocs/tutorial0.html

It is my understanding that TinyXML++ is a wrapper and that programs
using tinyXML, but not the TinyXML++ features, should execute whether
TIXML_USE_TICPP is defined or not. Maybe my understanding of what is
meant by wrapper function in this case is incorrect?

I tried using both the GCC and intel compilers and got the same
problem. As noted above the installation is correct and the
xmltest.cpp program completes without errors.

In the tutorial example routine:

int dump_attribs_to_stdout(TiXmlElement* pElement, unsigned int
indent)
{
if ( !pElement ) return 0;
TiXmlAttribute* pAttrib=pElement->FirstAttribute();

Returns a bad value for the pointer to the attributes.

The cause of this problem is in tinyxml.h
TiXmlAttribute* First() { return ( sentinel.next ==
&sentinel ) ? 0 : sentinel.next; }
Where sentinel.next is junk, causing the program to behave as if there
is an attribute when there is not. The subsequent attempt to print
the attribute fails as described in my first post.

When the definition of TIXML_USE_TICPP is removed the program
correctly determines that there are no attributes.







Ryan Pusztai

未读,
2009年7月6日 17:08:042009/7/6
收件人 ti...@googlegroups.com
OK. now I understand, can you please make this an issue in the GoogleCode issue tracker so we can track this properly.
--
Regards,
Ryan

KimJarvis

未读,
2009年7月7日 07:30:182009/7/7
收件人 TinyXML++
Created ticpp issue 52 to track this problem.
回复全部
回复作者
转发
0 个新帖子