LibreOffice Module store (master) 1
store.hxx
Go to the documentation of this file.
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
20#pragma once
21
22#include <store/store.h>
23#include <sal/types.h>
24#include <rtl/ustring.hxx>
25#include <store/types.h>
26
27namespace store
28{
29
31{
32public:
34 : m_hImpl (nullptr)
35 {}
36
38 {
39 if (m_hImpl)
41 }
42
44 : m_hImpl (rhs.m_hImpl)
45 {
46 if (m_hImpl)
48 }
49
51 {
52 if (rhs.m_hImpl)
53 (void) store_acquireHandle (rhs.m_hImpl);
54 if (m_hImpl)
56 m_hImpl = rhs.m_hImpl;
57 return *this;
58 }
59
64 storeFileHandle hFile,
65 OUString const & rPath,
66 OUString const & rName,
67 storeAccessMode eMode)
68 {
69 if (m_hImpl)
70 {
72 m_hImpl = nullptr;
73 }
74 return store_openStream (hFile, rPath.pData, rName.pData, eMode, &m_hImpl);
75 }
76
81 sal_uInt32 nOffset,
82 void * pBuffer,
83 sal_uInt32 nBytes,
84 sal_uInt32 & rnDone)
85 {
86 if (!m_hImpl)
88
89 return store_readStream (m_hImpl, nOffset, pBuffer, nBytes, &rnDone);
90 }
91
96 sal_uInt32 nOffset,
97 void const * pBuffer,
98 sal_uInt32 nBytes,
99 sal_uInt32 & rnDone)
100 {
101 if (!m_hImpl)
103
104 return store_writeStream (m_hImpl, nOffset, pBuffer, nBytes, &rnDone);
105 }
106
107private:
109};
110
112{
113public:
115 : m_hImpl (nullptr)
116 {}
117
119 {
120 if (m_hImpl)
122 }
123
125 : m_hImpl (rhs.m_hImpl)
126 {
127 if (m_hImpl)
129 }
130
132 : m_hImpl (rhs.m_hImpl)
133 {
134 rhs.m_hImpl = nullptr;
135 }
136
138 {
139 if (rhs.m_hImpl)
140 (void) store_acquireHandle (rhs.m_hImpl);
141 if (m_hImpl)
143 m_hImpl = rhs.m_hImpl;
144 return *this;
145 }
146
148 {
149 if (m_hImpl)
151 m_hImpl = rhs.m_hImpl;
152 rhs.m_hImpl = nullptr;
153 return *this;
154 }
155
160 storeFileHandle hFile,
161 OUString const & rPath,
162 OUString const & rName,
163 storeAccessMode eMode)
164 {
165 if (m_hImpl)
166 {
168 m_hImpl = nullptr;
169 }
170 return store_openDirectory (hFile, rPath.pData, rName.pData, eMode, &m_hImpl);
171 }
172
178
183 {
184 if (!m_hImpl)
186
187 return store_findFirst (m_hImpl, &it);
188 }
189
194 {
195 if (!m_hImpl)
197
198 return store_findNext (m_hImpl, &it);
199 }
200
201private:
203};
204
206{
207public:
209 : m_hImpl (nullptr)
210 {}
211
213 {
214 if (m_hImpl)
216 }
217
218 OStoreFile (OStoreFile const & rhs)
219 : m_hImpl (rhs.m_hImpl)
220 {
221 if (m_hImpl)
223 }
224
226 {
227 if (rhs.m_hImpl)
228 (void) store_acquireHandle (rhs.m_hImpl);
229 if (m_hImpl)
231 m_hImpl = rhs.m_hImpl;
232 return *this;
233 }
234
235 operator storeFileHandle() const
236 {
237 return m_hImpl;
238 }
239
243 bool isValid() const
244 {
245 return (m_hImpl != nullptr);
246 }
247
252 OUString const & rFilename,
253 storeAccessMode eAccessMode )
254 {
255 if (m_hImpl)
256 {
258 m_hImpl = nullptr;
259 }
260 return store_openFile (rFilename.pData, eAccessMode, STORE_DEFAULT_PAGESIZE, &m_hImpl);
261 }
262
267 {
268 if (m_hImpl)
269 {
271 m_hImpl = nullptr;
272 }
274 }
275
279 void close()
280 {
281 if (m_hImpl)
282 {
283 (void) store_closeFile (m_hImpl);
284 m_hImpl = nullptr;
285 }
286 }
287
292 {
293 if (!m_hImpl)
295
296 return store_flushFile (m_hImpl);
297 }
298
303 OUString const & rPath, OUString const & rName)
304 {
305 if (!m_hImpl)
307
308 return store_remove (m_hImpl, rPath.pData, rName.pData);
309 }
310
311private:
313};
314
315} // namespace store
316
317/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OStoreDirectory(OStoreDirectory const &rhs)
Definition: store.hxx:124
storeError next(iterator &it)
Find next directory entry.
Definition: store.hxx:193
storeFindData iterator
Directory iterator type.
Definition: store.hxx:177
storeDirectoryHandle m_hImpl
Definition: store.hxx:202
storeError create(storeFileHandle hFile, OUString const &rPath, OUString const &rName, storeAccessMode eMode)
Open the directory.
Definition: store.hxx:159
OStoreDirectory(OStoreDirectory &&rhs) noexcept
Definition: store.hxx:131
storeError first(iterator &it)
Find first directory entry.
Definition: store.hxx:182
OStoreDirectory & operator=(OStoreDirectory const &rhs)
Definition: store.hxx:137
storeError createInMemory()
Open the temporary file in memory.
Definition: store.hxx:266
storeFileHandle m_hImpl
Definition: store.hxx:312
storeError flush() const
Flush the file.
Definition: store.hxx:291
storeError create(OUString const &rFilename, storeAccessMode eAccessMode)
Open the file.
Definition: store.hxx:251
storeError remove(OUString const &rPath, OUString const &rName)
Remove a file entry.
Definition: store.hxx:302
void close()
Close the file.
Definition: store.hxx:279
OStoreFile(OStoreFile const &rhs)
Definition: store.hxx:218
OStoreFile & operator=(OStoreFile const &rhs)
Definition: store.hxx:225
bool isValid() const
Check for a valid File Handle.
Definition: store.hxx:243
OStoreStream(OStoreStream const &rhs)
Definition: store.hxx:43
OStoreStream & operator=(OStoreStream const &rhs)
Definition: store.hxx:50
storeStreamHandle m_hImpl
Definition: store.hxx:108
storeError writeAt(sal_uInt32 nOffset, void const *pBuffer, sal_uInt32 nBytes, sal_uInt32 &rnDone)
Write to the stream.
Definition: store.hxx:95
storeError readAt(sal_uInt32 nOffset, void *pBuffer, sal_uInt32 nBytes, sal_uInt32 &rnDone)
Read from the stream.
Definition: store.hxx:80
storeError create(storeFileHandle hFile, OUString const &rPath, OUString const &rName, storeAccessMode eMode)
Open the stream.
Definition: store.hxx:63
Mode eMode
Old OStorePageCache implementation.
Definition: lockbyte.cxx:133
storeError store_remove(storeFileHandle Handle, rtl_uString const *pPath, rtl_uString const *pName) SAL_THROW_EXTERN_C()
Remove a file entry.
Definition: store.cxx:342
storeError store_acquireHandle(storeHandle Handle) SAL_THROW_EXTERN_C()
Acquire a Handle.
Definition: store.cxx:65
storeError store_findFirst(storeDirectoryHandle Handle, storeFindData *pFindData) SAL_THROW_EXTERN_C()
Find first directory entry.
Definition: store.cxx:221
storeError store_releaseHandle(storeHandle Handle) SAL_THROW_EXTERN_C()
Release a Handle.
Definition: store.cxx:77
storeError store_readStream(storeStreamHandle Handle, sal_uInt32 nOffset, void *pBuffer, sal_uInt32 nBytes, sal_uInt32 *pnDone) SAL_THROW_EXTERN_C()
Read from a stream.
Definition: store.cxx:304
storeError store_openStream(storeFileHandle hFile, rtl_uString const *pPath, rtl_uString const *pName, storeAccessMode eAccessMode, storeStreamHandle *phStream) SAL_THROW_EXTERN_C()
Open a stream.
Definition: store.cxx:264
storeError store_findNext(storeDirectoryHandle Handle, storeFindData *pFindData) SAL_THROW_EXTERN_C()
Find next directory entry.
Definition: store.cxx:242
storeError store_openDirectory(storeFileHandle hFile, rtl_uString const *pPath, rtl_uString const *pName, storeAccessMode eAccessMode, storeDirectoryHandle *phDirectory) SAL_THROW_EXTERN_C()
Open a directory.
Definition: store.cxx:184
storeError store_flushFile(storeFileHandle Handle) SAL_THROW_EXTERN_C()
Flush a file.
Definition: store.cxx:172
storeError store_createMemoryFile(sal_uInt16 nPageSize, storeFileHandle *phFile) SAL_THROW_EXTERN_C()
Open a temporary file in memory.
Definition: store.cxx:89
storeError store_closeFile(storeFileHandle Handle) SAL_THROW_EXTERN_C()
Close a file.
Definition: store.cxx:158
storeError store_writeStream(storeStreamHandle Handle, sal_uInt32 nOffset, const void *pBuffer, sal_uInt32 nBytes, sal_uInt32 *pnDone) SAL_THROW_EXTERN_C()
Write to a stream.
Definition: store.cxx:323
storeError store_openFile(rtl_uString *pFilename, storeAccessMode eAccessMode, sal_uInt16 nPageSize, storeFileHandle *phFile) SAL_THROW_EXTERN_C()
Open a file.
Definition: store.cxx:120
void * storeStreamHandle
Stream Handle opaque type.
Definition: store.h:149
void * storeDirectoryHandle
Directory Handle opaque type.
Definition: store.h:105
void * storeFileHandle
File Handle opaque type.
Definition: store.h:54
Find Data structure.
Definition: types.h:105
storeAccessMode
Access Mode enumeration.
Definition: types.h:62
storeError
Error Code enumeration.
Definition: types.h:73
@ store_E_InvalidHandle
Definition: types.h:81
constexpr sal_uInt16 STORE_DEFAULT_PAGESIZE
PageSize (recommended) default.
Definition: types.h:31