1 /*
2    Source File : InputLimitedStream.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 "IByteReader.h"
24 
25 class InputLimitedStream : public IByteReader
26 {
27 public:
28 	InputLimitedStream();
29 	virtual ~InputLimitedStream(void);
30 
31 	// K. with this one (just cause i'm tired of this ownership thing) i'm trying something new - to flag ownership.
32 	// So make good use of this last flag
33 	InputLimitedStream(IByteReader* inSourceStream,IOBasicTypes::LongFilePositionType inReadLimit,bool inOwnsStream);
34 
35 	void Assign(IByteReader* inSourceStream,IOBasicTypes::LongFilePositionType inReadLimit,bool inOwnsStream);
36 
37 	virtual IOBasicTypes::LongBufferSizeType Read(IOBasicTypes::Byte* inBuffer,IOBasicTypes::LongBufferSizeType inBufferSize);
38 	virtual bool NotEnded();
39 
40 private:
41 
42 	bool mOwnsStream;
43 	IByteReader* mStream;
44 	IOBasicTypes::LongFilePositionType mMoreToRead;
45 };
46