File:
[ELWIX - Embedded LightWeight unIX -] /
elwix /
tools /
oldlzma /
SRC /
7zip /
Common /
OutBuffer.h
Revision
1.1.1.1 (vendor branch):
download - view:
text,
annotated -
select for diffs -
revision graph
Tue May 14 09:04:51 2013 UTC (11 years, 11 months ago) by
misho
Branches:
misho,
elwix1_9_mips,
MAIN
CVS tags:
start,
elwix2_8,
elwix2_7,
elwix2_6,
elwix2_3,
elwix2_2,
HEAD,
ELWIX2_7,
ELWIX2_6,
ELWIX2_5,
ELWIX2_2p0
oldlzma needs for uboot
// OutBuffer.h
#ifndef __OUTBUFFER_H
#define __OUTBUFFER_H
#include "../IStream.h"
#include "../../Common/MyCom.h"
#ifndef _NO_EXCEPTIONS
struct COutBufferException
{
HRESULT ErrorCode;
COutBufferException(HRESULT errorCode): ErrorCode(errorCode) {}
};
#endif
class COutBuffer
{
Byte *_buffer;
UInt32 _pos;
UInt32 _bufferSize;
CMyComPtr<ISequentialOutStream> _stream;
UInt64 _processedSize;
void WriteBlock();
public:
#ifdef _NO_EXCEPTIONS
HRESULT ErrorCode;
#endif
COutBuffer(): _buffer(0), _pos(0), _stream(0) {}
~COutBuffer() { Free(); }
bool Create(UInt32 bufferSize);
void Free();
void SetStream(ISequentialOutStream *stream);
void Init();
HRESULT Flush();
void ReleaseStream() { _stream.Release(); }
/*
void *GetBuffer(UInt32 &sizeAvail)
{
sizeAvail = _bufferSize - _pos;
return _buffer + _pos;
}
void MovePos(UInt32 num)
{
_pos += num;
if(_pos >= _bufferSize)
WriteBlock();
}
*/
void WriteByte(Byte b)
{
_buffer[_pos++] = b;
if(_pos >= _bufferSize)
WriteBlock();
}
void WriteBytes(const void *data, UInt32 size)
{
for (UInt32 i = 0; i < size; i++)
WriteByte(((const Byte *)data)[i]);
}
UInt64 GetProcessedSize() const { return _processedSize + _pos; }
};
#endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>