[osg-users] Serialization differences between ASCII and XML

Julien Valentin julienvalentin51 at gmail.com
Fri Dec 29 00:18:37 PST 2017


Sorry for the false hope
removing newline ine osgDB::XMLNode::writeProperty would
forbid string property with newline...
How silly i am!!



mp3butcher wrote:
> Hi Hartwig
> I have no experience with osgx format
> But the bug seams to come from osgDB/XMLParser.cpp
> perhaps removing newline (with trimEnclosingSpaces) from strings in osgDB::XMLNode::writeString
> could to the trick...
> or better add newline in _characterToControlMap
> 
> You should make a pull request for this bug fix
> 
> Cheers
> 
> 
> hartwigw wrote:
> > Hi,
> > 
> > wrote a simple serialiser for the output of a range:
> > 
> > 
> > Code:
> > 
> > namespace
> > {
> > 	bool checkGeographicRange(osgPlanetCore::GeodeticData const&)
> > 	{
> > 		return true;
> > 	}
> > 
> > 	bool readGeographicRange(osgDB::InputStream& inputStream, osgPlanetCore::GeodeticData& geodeticData)
> > 	{
> > 		osgPlanetCore::GeographicRange geographicRange;
> > 
> > 
> > 		if (osgPlanetWrappers::readRange(inputStream,geographicRange))
> > 		{
> > 			geodeticData.setGeographicRange(geographicRange);
> > 			return true;
> > 		} /* if */
> > 		else
> > 			return false;
> > 	}
> > 	
> > 	bool writeGeographicRange(osgDB::OutputStream& outputStream, osgPlanetCore::GeodeticData const& geodeticData)
> > 	{
> > 		outputStream << std::endl;
> > 		return osgPlanetWrappers::writeRange(outputStream,geodeticData.getGeographicRange());
> > 	}
> > 
> > } /* namespace */
> > 
> > 	template < typename Values >
> > 	bool readRange(osgDB::InputStream& inputStream, osgPlanetCore::Range< Values >& range)
> > 	{
> > 		inputStream >> inputStream.BEGIN_BRACKET;
> > 		inputStream >> inputStream.PROPERTY("FromValues") >> range.getFromValues();
> > 		inputStream >> inputStream.PROPERTY("TillValues") >> range.getTillValues();
> > 		inputStream >> inputStream.END_BRACKET;
> > 		return true;
> > 	}
> > 	
> > 	template < typename Values >
> > 	bool writeRange(osgDB::OutputStream& outputStream, osgPlanetCore::Range< Values > const& range)
> > 	{
> > 		outputStream << outputStream.BEGIN_BRACKET << std::endl;
> > 		outputStream << outputStream.PROPERTY("FromValues") << range.getFromValues() << std::endl;
> > 		outputStream << outputStream.PROPERTY("TillValues") << range.getTillValues() << std::endl;
> > 		outputStream << outputStream.END_BRACKET << std::endl;
> > 		return true;
> > 	}
> > 
> > 
> > 
> > 
> > 
> > In a wrapper I call
> > 
> > Code:
> > 
> > 	ADD_USER_SERIALIZER(GeographicRange);
> > 
> > 
> > 
> > 
> > Basically serialisation should write / read two vectors indicating a lower and a higher limit of a geodetic range.
> > 
> > The ASCII output looks like:
> > 
> > GeographicRange 
> > {
> > FromValues -135 40.9799 -10000 
> > TillValues -90 66.5133 10000 
> > }
> > 
> > Which seems to be fine.
> > 
> > The XML output looks like:
> > 
> >           < FromValues attribute="-135 40.9799 -10000&nl;" >
> >             < TillValues attribute="-90 66.5133 10000&nl;&nl;" >
> >              < /TillValues >
> >           < /FromValues >
> > 
> > Which is not really the same. Besides the fact that "GeographicRange" is gone completely.
> > 
> > How do I make the output of both versions the same?
> > 
> > Cheers,
> > Hartwig
> 


------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=72650#72650







More information about the osg-users mailing list