InputStream: "protect" attributes

This commit is contained in:
Max Kellermann
2014-05-11 18:34:09 +02:00
parent e138e2c880
commit 0b4fa41aff
14 changed files with 53 additions and 37 deletions

View File

@@ -64,6 +64,7 @@ public:
*/
Cond &cond;
protected:
/**
* indicates whether the stream is ready for reading and
* whether the other attributes in this struct are valid
@@ -80,7 +81,6 @@ public:
*/
offset_type size;
public:
/**
* the current offset within the stream
*/
@@ -217,6 +217,13 @@ public:
mime = _mime;
}
gcc_pure
bool KnownSize() const {
assert(ready);
return size >= 0;
}
gcc_pure
offset_type GetSize() const {
assert(ready);
@@ -239,6 +246,15 @@ public:
return offset;
}
gcc_pure
offset_type GetRest() const {
assert(ready);
assert(size >= 0);
assert(offset >= 0);
return size - offset;
}
gcc_pure
bool IsSeekable() const {
assert(ready);