1 /*
2    Source File : InputAscii85DecodeStream.h
3 
4 
5    Copyright 2011 Gal Kahana PDFWriter
6 
7    Licensed under the Apache License, Version 2.0 (the "License");
8    you may not use this file except in compliance with the License.
9    You may obtain a copy of the License at
10 
11        http://www.apache.org/licenses/LICENSE-2.0
12 
13    Unless required by applicable law or agreed to in writing, software
14    distributed under the License is distributed on an "AS IS" BASIS,
15    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16    See the License for the specific language governing permissions and
17    limitations under the License.
18 
19 
20 */
21 #pragma once
22 
23 #include "EStatusCode.h"
24 #include "IByteReader.h"
25 
26 class InputAscii85DecodeStream : public IByteReader
27 {
28 public:
29 	InputAscii85DecodeStream(void);
30 	~InputAscii85DecodeStream(void);
31 
32 	// Note that assigning passes ownership on the stream, use Assign(NULL) to remove ownership
33 	InputAscii85DecodeStream(IByteReader* inSourceReader);
34 
35 	// Assigning passes ownership of the input stream to the decoder stream.
36 	// if you don't care for that, then after finishing with the decode, Assign(NULL).
37 	void Assign(IByteReader* inSourceReader);
38 
39 	// IByteReader implementation. note that "inBufferSize" determines how many
40 	// bytes will be placed in the Buffer...not how many are actually read from the underlying
41 	// encoded stream. got it?!
42 	virtual IOBasicTypes::LongBufferSizeType Read(IOBasicTypes::Byte* inBuffer,IOBasicTypes::LongBufferSizeType inBufferSize);
43 
44 	virtual bool NotEnded();
45 
46 private:
47 	IByteReader* mSourceStream;
48 
49 	bool mHitEnd;
50 	IOBasicTypes::Byte mBuffer[4];
51 	int mReadBufferSize;
52 	int mReadBufferIndex;
53 
54 	void ReadNextBuffer();
55 
56 };
57