Debian Codegraph @

ucb/source/ucp/file/filstr.hxx

raw
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 #pragma once
20
21 #include <rtl/ustring.hxx>
22 #include <com/sun/star/io/XSeekable.hpp>
23 #include <com/sun/star/io/XTruncate.hpp>
24 #include <com/sun/star/io/XInputStream.hpp>
25 #include <com/sun/star/io/XOutputStream.hpp>
26 #include <com/sun/star/io/XStream.hpp>
27 #include <com/sun/star/io/XAsyncOutputMonitor.hpp>
28 #include <com/sun/star/lang/XUnoTunnel.hpp>
29 #include <comphelper/bytereader.hxx>
30 #include <cppuhelper/implbase.hxx>
31 #include <mutex>
32
33 #include "filrec.hxx"
34
35 enum class TaskHandlerErr;
36
37 namespace fileaccess {
38
39 class XStream_impl : public cppu::WeakImplHelper<
40 css::io::XStream,
41 css::io::XSeekable,
42 css::io::XInputStream,
43 css::io::XOutputStream,
44 css::io::XTruncate,
45 css::io::XAsyncOutputMonitor >,
46 public comphelper::ByteReader
47 {
48
49 public:
50
51 XStream_impl( const OUString& aUncPath, bool bLock );
52
53 /**
54 * Returns an error code as given by filerror.hxx
55 */
56
57 TaskHandlerErr CtorSuccess() const { return m_nErrorCode;}
58 sal_Int32 getMinorError() const { return m_nMinorErrorCode;}
59
60 virtual ~XStream_impl() override;
61
62 // XStream
63
64 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL
65 getInputStream() override;
66
67 virtual css::uno::Reference< css::io::XOutputStream > SAL_CALL
68 getOutputStream() override;
69
70
71 // XTruncate
72
73 virtual void SAL_CALL truncate() override;
74
75
76 // XInputStream
77
78 sal_Int32 SAL_CALL
79 readBytes(
80 css::uno::Sequence< sal_Int8 >& aData,
81 sal_Int32 nBytesToRead ) override;
82
83 sal_Int32 SAL_CALL
84 readSomeBytes(
85 css::uno::Sequence< sal_Int8 >& aData,
86 sal_Int32 nMaxBytesToRead ) override;
87
88
89 void SAL_CALL
90 skipBytes( sal_Int32 nBytesToSkip ) override;
91
92 sal_Int32 SAL_CALL
93 available() override;
94
95 void SAL_CALL
96 closeInput() override;
97
98 // XSeekable
99
100 void SAL_CALL
101 seek( sal_Int64 location ) override;
102
103 sal_Int64 SAL_CALL
104 getPosition() override;
105
106 sal_Int64 SAL_CALL
107 getLength() override;
108
109
110 // XOutputStream
111
112 void SAL_CALL
113 writeBytes( const css::uno::Sequence< sal_Int8 >& aData ) override;
114
115
116 void SAL_CALL
117 flush() override;
118
119
120 void SAL_CALL
121 closeOutput() override;
122
123 virtual void SAL_CALL waitForCompletion() override;
124
125 // utl::ByteReader
126 virtual sal_Int32
127 readSomeBytes(
128 sal_Int8* aData,
129 sal_Int32 nMaxBytesToRead ) override;
130
131 private:
132
133 std::mutex m_aMutex;
134 bool m_bInputStreamCalled,m_bOutputStreamCalled;
135 bool m_nIsOpen;
136
137 ReconnectingFile m_aFile;
138
139 TaskHandlerErr m_nErrorCode;
140 sal_Int32 m_nMinorErrorCode;
141
142 // Implementation methods
143
144 /// @throws css::io::NotConnectedException
145 /// @throws css::io::IOException
146 /// @throws css::uno::RuntimeException
147 void
148 closeStream();
149
150 };
151
152 } // end namespace XStream_impl
153
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */