cocos2d-x与tinyXml的问题

system
Mon, 21 May 2012 02:02:58 +0000

bool TiXmlDocument::LoadFile()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
int i=0;

long length=0;
long *pSize=&length;

char* strdata =(char *)cocos2d::CCFileUtils::getFileData(value.c_str(),"r", (long unsigned int *)pSize);
char buf;
TIXML_STRING data;
data.reserve( length );
i=0;
for(;i<length;i++){
	buf*=strdata*;
}

const char* lastPos = buf;
const char* p = buf;

buf = 0;
while( *p ) {
	assert( p < (buf+length) );
	if ( *p == 0xa ) {
		data.append( lastPos, (p-lastPos+1) );
		++p;
		lastPos = p;
		assert( p <= (buf+length) );
	}
	else if ( *p == 0xd ) {

		if ( (p-lastPos) > 0 ) {
			data.append( lastPos, p-lastPos );
		}
		data += (char)0xa;

		if ( *(p+1) == 0xa ) {

			p += 2;
			lastPos = p;
			assert( p <= (buf+length) );
		}
		else {

			++p;
			lastPos = p;
			assert( p <= (buf+length) );
		}
	}
	else {
		++p;
	}
}

if ( p-lastPos ) {
	data.append( lastPos, p-lastPos );
}
Parse( data.c_str(), 0, TIXML_DEFAULT_ENCODING );
delete ]strdata;
if (  Error() )
    return false;
else
	return true;
#else
return LoadFile(Value());
#endif

}
**

阅读整个主题