xref: /trunk/main/package/inc/ZipPackageBuffer.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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 _ZIP_PACKAGE_BUFFER_HXX
24 #define _ZIP_PACKAGE_BUFFER_HXX
25 
26 #include <com/sun/star/io/XOutputStream.hpp>
27 #include <com/sun/star/io/XSeekable.hpp>
28 #include <com/sun/star/io/XInputStream.hpp>
29 #ifndef _CPPUHELPER_IMPLBASE3_HXX
30 #include <cppuhelper/implbase3.hxx>
31 #endif
32 
33 class ZipPackage;
34 
35 class ZipPackageBuffer : public ::cppu::WeakImplHelper3
36 <
37     com::sun::star::io::XInputStream,
38     com::sun::star::io::XOutputStream,
39     com::sun::star::io::XSeekable
40 >
41 {
42 protected:
43     com::sun::star::uno::Sequence < sal_Int8 > m_aBuffer;
44     sal_Int64 m_nBufferSize, m_nEnd, m_nCurrent;
45     sal_Bool m_bMustInitBuffer;
46 public:
47     ZipPackageBuffer(sal_Int64 nNewBufferSize);
48     virtual ~ZipPackageBuffer(void);
49 
realloc(sal_Int32 nSize)50     inline void realloc ( sal_Int32 nSize ) { m_aBuffer.realloc ( nSize ); }
getConstArray() const51     inline const sal_Int8 * getConstArray () const { return m_aBuffer.getConstArray(); }
getSequence() const52     inline const com::sun::star::uno::Sequence < sal_Int8> getSequence () const { return m_aBuffer; }
53 
54     // XInputStream
55     virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead );
56     virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead );
57     virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip );
58     virtual sal_Int32 SAL_CALL available(  );
59     virtual void SAL_CALL closeInput(  );
60     // XOutputStream
61     virtual void SAL_CALL writeBytes( const ::com::sun::star::uno::Sequence< sal_Int8 >& aData );
62     virtual void SAL_CALL flush(  );
63     virtual void SAL_CALL closeOutput(  );
64     // XSeekable
65     virtual void SAL_CALL seek( sal_Int64 location );
66     virtual sal_Int64 SAL_CALL getPosition(  );
67     virtual sal_Int64 SAL_CALL getLength(  );
68 };
69 #endif
70