Jump to content

[SOLVED] Spaces confuse XML::setStringArrayData / getStringArrayData


photo

Recommended Posts

Xml::setStringArrayData writes out each String element of the provided array in the form of comma-separated values. If a String has spaces, those spaces are preserved. However, when Xml::getStringArrayData reads this data back in, the space characters seem to be treated as delimiters and what was originally a single element is broken into multiple. This seems like a bug. Should I be doing something differently?

Link to comment

Hi Adam,

 

As a fix, you can try to patch source/engine/common/XmlParser.cpp (two methods Xml::getStringArrayArg should look like this):

int Xml::getStringArrayArg(const char *name,Vector<String> &dest) const {
	dest.clear();
	const char *s = getArg(name);
	const char *to;
	while((to = strchr(s,',')) != NULL) {
		dest.append(String::substr(s,0,(int)(to - s)));
		s = to + 1;
	}
	dest.append(s);
	return 1;
}
int Xml::getStringArrayData(Vector<String> &dest) const {
	dest.clear();
	const char *s = getData();
	const char *to;
	while((to = strchr(s,',')) != NULL) {
		dest.append(String::substr(s,0,(int)(to - s)));
		s = to + 1;
	}
	dest.append(s);
	return 1;
}

If this fix will be useful in your use-case we will include it in the upcoming Unigine SDK 2.3 update.

 

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
  • 1 year later...

The 2.3.1 version of ColladaImport.cpp appears to depend on the former behaviour. The spaces in the <p/> tags in our <polygons/> data aren't separating the numbers anymore. Please advise.

Link to comment

Hi Greg,

Thanks for the report. The fastest solution I guess will be to patch getStringArrayData() so it could work with space delimiters optionally (default is ",") and than do the fixes in ColladaImport.cpp as well.

We can try to do this right now (or you can do it on your side since you also have an access to the engine sources).

 

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
×
×
  • Create New...