1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_STORE_STORE_HXX
21 #define INCLUDED_STORE_STORE_HXX
23 #include <store/store.h>
24 #include <sal/types.h>
26 #include <rtl/ustring.hxx>
27 #include <store/types.h>
32 /*========================================================================
34 * OStoreStream interface.
36 *======================================================================*/
48 inline ~OStoreStream()
51 (void) store_releaseHandle (m_hImpl
);
54 /** Copy construction.
56 inline OStoreStream (OStoreStream
const & rhs
)
57 : m_hImpl (rhs
.m_hImpl
)
60 (void) store_acquireHandle (m_hImpl
);
65 inline OStoreStream
& operator= (OStoreStream
const & rhs
)
68 (void) store_acquireHandle (rhs
.m_hImpl
);
70 (void) store_releaseHandle (m_hImpl
);
71 m_hImpl
= rhs
.m_hImpl
;
76 @see store_openStream()
78 inline storeError
create (
79 storeFileHandle hFile
,
80 rtl::OUString
const & rPath
,
81 rtl::OUString
const & rName
,
82 storeAccessMode eMode
)
86 (void) store_releaseHandle (m_hImpl
);
89 return store_openStream (hFile
, rPath
.pData
, rName
.pData
, eMode
, &m_hImpl
);
92 /** Read from the stream.
93 @see store_readStream()
95 inline storeError
readAt (
102 return store_E_InvalidHandle
;
104 return store_readStream (m_hImpl
, nOffset
, pBuffer
, nBytes
, &rnDone
);
107 /** Write to the stream.
108 @see store_writeStream()
110 inline storeError
writeAt (
112 void const * pBuffer
,
117 return store_E_InvalidHandle
;
119 return store_writeStream (m_hImpl
, nOffset
, pBuffer
, nBytes
, &rnDone
);
125 storeStreamHandle m_hImpl
;
128 /*========================================================================
130 * OStoreDirectory interface.
132 *======================================================================*/
133 class OStoreDirectory
138 inline OStoreDirectory()
144 inline ~OStoreDirectory()
147 (void) store_releaseHandle (m_hImpl
);
150 /** Copy construction.
152 inline OStoreDirectory (OStoreDirectory
const & rhs
)
153 : m_hImpl (rhs
.m_hImpl
)
156 (void) store_acquireHandle (m_hImpl
);
159 /** Move construction.
161 inline OStoreDirectory (OStoreDirectory
&& rhs
)
162 : m_hImpl (rhs
.m_hImpl
)
164 rhs
.m_hImpl
= nullptr;
169 inline OStoreDirectory
& operator= (OStoreDirectory
const & rhs
)
172 (void) store_acquireHandle (rhs
.m_hImpl
);
174 (void) store_releaseHandle (m_hImpl
);
175 m_hImpl
= rhs
.m_hImpl
;
181 inline OStoreDirectory
& operator= (OStoreDirectory
&& rhs
)
184 (void) store_releaseHandle (m_hImpl
);
185 m_hImpl
= rhs
.m_hImpl
;
186 rhs
.m_hImpl
= nullptr;
190 /** Open the directory.
191 @see store_openDirectory()
193 inline storeError
create (
194 storeFileHandle hFile
,
195 rtl::OUString
const & rPath
,
196 rtl::OUString
const & rName
,
197 storeAccessMode eMode
)
201 (void) store_releaseHandle (m_hImpl
);
204 return store_openDirectory (hFile
, rPath
.pData
, rName
.pData
, eMode
, &m_hImpl
);
207 /** Directory iterator type.
211 typedef storeFindData iterator
;
213 /** Find first directory entry.
214 @see store_findFirst()
216 inline storeError
first (iterator
& it
)
219 return store_E_InvalidHandle
;
221 return store_findFirst (m_hImpl
, &it
);
224 /** Find next directory entry.
225 @see store_findNext()
227 inline storeError
next (iterator
& it
)
230 return store_E_InvalidHandle
;
232 return store_findNext (m_hImpl
, &it
);
238 storeDirectoryHandle m_hImpl
;
241 /*========================================================================
243 * OStoreFile interface.
245 *======================================================================*/
260 (void) store_releaseHandle (m_hImpl
);
263 /** Copy construction.
265 inline OStoreFile (OStoreFile
const & rhs
)
266 : m_hImpl (rhs
.m_hImpl
)
269 (void) store_acquireHandle (m_hImpl
);
274 inline OStoreFile
& operator= (OStoreFile
const & rhs
)
277 (void) store_acquireHandle (rhs
.m_hImpl
);
279 (void) store_releaseHandle (m_hImpl
);
280 m_hImpl
= rhs
.m_hImpl
;
284 /** Conversion into File Handle.
286 inline operator storeFileHandle() const
291 /** Check for a valid File Handle.
292 @return sal_True if valid, sal_False otherwise.
294 inline bool isValid() const
296 return (m_hImpl
!= nullptr);
300 @see store_openFile()
302 inline storeError
create(
303 rtl::OUString
const & rFilename
,
304 storeAccessMode eAccessMode
)
308 (void) store_releaseHandle (m_hImpl
);
311 return store_openFile (rFilename
.pData
, eAccessMode
, STORE_DEFAULT_PAGESIZE
, &m_hImpl
);
314 /** Open the temporary file in memory.
315 @see store_createMemoryFile()
317 inline storeError
createInMemory ()
321 (void) store_releaseHandle (m_hImpl
);
324 return store_createMemoryFile (STORE_DEFAULT_PAGESIZE
, &m_hImpl
);
328 @see store_closeFile()
334 (void) store_closeFile (m_hImpl
);
340 @see store_flushFile()
342 inline storeError
flush() const
345 return store_E_InvalidHandle
;
347 return store_flushFile (m_hImpl
);
350 /** Remove a file entry.
353 inline storeError
remove (
354 rtl::OUString
const & rPath
, rtl::OUString
const & rName
)
357 return store_E_InvalidHandle
;
359 return store_remove (m_hImpl
, rPath
.pData
, rName
.pData
);
365 storeFileHandle m_hImpl
;
368 /*========================================================================
372 *======================================================================*/
376 #endif /* ! INCLUDED_STORE_STORE_HXX */
379 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */