~ubuntu-branches/ubuntu/trusty/advancecomp/trusty

« back to all changes in this revision

Viewing changes to 7z/OutByte.h

  • Committer: Bazaar Package Importer
  • Author(s): Piotr Ozarowski
  • Date: 2006-05-13 21:15:49 UTC
  • Revision ID: james.westby@ubuntu.com-20060513211549-2vu7peis643ojcm5
Tags: upstream-1.15
ImportĀ upstreamĀ versionĀ 1.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef __STREAM_OUTBYTE_H
 
2
#define __STREAM_OUTBYTE_H
 
3
 
 
4
#include "Portable.h"
 
5
#include "IInOutStreams.h"
 
6
 
 
7
namespace NStream {
 
8
 
 
9
class COutByte
 
10
{
 
11
  BYTE *m_Buffer;
 
12
  INT m_Pos;
 
13
  INT m_BufferSize;
 
14
  ISequentialOutStream* m_Stream;
 
15
  UINT64 m_ProcessedSize;
 
16
 
 
17
  void WriteBlock();
 
18
public:
 
19
  COutByte(INT aBufferSize = (1 << 20));
 
20
  ~COutByte();
 
21
 
 
22
  void Init(ISequentialOutStream *aStream);
 
23
  HRESULT Flush();
 
24
 
 
25
  void WriteByte(BYTE aByte)
 
26
  {
 
27
    m_Buffer[m_Pos++] = aByte;
 
28
    if(m_Pos >= m_BufferSize)
 
29
      WriteBlock();
 
30
  }
 
31
  void WriteBytes(const void *aBytes, INT aSize)
 
32
  {
 
33
    for (INT i = 0; i < aSize; i++)
 
34
      WriteByte(((const BYTE *)aBytes)[i]);
 
35
  }
 
36
 
 
37
  UINT64 GetProcessedSize() const { return m_ProcessedSize + m_Pos; }
 
38
};
 
39
 
 
40
}
 
41
 
 
42
#endif