summaryrefslogtreecommitdiffstats
path: root/hostTools/lzma/compress/OutByte.h
diff options
context:
space:
mode:
Diffstat (limited to 'hostTools/lzma/compress/OutByte.h')
-rw-r--r--hostTools/lzma/compress/OutByte.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/hostTools/lzma/compress/OutByte.h b/hostTools/lzma/compress/OutByte.h
new file mode 100644
index 0000000..dc9ff0a
--- /dev/null
+++ b/hostTools/lzma/compress/OutByte.h
@@ -0,0 +1,42 @@
+#ifndef __STREAM_OUTBYTE_H
+#define __STREAM_OUTBYTE_H
+
+#include "Portable.h"
+#include "IInOutStreams.h"
+
+namespace NStream {
+
+class COutByte
+{
+ BYTE *m_Buffer;
+ UINT32 m_Pos;
+ UINT32 m_BufferSize;
+ ISequentialOutStream* m_Stream;
+ UINT64 m_ProcessedSize;
+
+ void WriteBlock();
+public:
+ COutByte(UINT32 aBufferSize = (1 << 20));
+ ~COutByte();
+
+ void Init(ISequentialOutStream *aStream);
+ HRESULT Flush();
+
+ void WriteByte(BYTE aByte)
+ {
+ m_Buffer[m_Pos++] = aByte;
+ if(m_Pos >= m_BufferSize)
+ WriteBlock();
+ }
+ void WriteBytes(const void *aBytes, UINT32 aSize)
+ {
+ for (UINT32 i = 0; i < aSize; i++)
+ WriteByte(((const BYTE *)aBytes)[i]);
+ }
+
+ UINT64 GetProcessedSize() const { return m_ProcessedSize + m_Pos; }
+};
+
+}
+
+#endif