Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

sf::InputStream unclear assumptions about the derived class #349

Closed
FRex opened this Issue · 2 comments

3 participants

@FRex

SFML Class that uses input stream assume following things that are not clearly mentioned in documentation:
1. Instance passed to them has its' get pointer at 0 as if seek(0) was called or like standard streams in c++ and C do when they're freshly created.
2. When something is read() from the instance passed to it, the get pointer is advanced the same number of bytes as the returned number.

Possible fix:
1. Call seek(0) or use tell() to check if stream is at the beggining and call seek(0) if it's not.
2. That's quite understandable assumption and the way standard streams work so it should be enough to just document it.

@LaurentGomila LaurentGomila was assigned
@MarioLiebisch
Collaborator

Point 1: I don't think seeking would be the best option, because I'd consider this expected and intended behavior (so I'd probably add a note to the documentation, but no code change)

Point 2: What's wrong here or what can be misunderstood?

@FRex
  1. Loading twice from same memory or file works, loading twice from same stream will cause 'file corrupt' error. There is no reason to not seek to 0.
  2. It's not clear that 'read' is same as 'read and discard' or 'extract'.
@LaurentGomila LaurentGomila referenced this issue from a commit
@LaurentGomila LaurentGomila InputStream.hpp was missing from the source file listing in CMake fil…
…es, and added an important comment in the doc of InputStream::read (#349)
ae11207
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.