1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
28 #ifndef CONNECTIVITY_SKIPDELETEDSSET_HXX
29 #define CONNECTIVITY_SKIPDELETEDSSET_HXX
31 #include "TResultSetHelper.hxx"
32 #include <rtl/alloc.h>
33 #include <boost/unordered_map.hpp>
35 #include "connectivity/dbtoolsdllapi.hxx"
37 namespace connectivity
40 the class OSkipDeletedSet supports a general method to skip deleted rows
42 class OOO_DLLPUBLIC_DBTOOLS OSkipDeletedSet
44 ::std::vector
<sal_Int32
> m_aBookmarksPositions
;// vector of iterators to position map, the order is the logical position
45 IResultSetHelper
* m_pHelper
; // used for moving in the resultset
46 bool m_bDeletedVisible
;
48 sal_Bool
moveAbsolute(sal_Int32 _nOffset
,sal_Bool _bRetrieveData
);
50 OSkipDeletedSet(IResultSetHelper
* _pHelper
);
53 inline static void * SAL_CALL
operator new( size_t nSize
) SAL_THROW(())
54 { return ::rtl_allocateMemory( nSize
); }
55 inline static void * SAL_CALL
operator new( size_t,void* _pHint
) SAL_THROW(())
57 inline static void SAL_CALL
operator delete( void * pMem
) SAL_THROW(())
58 { ::rtl_freeMemory( pMem
); }
59 inline static void SAL_CALL
operator delete( void *,void* ) SAL_THROW(())
63 skipDeleted moves the resultset to the position defined by the parameters
64 it garantees that the row isn't deleted
66 IResultSetHelper::Movement _eCursorPosition in which direction the resultset should be moved
67 sal_Int32 _nOffset the position relativ to the movement
68 sal_Bool _bRetrieveData is true when the current row should be filled which data
70 true when the movement was successful otherwise false
72 sal_Bool
skipDeleted(IResultSetHelper::Movement _eCursorPosition
, sal_Int32 _nOffset
, sal_Bool _bRetrieveData
);
74 clear the map and the vector used in this class
78 getMappedPosition returns the mapped position of a logical position
80 sal_Int32 _nBookmark the logical position
82 @return the mapped position
84 sal_Int32
getMappedPosition(sal_Int32 _nBookmark
) const;
86 insertNewPosition adds a new position to the map
88 sal_Int32 _nPos the logical position
90 void insertNewPosition(sal_Int32 _nPos
);
92 deletePosition deletes this position from the map and decrement all following positions
94 sal_Int32 _nPos the logical position
96 void deletePosition(sal_Int32 _nPos
);
98 getLastPosition returns the last position
99 @return the last position
101 inline sal_Int32
getLastPosition() const { return m_aBookmarksPositions
.size(); }
102 inline void SetDeletedVisible(bool _bDeletedVisible
) { m_bDeletedVisible
= _bDeletedVisible
; }
105 #endif // CONNECTIVITY_SKIPDELETEDSSET_HXX
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */