Update ooo320-m1
[ooovba.git] / connectivity / source / inc / TSkipDeletedSet.hxx
blob0897440d9a66583f324c6b4492e205f1b5f10fb9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TSkipDeletedSet.hxx,v $
10 * $Revision: 1.7 $
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>
35 #include <hash_map>
36 #include <vector>
37 #include "connectivity/dbtoolsdllapi.hxx"
39 namespace connectivity
41 /**
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);
51 public:
52 OSkipDeletedSet(IResultSetHelper* _pHelper);
53 ~OSkipDeletedSet();
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( () )
58 { return _pHint; }
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( () )
62 { }
64 /**
65 skipDeleted moves the resultset to the position defined by the parameters
66 it garantees that the row isn't deleted
67 @param
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
71 @return
72 true when the movement was successful otherwise false
74 sal_Bool skipDeleted(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nOffset, sal_Bool _bRetrieveData);
75 /**
76 clear the map and the vector used in this class
78 void clear();
79 /**
80 getMappedPosition returns the mapped position of a logical position
81 @param
82 sal_Int32 _nBookmark the logical position
84 @return the mapped position
86 sal_Int32 getMappedPosition(sal_Int32 _nBookmark) const;
87 /**
88 insertNewPosition adds a new position to the map
89 @param
90 sal_Int32 _nPos the logical position
92 void insertNewPosition(sal_Int32 _nPos);
93 /**
94 deletePosition deletes this position from the map and decrement all following positions
95 @param
96 sal_Int32 _nPos the logical position
98 void deletePosition(sal_Int32 _nPos);
99 /**
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