mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
Core: InFilterStream FilterEof
git-svn-id: svn://ultimatepp.org/upp/trunk@11768 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
ae0c3e65f5
commit
8d31e7d78c
5 changed files with 19 additions and 8 deletions
|
|
@ -88,8 +88,10 @@ void InFilterStream::Fetch()
|
|||
End();
|
||||
eof = true;
|
||||
}
|
||||
else
|
||||
else {
|
||||
Filter(~inbuffer, n);
|
||||
eof = FilterEof();
|
||||
}
|
||||
}
|
||||
}
|
||||
Stream::buffer = ptr = buffer.begin();
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ private:
|
|||
public:
|
||||
Stream *in;
|
||||
Event<const void *, int> Filter;
|
||||
Gate<> FilterEof;
|
||||
Event<> End;
|
||||
Gate<> More;
|
||||
void Out(const void *ptr, int size);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
topic "InFilterStream";
|
||||
[2 $$0,0#00000000000000000000000000000000:Default]
|
||||
[i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class]
|
||||
[l288;2 $$2,2#27521748481378242620020725143825:desc]
|
||||
[0 $$3,0#96390100711032703541132217272105:end]
|
||||
|
|
@ -9,6 +8,7 @@ topic "InFilterStream";
|
|||
[l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param]
|
||||
[i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam]
|
||||
[b42;2 $$9,9#13035079074754324216151401829390:normal]
|
||||
[2 $$0,0#00000000000000000000000000000000:Default]
|
||||
[{_}
|
||||
[ {{10000@(113.42.0) [s0;%% [*@7;4 InFilterStream]]}}&]
|
||||
[s0;i448;a25;kKO9;@(0.0.255) &]
|
||||
|
|
@ -29,6 +29,12 @@ to be filtered.&]
|
|||
[s2;%% Callback to filter input function.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:InFilterStream`:`:FilterEof: [_^Upp`:`:Gate^ Gate]<>_[* FilterEof]&]
|
||||
[s2;%% In some cases, there is a logical end of filtered stream before
|
||||
the end of `'real`' stream. This Gate serves as signal of such
|
||||
situation.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:InFilterStream`:`:End: [_^Callback^ Callback]_[* End]&]
|
||||
[s2;%% Callback to filter finalization. This is invoked by InFilterStream
|
||||
when it reaches the end of input stream. It gives chance to the
|
||||
|
|
|
|||
|
|
@ -75,12 +75,12 @@ namespace bz2 {
|
|||
Lib z;
|
||||
|
||||
public:
|
||||
void Open(Stream& in) { z.Decompress(); Set(in, z); }
|
||||
void Open(Stream& in, bool all = true) { z.Decompress(all); Set(in, z); FilterEof = [=]() -> bool { return z.IsEOS(); }; }
|
||||
Lib& ChunkSize(int n) { return z.ChunkSize(n); }
|
||||
|
||||
DecompressStream() {}
|
||||
DecompressStream(Stream& out) { Open(out); }
|
||||
~DecompressStream() { Close(); }
|
||||
DecompressStream() {}
|
||||
DecompressStream(Stream& out, bool all = true) { Open(out, all); }
|
||||
~DecompressStream() { Close(); }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ namespace bz2 {
|
|||
if (mode == INFLATE) {
|
||||
z.avail_out = chunk;
|
||||
z.next_out = output;
|
||||
while (z.avail_in) {
|
||||
while (z.avail_in && !IsEOS()) {
|
||||
const int code = BZ2_bzDecompress(&z);
|
||||
const int count = chunk - z.avail_out;
|
||||
if(count) {
|
||||
|
|
@ -111,9 +111,10 @@ namespace bz2 {
|
|||
{
|
||||
if(error)
|
||||
return;
|
||||
// return false;
|
||||
LLOG("BZLIB Put " << size);
|
||||
const char *p = reinterpret_cast<const char *>(ptr);
|
||||
while(size) {
|
||||
while(size && !IsEOS()) {
|
||||
int psz = (int) min(size, INT_MAX / 4);
|
||||
if(mode == DEFLATE)
|
||||
total += size;
|
||||
|
|
@ -123,6 +124,7 @@ namespace bz2 {
|
|||
size -= psz;
|
||||
p += psz;
|
||||
}
|
||||
// return !IsEOS();
|
||||
}
|
||||
|
||||
void Lib::PutOut(const void *ptr, int size)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue