xref: /AOO42X/main/dbaccess/source/core/api/RowSetRow.hxx (revision 9bce9b0d387299c68bd81d539e1478357a103de5)
1*2e2212a7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2e2212a7SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2e2212a7SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2e2212a7SAndrew Rist  * distributed with this work for additional information
6*2e2212a7SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2e2212a7SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2e2212a7SAndrew Rist  * "License"); you may not use this file except in compliance
9*2e2212a7SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*2e2212a7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*2e2212a7SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2e2212a7SAndrew Rist  * software distributed under the License is distributed on an
15*2e2212a7SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2e2212a7SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2e2212a7SAndrew Rist  * specific language governing permissions and limitations
18*2e2212a7SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*2e2212a7SAndrew Rist  *************************************************************/
21*2e2212a7SAndrew Rist 
22*2e2212a7SAndrew Rist 
23cdf0e10cSrcweir #ifndef DBACCESS_CORE_API_ROWSETROW_HXX
24cdf0e10cSrcweir #define DBACCESS_CORE_API_ROWSETROW_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #ifndef _VOS_REF_HXX_
27cdf0e10cSrcweir #include <vos/ref.hxx>
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
30cdf0e10cSrcweir #include <connectivity/CommonTools.hxx>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #ifndef _CONNECTIVITY_FILE_VALUE_HXX_
33cdf0e10cSrcweir #include "connectivity/FValue.hxx"
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #ifndef _COMPHELPER_TYPES_HXX_
36cdf0e10cSrcweir #include <comphelper/types.hxx>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir 
39cdf0e10cSrcweir namespace dbaccess
40cdf0e10cSrcweir {
41cdf0e10cSrcweir     typedef connectivity::ORowVector< connectivity::ORowSetValue >  ORowSetValueVector;
42cdf0e10cSrcweir     typedef ::vos::ORef< ORowSetValueVector >                       ORowSetRow;
43cdf0e10cSrcweir     typedef ::std::vector< ORowSetRow >                             ORowSetMatrix;
44cdf0e10cSrcweir 
45cdf0e10cSrcweir     class ORowSetOldRowHelper
46cdf0e10cSrcweir     {
47cdf0e10cSrcweir         oslInterlockedCount         m_refCount;
48cdf0e10cSrcweir         ORowSetRow                  m_aRow;
49cdf0e10cSrcweir 
50cdf0e10cSrcweir         ORowSetOldRowHelper& operator=(const ORowSetOldRowHelper& _rRH);
51cdf0e10cSrcweir         ORowSetOldRowHelper(const ORowSetOldRowHelper& _rRh);
52cdf0e10cSrcweir     public:
ORowSetOldRowHelper()53cdf0e10cSrcweir         ORowSetOldRowHelper() : m_refCount(0){}
ORowSetOldRowHelper(const ORowSetRow & _rRow)54cdf0e10cSrcweir         ORowSetOldRowHelper(const ORowSetRow& _rRow)
55cdf0e10cSrcweir             : m_refCount(0)
56cdf0e10cSrcweir             , m_aRow(_rRow)
57cdf0e10cSrcweir         {}
58cdf0e10cSrcweir //      ORowSetOldRowHelper(const ORowSetOldRowHelper& _rRh)
59cdf0e10cSrcweir //          : m_refCount(0)
60cdf0e10cSrcweir //          , m_aRow(_rRh.m_aRow)
61cdf0e10cSrcweir //      {}
62cdf0e10cSrcweir 
acquire()63cdf0e10cSrcweir         void acquire()
64cdf0e10cSrcweir         {
65cdf0e10cSrcweir             osl_incrementInterlockedCount( &m_refCount );
66cdf0e10cSrcweir         }
release()67cdf0e10cSrcweir         void release()
68cdf0e10cSrcweir         {
69cdf0e10cSrcweir             if (! osl_decrementInterlockedCount( &m_refCount ))
70cdf0e10cSrcweir                 delete this;
71cdf0e10cSrcweir         }
getRow() const72cdf0e10cSrcweir         inline ORowSetRow getRow() const { return m_aRow; }
clearRow()73cdf0e10cSrcweir         inline void clearRow() { m_aRow = NULL; }
setRow(const ORowSetRow & _rRow)74cdf0e10cSrcweir         inline void setRow(const ORowSetRow& _rRow) { m_aRow = _rRow; }
75cdf0e10cSrcweir     };
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     typedef ::vos::ORef< ORowSetOldRowHelper >  TORowSetOldRowHelperRef;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     class ORowSetValueCompare
80cdf0e10cSrcweir     {
81cdf0e10cSrcweir         const ::com::sun::star::uno::Any& m_rAny;
82cdf0e10cSrcweir     public:
ORowSetValueCompare(const::com::sun::star::uno::Any & _rAny)83cdf0e10cSrcweir         ORowSetValueCompare(const ::com::sun::star::uno::Any& _rAny) : m_rAny(_rAny){}
84cdf0e10cSrcweir 
operator ()(const ORowSetRow & _rRH)85cdf0e10cSrcweir         sal_Bool operator ()(const ORowSetRow& _rRH)
86cdf0e10cSrcweir         {
87cdf0e10cSrcweir             switch((_rRH->get())[0].getTypeKind())
88cdf0e10cSrcweir             {
89cdf0e10cSrcweir                 case ::com::sun::star::sdbc::DataType::TINYINT:
90cdf0e10cSrcweir                 case ::com::sun::star::sdbc::DataType::SMALLINT:
91cdf0e10cSrcweir                 case ::com::sun::star::sdbc::DataType::INTEGER:
92cdf0e10cSrcweir                     return comphelper::getINT32(m_rAny) == (sal_Int32)(_rRH->get())[0];
93cdf0e10cSrcweir                 default:
94cdf0e10cSrcweir                 {
95cdf0e10cSrcweir                     ::com::sun::star::uno::Sequence<sal_Int8> aSeq;
96cdf0e10cSrcweir                     m_rAny >>= aSeq;
97cdf0e10cSrcweir                     return aSeq == (_rRH->get())[0];
98cdf0e10cSrcweir                 }
99cdf0e10cSrcweir             }
100cdf0e10cSrcweir         }
101cdf0e10cSrcweir     };
102cdf0e10cSrcweir }
103cdf0e10cSrcweir #endif // DBACCESS_CORE_API_ROWSETROW_HXX
104