xref: /aoo42x/main/package/inc/ByteGrabber.hxx (revision f319bb99)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  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,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _BYTE_GRABBER_HXX_
24 #define _BYTE_GRABBER_HXX_
25 
26 #include <com/sun/star/uno/Sequence.h>
27 #include <com/sun/star/uno/Reference.h>
28 #include <com/sun/star/io/BufferSizeExceededException.hpp>
29 #include <com/sun/star/io/IOException.hpp>
30 #include <com/sun/star/io/NotConnectedException.hpp>
31 #include <com/sun/star/uno/RuntimeException.hpp>
32 #include <com/sun/star/lang/IllegalArgumentException.hpp>
33 
34 #include <osl/mutex.hxx>
35 
36 namespace com { namespace sun { namespace star {
37 	namespace io { class XSeekable; class XInputStream; }
38 } } }
39 class ByteGrabber
40 {
41 protected:
42     ::osl::Mutex m_aMutex;
43 
44 	com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xStream;
45 	com::sun::star::uno::Reference < com::sun::star::io::XSeekable > xSeek;
46 	com::sun::star::uno::Sequence < sal_Int8 > aSequence;
47 	const sal_Int8 *pSequence;
48 
49 public:
50 	ByteGrabber (com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xIstream);
51 	~ByteGrabber();
52 
53 	void setInputStream (com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xNewStream);
54 	// XInputStream
55     sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
56 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
57 	// XSeekable
58     sal_Int64 SAL_CALL seek( sal_Int64 location )
59 		throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
60     sal_Int64 SAL_CALL getPosition(  )
61 		throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
62     sal_Int64 SAL_CALL getLength(  )
63 		throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
64 
65 	ByteGrabber& operator >> (sal_Int8& rInt8);
66 	ByteGrabber& operator >> (sal_Int16& rInt16);
67 	ByteGrabber& operator >> (sal_Int32& rInt32);
68 	ByteGrabber& operator >> (sal_uInt8& ruInt8);
69 	ByteGrabber& operator >> (sal_uInt16& ruInt16);
70 	ByteGrabber& operator >> (sal_uInt32& ruInt32);
71 };
72 
73 #endif
74