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>
25 #include <rtl/ustring.hxx>
26 #include <store/types.h>
45 (void) store_releaseHandle (m_hImpl
);
48 /** Copy construction.
50 OStoreStream (OStoreStream
const & rhs
)
51 : m_hImpl (rhs
.m_hImpl
)
54 (void) store_acquireHandle (m_hImpl
);
59 OStoreStream
& operator= (OStoreStream
const & rhs
)
62 (void) store_acquireHandle (rhs
.m_hImpl
);
64 (void) store_releaseHandle (m_hImpl
);
65 m_hImpl
= rhs
.m_hImpl
;
70 @see store_openStream()
73 storeFileHandle hFile
,
74 OUString
const & rPath
,
75 OUString
const & rName
,
76 storeAccessMode eMode
)
80 (void) store_releaseHandle (m_hImpl
);
83 return store_openStream (hFile
, rPath
.pData
, rName
.pData
, eMode
, &m_hImpl
);
86 /** Read from the stream.
87 @see store_readStream()
96 return store_E_InvalidHandle
;
98 return store_readStream (m_hImpl
, nOffset
, pBuffer
, nBytes
, &rnDone
);
101 /** Write to the stream.
102 @see store_writeStream()
106 void const * pBuffer
,
111 return store_E_InvalidHandle
;
113 return store_writeStream (m_hImpl
, nOffset
, pBuffer
, nBytes
, &rnDone
);
119 storeStreamHandle m_hImpl
;
122 class OStoreDirectory
136 (void) store_releaseHandle (m_hImpl
);
139 /** Copy construction.
141 OStoreDirectory (OStoreDirectory
const & rhs
)
142 : m_hImpl (rhs
.m_hImpl
)
145 (void) store_acquireHandle (m_hImpl
);
148 /** Move construction.
150 OStoreDirectory (OStoreDirectory
&& rhs
)
151 : m_hImpl (rhs
.m_hImpl
)
153 rhs
.m_hImpl
= nullptr;
158 OStoreDirectory
& operator= (OStoreDirectory
const & rhs
)
161 (void) store_acquireHandle (rhs
.m_hImpl
);
163 (void) store_releaseHandle (m_hImpl
);
164 m_hImpl
= rhs
.m_hImpl
;
170 OStoreDirectory
& operator= (OStoreDirectory
&& rhs
)
173 (void) store_releaseHandle (m_hImpl
);
174 m_hImpl
= rhs
.m_hImpl
;
175 rhs
.m_hImpl
= nullptr;
179 /** Open the directory.
180 @see store_openDirectory()
183 storeFileHandle hFile
,
184 OUString
const & rPath
,
185 OUString
const & rName
,
186 storeAccessMode eMode
)
190 (void) store_releaseHandle (m_hImpl
);
193 return store_openDirectory (hFile
, rPath
.pData
, rName
.pData
, eMode
, &m_hImpl
);
196 /** Directory iterator type.
200 typedef storeFindData iterator
;
202 /** Find first directory entry.
203 @see store_findFirst()
205 storeError
first (iterator
& it
)
208 return store_E_InvalidHandle
;
210 return store_findFirst (m_hImpl
, &it
);
213 /** Find next directory entry.
214 @see store_findNext()
216 storeError
next (iterator
& it
)
219 return store_E_InvalidHandle
;
221 return store_findNext (m_hImpl
, &it
);
227 storeDirectoryHandle m_hImpl
;
244 (void) store_releaseHandle (m_hImpl
);
247 /** Copy construction.
249 OStoreFile (OStoreFile
const & rhs
)
250 : m_hImpl (rhs
.m_hImpl
)
253 (void) store_acquireHandle (m_hImpl
);
258 OStoreFile
& operator= (OStoreFile
const & rhs
)
261 (void) store_acquireHandle (rhs
.m_hImpl
);
263 (void) store_releaseHandle (m_hImpl
);
264 m_hImpl
= rhs
.m_hImpl
;
268 /** Conversion into File Handle.
270 operator storeFileHandle() const
275 /** Check for a valid File Handle.
276 @return sal_True if valid, sal_False otherwise.
280 return (m_hImpl
!= nullptr);
284 @see store_openFile()
287 OUString
const & rFilename
,
288 storeAccessMode eAccessMode
)
292 (void) store_releaseHandle (m_hImpl
);
295 return store_openFile (rFilename
.pData
, eAccessMode
, STORE_DEFAULT_PAGESIZE
, &m_hImpl
);
298 /** Open the temporary file in memory.
299 @see store_createMemoryFile()
301 storeError
createInMemory ()
305 (void) store_releaseHandle (m_hImpl
);
308 return store_createMemoryFile (STORE_DEFAULT_PAGESIZE
, &m_hImpl
);
312 @see store_closeFile()
318 (void) store_closeFile (m_hImpl
);
324 @see store_flushFile()
326 storeError
flush() const
329 return store_E_InvalidHandle
;
331 return store_flushFile (m_hImpl
);
334 /** Remove a file entry.
338 OUString
const & rPath
, OUString
const & rName
)
341 return store_E_InvalidHandle
;
343 return store_remove (m_hImpl
, rPath
.pData
, rName
.pData
);
349 storeFileHandle m_hImpl
;
354 #endif /* ! INCLUDED_STORE_STORE_HXX */
356 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */