Branch libreoffice-5-0-4
[LibreOffice.git] / include / ucbhelper / std_inputstream.hxx
blobbb30206e4ba6878f09cbcb7e7defc7ebb61a89a2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #ifndef INCLUDED_UCBHELPER_STD_INPUTSTREAM_HXX
11 #define INCLUDED_UCBHELPER_STD_INPUTSTREAM_HXX
13 #include <boost/shared_ptr.hpp>
14 #include <istream>
16 #include <rtl/ustring.hxx>
17 #include <osl/mutex.hxx>
18 #include <cppuhelper/weak.hxx>
19 #include <cppuhelper/queryinterface.hxx>
20 #include <com/sun/star/io/XInputStream.hpp>
21 #include <com/sun/star/io/XSeekable.hpp>
23 #include <ucbhelper/ucbhelperdllapi.h>
25 namespace ucbhelper
27 /** Implements a seekable InputStream
28 * working on an std::istream
30 class UCBHELPER_DLLPUBLIC StdInputStream
31 : public cppu::OWeakObject,
32 public com::sun::star::io::XInputStream,
33 public com::sun::star::io::XSeekable
35 public:
37 StdInputStream( boost::shared_ptr< std::istream > pStream );
39 virtual ~StdInputStream();
41 virtual css::uno::Any SAL_CALL queryInterface ( const css::uno::Type& rType )
42 throw ( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
44 virtual void SAL_CALL acquire( ) throw ( ) SAL_OVERRIDE;
46 virtual void SAL_CALL release( ) throw ( ) SAL_OVERRIDE;
48 virtual sal_Int32 SAL_CALL
49 readBytes ( css::uno::Sequence< sal_Int8 >& aData,
50 sal_Int32 nBytesToRead )
51 throw ( css::io::NotConnectedException,
52 css::io::BufferSizeExceededException,
53 css::io::IOException,
54 css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
56 virtual sal_Int32 SAL_CALL
57 readSomeBytes ( css::uno::Sequence< sal_Int8 >& aData,
58 sal_Int32 nMaxBytesToRead )
59 throw ( css::io::NotConnectedException,
60 css::io::BufferSizeExceededException,
61 css::io::IOException,
62 css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
64 virtual void SAL_CALL
65 skipBytes ( sal_Int32 nBytesToSkip )
66 throw ( css::io::NotConnectedException,
67 css::io::BufferSizeExceededException,
68 css::io::IOException,
69 css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
71 virtual sal_Int32 SAL_CALL
72 available ( )
73 throw ( css::io::NotConnectedException,
74 css::io::IOException,
75 css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
77 virtual void SAL_CALL
78 closeInput ( )
79 throw ( css::io::NotConnectedException,
80 css::io::IOException,
81 css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
84 /** XSeekable
87 virtual void SAL_CALL
88 seek ( sal_Int64 location )
89 throw ( css::lang::IllegalArgumentException,
90 css::io::IOException,
91 css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
94 virtual sal_Int64 SAL_CALL
95 getPosition ( )
96 throw ( css::io::IOException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
99 virtual sal_Int64 SAL_CALL
100 getLength ( )
101 throw ( css::io::IOException,
102 css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
104 private:
106 osl::Mutex m_aMutex;
107 boost::shared_ptr< std::istream > m_pStream;
108 sal_Int64 m_nLength;
113 #endif
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */