New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
FRex opened this Issue Feb 2, 2013 · 2 comments

Comments

Projects
None yet
3 participants
@FRex
Contributor

FRex commented Feb 2, 2013

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.

@ghost ghost assigned LaurentGomila Feb 2, 2013

@MarioLiebisch

This comment has been minimized.

Show comment
Hide comment
@MarioLiebisch

MarioLiebisch Feb 2, 2013

Member

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?

Member

MarioLiebisch commented Feb 2, 2013

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

This comment has been minimized.

Show comment
Hide comment
@FRex

FRex Feb 2, 2013

Contributor
  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'.
Contributor

FRex commented Feb 2, 2013

  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 added a commit that referenced this issue May 9, 2013

LaurentGomila added a commit that referenced this issue May 9, 2013

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment