27#if defined HAVE_CONFIG_H
40 ID3D_NOTICE(
"WindowedReader::setWindow() [beg, size] = [" <<
41 this->
getBeg() <<
", " << size <<
"]" );
45 this->
setEnd(_reader.getEnd());
53 ID3D_NOTICE(
"WindowedReader::setWindow(): after setCur(beg), cur = "<<
57 ID3D_NOTICE(
"WindowedReader::setWindow(): after skipChars, cur = " <<
62 ID3D_NOTICE(
"WindowedReader::setWindow() [beg, cur, end] = [" << this->
getBeg() <<
", " << this->
getCur() <<
", " << this->
getEnd() <<
"]" );
73 if (beg <= this->
getEnd() && beg >= _reader.getBeg())
77 else if (beg > this->
getEnd())
79 ID3D_WARNING(
"WindowedReader::setBeg() failed, [beg, _end] = " <<
80 beg <<
", " << this->
getEnd() <<
"]" );
84 ID3D_WARNING(
"WindowedReader::setBeg() failed, [beg, _beg] = " <<
85 beg <<
", " << this->
getBeg() <<
"]" );
94 if (this->
getBeg() <= end && end <= _reader.getEnd())
100 ID3D_WARNING(
"WindowedReader::setEnd() failed, end = " << end );
101 ID3D_WARNING(
"WindowedReader::setEnd() failed, beg = " <<
103 ID3D_WARNING(
"WindowedReader::setEnd() failed, super.end = " <<
113 if (this->inWindow())
115 ch = _reader.readChar();
119 ID3D_WARNING(
"io::WindowedReader::readChar: not in window, " <<
120 "pos = " << this->
getCur() <<
", window = [" <<
129 if (this->inWindow())
131 ch = _reader.peekChar();
140 if (this->inWindow(cur))
150 ID3D_NOTICE(
"CharReader::readChars(): len = " << len );
151 for (; numChars < len; ++numChars)
163 ID3D_NOTICE(
"CharReader::readChars(): numChars = " << len );
174 if (ch == 0x0D && this->
peekChar() == 0x0A)
176 ID3D_NOTICE(
"LineFeedReader::readChar(): found CRLF at pos " <<
190 if (ch == 0xFF && this->
peekChar() == 0x00)
192 ID3D_NOTICE(
"UnsyncedReader::readChar(): found sync at pos " <<
206 ::uncompress(_uncompressed,
207 reinterpret_cast<luint*
>(&newSize),
208 reinterpret_cast<const uchar*
>(binary.data()),
215 delete [] _uncompressed;
220 if (_last == 0xFF && (ch == 0x00 || ch >= 0xE0))
222 _writer.writeChar(
'\0');
225 _last = _writer.writeChar(ch);
233 _last = _writer.writeChar(
'\0');
243 ID3D_NOTICE(
"UnsyncedWriter::writeChars(): len = " << len );
244 for (
size_t i = 0; i < len; ++i)
253 ID3D_NOTICE(
"CharWriter::writeChars(): numChars = " << numChars );
259 if (_data.size() == 0)
265 _origSize = dataSize;
269 unsigned long newDataSize = dataSize + (dataSize / 10) + 12;
271 if (::compress(newData, &newDataSize, data, dataSize) != Z_OK)
274 ID3D_WARNING(
"io::CompressedWriter: error compressing");
275 _writer.writeChars(data, dataSize);
277 else if (newDataSize < dataSize)
279 ID3D_NOTICE(
"io::CompressedWriter: compressed size = " << newDataSize <<
", original size = " << dataSize );
280 _writer.writeChars(newData, newDataSize);
284 ID3D_NOTICE(
"io::CompressedWriter: no compression!compressed size = " << newDataSize <<
", original size = " << dataSize );
285 _writer.writeChars(data, dataSize);
294 ID3D_NOTICE(
"io::CompressedWriter: writing chars: " << len );
295 _data.append(buf, len);
void setBuffer(const char_type *buf, size_type size)
virtual size_type skipChars(size_type len)
Skip up to len chars in the stream and advance the internal position accordingly.
static const int_type END_OF_READER
virtual int_type readChar()
Read a single character and advance the internal position.
virtual size_type remainingBytes()
int_type peekChar()
Return the next character to be read without advancing the internal position.
size_type readChars(char_type buf[], size_type len)
Read len characters into the array buf.
pos_type getCur()
Return the current position in the reader.
CompressedReader(ID3_Reader &reader, size_type newSize)
virtual ~CompressedReader()
void flush()
Flush the writer.
size_type writeChars(const char_type buf[], size_type len)
Write up to len characters into buf and advance the internal position accordingly.
int_type readChar()
Read a single character and advance the internal position.
int_type readChar()
Read a single character and advance the internal position.
int_type writeChar(char_type ch)
Write a single character and advance the internal position.
size_type writeChars(const char_type[], size_type len)
Write len characters into the array buf.
void flush()
Flush the writer.
pos_type getCur()
Return the next position that will be written to.
pos_type getCur()
Return the current position in the reader.
int_type peekChar()
Return the next character to be read without advancing the internal position.
void setWindow(pos_type beg, size_type size)
pos_type getBeg()
Return the beginning position in the reader.
pos_type setCur(pos_type cur)
Set the value of the current position for reading.
pos_type getEnd()
Return the ending position in the reader.
pos_type setBeg(pos_type)
size_type readChars(char_type buf[], size_type len)
Read up to len characters into buf and advance the internal position accordingly.
pos_type setEnd(pos_type)
int_type readChar()
Read a single character and advance the internal position.
ID3_C_EXPORT BString readBinary(ID3_Reader &, size_t)