Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "RowSetCacheIterator.hxx"
21 : #include "RowSetCache.hxx"
22 : #include "RowSetBase.hxx"
23 :
24 : using namespace dbaccess;
25 0 : ORowSetCacheIterator::ORowSetCacheIterator(const ORowSetCacheIterator& _rRH)
26 : : m_aIter(_rRH.m_aIter)
27 : , m_pCache(_rRH.m_pCache)
28 0 : ,m_pRowSet(_rRH.m_pRowSet)
29 : {
30 0 : }
31 :
32 11 : ORowSetCacheIterator::operator ORowSetMatrix::iterator()
33 : {
34 11 : return m_aIter->second.aIterator;
35 : }
36 :
37 153 : ORowSetCacheIterator& ORowSetCacheIterator::operator =(const ORowSetCacheIterator& _rRH)
38 : {
39 153 : if(this == &_rRH)
40 0 : return *this;
41 :
42 153 : m_pCache = _rRH.m_pCache;
43 153 : m_aIter = _rRH.m_aIter;
44 153 : m_pRowSet = _rRH.m_pRowSet;
45 :
46 153 : return *this;
47 : }
48 :
49 4794 : ORowSetCacheIterator& ORowSetCacheIterator::operator =(const ORowSetMatrix::iterator& _rIter)
50 : {
51 4794 : m_aIter->second.aIterator = _rIter;
52 4794 : return *this;
53 : }
54 :
55 11506 : ORowSetRow& ORowSetCacheIterator::operator *()
56 : {
57 11506 : return *m_aIter->second.aIterator;
58 : }
59 :
60 0 : const ORowSetRow& ORowSetCacheIterator::operator *() const
61 : {
62 0 : if ( !m_pRowSet->isInsertRow() && m_aIter->second.aIterator == m_pCache->m_pMatrix->end() )
63 : {
64 : OSL_ENSURE(m_aIter->second.aBookmark.hasValue(),"bookmark has no value!");
65 0 : OSL_VERIFY(m_pCache->moveToBookmark(m_aIter->second.aBookmark));
66 0 : m_aIter->second.aIterator = m_pCache->m_aMatrixIter;
67 : }
68 0 : return *m_aIter->second.aIterator;
69 : }
70 :
71 11469 : ORowSetMatrix::iterator& ORowSetCacheIterator::operator ->()
72 : {
73 11469 : return m_aIter->second.aIterator;
74 : }
75 :
76 0 : const ORowSetMatrix::iterator& ORowSetCacheIterator::operator ->() const
77 : {
78 0 : if ( !m_pRowSet->isInsertRow() && m_aIter->second.aIterator == m_pCache->m_pMatrix->end() )
79 : {
80 : OSL_ENSURE(m_aIter->second.aBookmark.hasValue(),"bookmark has no value!");
81 0 : OSL_VERIFY(m_pCache->moveToBookmark(m_aIter->second.aBookmark));
82 0 : m_aIter->second.aIterator = m_pCache->m_aMatrixIter;
83 : }
84 0 : return m_aIter->second.aIterator;
85 : }
86 :
87 0 : bool ORowSetCacheIterator::operator <=(const ORowSetMatrix::iterator& _rRH) const
88 : {
89 0 : return m_aIter->second.aIterator <= _rRH;
90 : }
91 :
92 0 : bool ORowSetCacheIterator::operator <(const ORowSetMatrix::iterator& _rRH) const
93 : {
94 0 : return m_aIter->second.aIterator < _rRH;
95 : }
96 :
97 11464 : bool ORowSetCacheIterator::operator !=(const ORowSetMatrix::iterator& _rRH) const
98 : {
99 11464 : return m_aIter->second.aIterator != _rRH;
100 : }
101 :
102 0 : bool ORowSetCacheIterator::operator ==(const ORowSetMatrix::iterator& _rRH) const
103 : {
104 0 : return m_aIter->second.aIterator == _rRH;
105 : }
106 :
107 1947 : void ORowSetCacheIterator::setBookmark(const ::com::sun::star::uno::Any& _rBookmark)
108 : {
109 1947 : m_aIter->second.aBookmark = _rBookmark;
110 1947 : }
111 :
112 12438 : bool ORowSetCacheIterator::isNull() const
113 : {
114 12438 : bool bRet = !m_pCache || !m_pRowSet || m_aIter == m_pCache->m_aCacheIterators.end();
115 12438 : if ( !bRet )
116 : {
117 12438 : bRet = ( m_pRowSet->isInsertRow()
118 : ?
119 12471 : m_aIter->second.aIterator == m_pCache->m_pInsertMatrix->end()
120 : :
121 37292 : m_aIter->second.aIterator == m_pCache->m_pMatrix->end()
122 49741 : );
123 : }
124 12438 : return bRet;
125 : }
126 :
127 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|