Core: FilterStream features

git-svn-id: svn://ultimatepp.org/upp/trunk@7778 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2014-10-14 07:32:30 +00:00
parent 5cef0718ca
commit 30cea78e93
3 changed files with 25 additions and 4 deletions

View file

@ -13,6 +13,8 @@ void InFilterStream::Init()
ptr = rdlim = h;
in = NULL;
eof = false;
style = STRM_READ|STRM_LOADING;
SetLoading();
}
dword InFilterStream::Avail()
@ -100,7 +102,8 @@ void OutFilterStream::Init()
wrlim = ~buffer + 4096;
ptr = ~buffer;
out = NULL;
count = 0;
count = in_count = 0;
style = STRM_WRITE;
}
OutFilterStream::~OutFilterStream()
@ -122,11 +125,18 @@ void OutFilterStream::Close()
void OutFilterStream::FlushOut()
{
if(ptr != ~buffer) {
Filter(~buffer, (int)(ptr - ~buffer));
int sz = (int)(ptr - ~buffer);
in_count += sz;
Filter(~buffer, sz);
ptr = ~buffer;
}
}
int64 OutFilterStream::GetInCount() const
{
return buffer ? in_count + (int)(ptr - ~buffer) : in_count;
}
void OutFilterStream::_Put(int w)
{
FlushOut();

View file

@ -8,7 +8,7 @@ protected:
virtual dword _Get(void *data, dword size);
Vector<byte> buffer;
bool eof;
bool eof;
void Init();
void Fetch(int size);
@ -44,6 +44,7 @@ protected:
Buffer<byte> buffer;
int64 count;
int64 in_count;
void FlushOut();
dword Avail() { return dword(4096 - (ptr - ~buffer)); }
@ -56,6 +57,7 @@ public:
void Out(const void *ptr, int size);
int64 GetCount() const { return count; }
int64 GetInCount() const;
template <class F>
void Set(Stream& out_, F& filter) {

View file

@ -49,7 +49,16 @@ size), also keeps track of output bytes written (see GetCount).&]
[s4; &]
[s5;:OutFilterStream`:`:GetCount`(`)const: [@(0.0.255) int64]_[* GetCount]()_[@(0.0.255) co
nst]&]
[s2;%% Returns a number of bytes written to the output.&]
[s2;%% Returns a number of bytes written to the output stream (if
OutFilterStream is used for compression, this is the compressed
size). Note that this number is `'complete`' only after the OutFilterStream
is closed, because of buffering of data chunks.&]
[s3; &]
[s4; &]
[s5;:OutFilterStream`:`:GetInCount`(`)const: [@(0.0.255) int64]_[* GetInCount]()_[@(0.0.255) c
onst]&]
[s2;%% Returns a number of bytes written to OutFilterStream (if OutFilterStream
is used for compression, this is the uncompressed size).&]
[s3; &]
[s4;%% &]
[s5;:OutFilterStream`:`:Set`(Stream`&`,F`&`): [@(0.0.255) template]_<[@(0.0.255) class]_[*@4 F