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