tinyxml2 icon indicating copy to clipboard operation
tinyxml2 copied to clipboard

size of XMLtext?

Open martell opened this issue 13 years ago • 4 comments

Hi lee thanks for merging the update that I done. Im working on cocos2dx atm which uses tiny xml for its windows 8 platform.

Here is a function in the code

bool XmlSaxHander::Visit( const XMLText& text ) {

//CCLog("Visit %s",text.Value());
CCSAXParser::textHandler(m_ccsaxParserImp, (const CC_XML_CHAR *)text.Value(), text.ValueTStr().size());
return true;

}

now my issue is tinyxml2 doesnt have a .ValueTStr().size() function.

Any hints?

martell avatar Sep 12 '12 12:09 martell

If you just want to get the length of the text, you can use strlen( text.Value() ), because text.Value() just return a '\0' terminated char pointer.

sniperbat avatar Sep 12 '12 14:09 sniperbat

It would be straightforward to have method on StrPair (which in the underlying string class):

StrPair.Size() { GetStr(); return end-str; }

The GetStr() is just there to cause a flush.

The tedious part is this, in the API surface:

const char* Value()
int ValueSize();

or possibly:

const char* Value( int* size=0 );

Which is possibly a little better. Thoughts on whether that is a valuable API? (It's come up before.)

leethomason avatar Sep 12 '12 21:09 leethomason

const char* Value( int* size=0 ); +1

sniperbat avatar Sep 13 '12 00:09 sniperbat

+1 from me also Sorry for the late reply.

I got tinyxml2 working with cocos in an hour or so today in my free time

martell avatar Jan 24 '13 19:01 martell