Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef INCLUDED_PACKAGE_INC_BYTEGRABBER_HXX
20 : #define INCLUDED_PACKAGE_INC_BYTEGRABBER_HXX
21 :
22 : #include <com/sun/star/uno/Sequence.h>
23 : #include <com/sun/star/uno/Reference.h>
24 : #include <com/sun/star/io/BufferSizeExceededException.hpp>
25 : #include <com/sun/star/io/IOException.hpp>
26 : #include <com/sun/star/io/NotConnectedException.hpp>
27 : #include <com/sun/star/uno/RuntimeException.hpp>
28 : #include <com/sun/star/lang/IllegalArgumentException.hpp>
29 :
30 : #include <osl/mutex.hxx>
31 :
32 : namespace com { namespace sun { namespace star {
33 : namespace io { class XSeekable; class XInputStream; }
34 : } } }
35 : class ByteGrabber
36 : {
37 : protected:
38 : ::osl::Mutex m_aMutex;
39 :
40 : com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xStream;
41 : com::sun::star::uno::Reference < com::sun::star::io::XSeekable > xSeek;
42 : com::sun::star::uno::Sequence < sal_Int8 > aSequence;
43 : const sal_Int8 *pSequence;
44 :
45 : public:
46 : ByteGrabber (com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xIstream);
47 : ~ByteGrabber();
48 :
49 : void setInputStream (com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xNewStream);
50 : // XInputStream
51 : sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
52 : throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
53 : // XSeekable
54 : sal_Int64 SAL_CALL seek( sal_Int64 location )
55 : throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
56 : sal_Int64 SAL_CALL getPosition( )
57 : throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
58 : sal_Int64 SAL_CALL getLength( )
59 : throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
60 :
61 : sal_uInt16 ReadUInt16();
62 : sal_uInt32 ReadUInt32();
63 271015 : sal_Int16 ReadInt16()
64 : {
65 271015 : return static_cast<sal_Int16>(ReadUInt16());
66 : }
67 295151 : sal_Int32 ReadInt32()
68 : {
69 295151 : return static_cast<sal_Int32>(ReadUInt32());
70 : }
71 : };
72 :
73 : #endif
74 :
75 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|