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 .
19 #ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_TSKIPDELETEDSET_HXX
20 #define INCLUDED_CONNECTIVITY_SOURCE_INC_TSKIPDELETEDSET_HXX
22 #include "TResultSetHelper.hxx"
23 #include <rtl/alloc.h>
24 #include <unordered_map>
26 #include <connectivity/dbtoolsdllapi.hxx>
28 namespace connectivity
31 the class OSkipDeletedSet supports a general method to skip deleted rows
33 class OOO_DLLPUBLIC_DBTOOLS OSkipDeletedSet
35 ::std::vector
<sal_Int32
> m_aBookmarksPositions
;// vector of iterators to position map, the order is the logical position
36 IResultSetHelper
* m_pHelper
; // used for moving in the resultset
37 bool m_bDeletedVisible
;
39 bool moveAbsolute(sal_Int32 _nOffset
,bool _bRetrieveData
);
41 OSkipDeletedSet(IResultSetHelper
* _pHelper
);
44 inline static void * SAL_CALL
operator new( size_t nSize
)
45 { return ::rtl_allocateMemory( nSize
); }
46 inline static void * SAL_CALL
operator new( size_t,void* _pHint
)
48 inline static void SAL_CALL
operator delete( void * pMem
)
49 { ::rtl_freeMemory( pMem
); }
50 inline static void SAL_CALL
operator delete( void *,void* )
54 skipDeleted moves the resultset to the position defined by the parameters
55 it guarantees that the row isn't deleted
57 IResultSetHelper::Movement _eCursorPosition in which direction the resultset should be moved
58 sal_Int32 _nOffset the position relativ to the movement
59 sal_Bool _bRetrieveData is true when the current row should be filled which data
61 true when the movement was successful otherwise false
63 bool skipDeleted(IResultSetHelper::Movement _eCursorPosition
, sal_Int32 _nOffset
, bool _bRetrieveData
);
65 clear the map and the vector used in this class
69 getMappedPosition returns the mapped position of a logical position
71 sal_Int32 _nBookmark the logical position
73 @return the mapped position
75 sal_Int32
getMappedPosition(sal_Int32 _nBookmark
) const;
77 insertNewPosition adds a new position to the map
79 sal_Int32 _nPos the logical position
81 void insertNewPosition(sal_Int32 _nPos
);
83 deletePosition deletes this position from the map and decrement all following positions
85 sal_Int32 _nPos the logical position
87 void deletePosition(sal_Int32 _nPos
);
89 getLastPosition returns the last position
90 @return the last position
92 inline sal_Int32
getLastPosition() const { return m_aBookmarksPositions
.size(); }
93 inline void SetDeletedVisible(bool _bDeletedVisible
) { m_bDeletedVisible
= _bDeletedVisible
; }
96 #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_TSKIPDELETEDSET_HXX
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */