1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TSkipDeletedSet.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef CONNECTIVITY_SKIPDELETEDSSET_HXX
31 #define CONNECTIVITY_SKIPDELETEDSSET_HXX
33 #include "TResultSetHelper.hxx"
34 #include <rtl/alloc.h>
37 #include "connectivity/dbtoolsdllapi.hxx"
39 namespace connectivity
42 the class OSkipDeletedSet supports a general method to skip deleted rows
44 class OOO_DLLPUBLIC_DBTOOLS OSkipDeletedSet
46 ::std::vector
<sal_Int32
> m_aBookmarksPositions
;// vector of iterators to position map, the order is the logical position
47 IResultSetHelper
* m_pHelper
; // used for moving in the resultset
48 bool m_bDeletedVisible
;
50 sal_Bool
moveAbsolute(sal_Int32 _nOffset
,sal_Bool _bRetrieveData
);
52 OSkipDeletedSet(IResultSetHelper
* _pHelper
);
55 inline static void * SAL_CALL
operator new( size_t nSize
) SAL_THROW( () )
56 { return ::rtl_allocateMemory( nSize
); }
57 inline static void * SAL_CALL
operator new( size_t,void* _pHint
) SAL_THROW( () )
59 inline static void SAL_CALL
operator delete( void * pMem
) SAL_THROW( () )
60 { ::rtl_freeMemory( pMem
); }
61 inline static void SAL_CALL
operator delete( void *,void* ) SAL_THROW( () )
65 skipDeleted moves the resultset to the position defined by the parameters
66 it garantees that the row isn't deleted
68 IResultSetHelper::Movement _eCursorPosition in which direction the resultset should be moved
69 sal_Int32 _nOffset the position relativ to the movement
70 sal_Bool _bRetrieveData is true when the current row should be filled which data
72 true when the movement was successful otherwise false
74 sal_Bool
skipDeleted(IResultSetHelper::Movement _eCursorPosition
, sal_Int32 _nOffset
, sal_Bool _bRetrieveData
);
76 clear the map and the vector used in this class
80 getMappedPosition returns the mapped position of a logical position
82 sal_Int32 _nBookmark the logical position
84 @return the mapped position
86 sal_Int32
getMappedPosition(sal_Int32 _nBookmark
) const;
88 insertNewPosition adds a new position to the map
90 sal_Int32 _nPos the logical position
92 void insertNewPosition(sal_Int32 _nPos
);
94 deletePosition deletes this position from the map and decrement all following positions
96 sal_Int32 _nPos the logical position
98 void deletePosition(sal_Int32 _nPos
);
100 getLastPosition returns the last position
101 @return the last position
103 inline sal_Int32
getLastPosition() const { return m_aBookmarksPositions
.size(); }
104 inline void SetDeleted(bool _bDeletedVisible
) { m_bDeletedVisible
= _bDeletedVisible
; }
107 #endif // CONNECTIVITY_SKIPDELETEDSSET_HXX