Hi Wang Rui,

On the topic of istream's not being ideal for rewinding to check for
previous token etc, this will be an real issue for istreams that don't
support random access, so for maximum flexibility we should work on
the principle that we want be able to just move to a particular point
in a istream and read, and instead will have to read sequentially
through the file.

This issue is something I did some thinking about in the
implementation of the include/osgDB/XmlParser and like you needed
something similar to the FieldReaderIterator to be able to look
ahead/back to decide what to do.  In the end rather than come up with
a clever scheme as I was originally expecting to need, I just loaded
the whole stream into an std::string and did the parsing from this
with all the capabilities of std::string that it brings.  It's not an
ideal approach as it doesn't scale to handle very large models, but it
got the job done without me getting bogged down.   My plan has been at
later date return to the parser to implement a better scheme that
caches only what is needed from the stream at any one time and
discards data once it's used.  Perhaps something like a deque would be
useful for this.

I raise this as perhaps we can come up with a parser helper class that
allows us to read istreams in a way that we can easily look
forward/back and have what we need cached for as long as we need it.
If we can do it in a generic way then both the XmlParser and your own
work can utilize it.

Robert.
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to