[osg-users] Serialization differences between ASCII and XML
Robert Osfield
robert.osfield at gmail.com
Sat Dec 30 07:24:24 PST 2017
Hi Hartwig,
I'm not yet back to work so just quick reply. What you describe looks
like a bug, when I return to work I'll look into it, albeit as part of
queue of support issues that have accumulated this holiday...
What would help me is a small example that illustrates the problem so
I can reproduce it at my end. If your project is open sourced then a
link to the code that you are seeing a problem with would help as
well.
As a general comment, there are lots of helper macros for serializers
that can often avoid the need for custom user serializers, for
instance if your properties are a Vec4d you should be able to just use
the macros to read/write them. Have a look through the
OpenSceneGraph/src/osgWrappers/serialzers/osg for examples of this in
action.
Robert.
On 27 December 2017 at 17:49, Hartwig Wiesmann
<hartwig.wiesmann at skywind.eu> 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=72645#72645
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
More information about the osg-users
mailing list