~ubuntu-branches/ubuntu/precise/p7zip/precise-updates

« back to all changes in this revision

Viewing changes to CPP/7zip/Common/InBuffer.h

  • Committer: Bazaar Package Importer
  • Author(s): Mohammed Adnène Trojette
  • Date: 2009-02-14 20:12:27 UTC
  • mfrom: (1.1.11 upstream) (2.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090214201227-go63qxm9ozfdma60
Tags: 4.65~dfsg.1-1
* New upstream release.
* Remove wx2.8 Build-Depends added by mistakes (7zG is not yet
  intended to be built).
* Use dh_clean without -k.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
#include "../../Common/MyException.h"
9
9
 
10
10
#ifndef _NO_EXCEPTIONS
11
 
struct CInBufferException: public CSystemException 
 
11
struct CInBufferException: public CSystemException
12
12
{
13
 
  CInBufferException(HRESULT errorCode): CSystemException(errorCode) {} 
 
13
  CInBufferException(HRESULT errorCode): CSystemException(errorCode) {}
14
14
};
15
15
#endif
16
16
 
44
44
 
45
45
  bool ReadByte(Byte &b)
46
46
  {
47
 
    if(_buffer >= _bufferLimit)
48
 
      if(!ReadBlock())
 
47
    if (_buffer >= _bufferLimit)
 
48
      if (!ReadBlock())
49
49
        return false;
50
50
    b = *_buffer++;
51
51
    return true;
52
52
  }
53
53
  Byte ReadByte()
54
54
  {
55
 
    if(_buffer >= _bufferLimit)
 
55
    if (_buffer >= _bufferLimit)
56
56
      return ReadBlock2();
57
57
    return *_buffer++;
58
58
  }
59
 
  void ReadBytes(void *data, UInt32 size, UInt32 &processedSize)
60
 
  {
61
 
    for(processedSize = 0; processedSize < size; processedSize++)
62
 
      if (!ReadByte(((Byte *)data)[processedSize]))
63
 
        return;
64
 
  }
65
 
  bool ReadBytes(void *data, UInt32 size)
66
 
  {
67
 
    UInt32 processedSize;
68
 
    ReadBytes(data, size, processedSize);
69
 
    return (processedSize == size);
 
59
  UInt32 ReadBytes(Byte *buf, UInt32 size)
 
60
  {
 
61
    if ((UInt32)(_bufferLimit - _buffer) >= size)
 
62
    {
 
63
      for (UInt32 i = 0; i < size; i++)
 
64
        buf[i] = _buffer[i];
 
65
      _buffer += size;
 
66
      return size;
 
67
    }
 
68
    for (UInt32 i = 0; i < size; i++)
 
69
    {
 
70
      if (_buffer >= _bufferLimit)
 
71
        if (!ReadBlock())
 
72
          return i;
 
73
      buf[i] = *_buffer++;
 
74
    }
 
75
    return size;
70
76
  }
71
77
  UInt64 GetProcessedSize() const { return _processedSize + (_buffer - _bufferBase); }
72
78
  bool WasFinished() const { return _wasFinished; }