xref: /trunk/main/dbaccess/source/core/api/RowSetRow.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef DBACCESS_CORE_API_ROWSETROW_HXX
28 #define DBACCESS_CORE_API_ROWSETROW_HXX
29 
30 #ifndef _VOS_REF_HXX_
31 #include <vos/ref.hxx>
32 #endif
33 #ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
34 #include <connectivity/CommonTools.hxx>
35 #endif
36 #ifndef _CONNECTIVITY_FILE_VALUE_HXX_
37 #include "connectivity/FValue.hxx"
38 #endif
39 #ifndef _COMPHELPER_TYPES_HXX_
40 #include <comphelper/types.hxx>
41 #endif
42 
43 namespace dbaccess
44 {
45     typedef connectivity::ORowVector< connectivity::ORowSetValue >  ORowSetValueVector;
46     typedef ::vos::ORef< ORowSetValueVector >                       ORowSetRow;
47     typedef ::std::vector< ORowSetRow >                             ORowSetMatrix;
48 
49     class ORowSetOldRowHelper
50     {
51         oslInterlockedCount         m_refCount;
52         ORowSetRow                  m_aRow;
53 
54         ORowSetOldRowHelper& operator=(const ORowSetOldRowHelper& _rRH);
55         ORowSetOldRowHelper(const ORowSetOldRowHelper& _rRh);
56     public:
57         ORowSetOldRowHelper() : m_refCount(0){}
58         ORowSetOldRowHelper(const ORowSetRow& _rRow)
59             : m_refCount(0)
60             , m_aRow(_rRow)
61         {}
62 //      ORowSetOldRowHelper(const ORowSetOldRowHelper& _rRh)
63 //          : m_refCount(0)
64 //          , m_aRow(_rRh.m_aRow)
65 //      {}
66 
67         void acquire()
68         {
69             osl_incrementInterlockedCount( &m_refCount );
70         }
71         void release()
72         {
73             if (! osl_decrementInterlockedCount( &m_refCount ))
74                 delete this;
75         }
76         inline ORowSetRow getRow() const { return m_aRow; }
77         inline void clearRow() { m_aRow = NULL; }
78         inline void setRow(const ORowSetRow& _rRow) { m_aRow = _rRow; }
79     };
80 
81     typedef ::vos::ORef< ORowSetOldRowHelper >  TORowSetOldRowHelperRef;
82 
83     class ORowSetValueCompare
84     {
85         const ::com::sun::star::uno::Any& m_rAny;
86     public:
87         ORowSetValueCompare(const ::com::sun::star::uno::Any& _rAny) : m_rAny(_rAny){}
88 
89         sal_Bool operator ()(const ORowSetRow& _rRH)
90         {
91             switch((_rRH->get())[0].getTypeKind())
92             {
93                 case ::com::sun::star::sdbc::DataType::TINYINT:
94                 case ::com::sun::star::sdbc::DataType::SMALLINT:
95                 case ::com::sun::star::sdbc::DataType::INTEGER:
96                     return comphelper::getINT32(m_rAny) == (sal_Int32)(_rRH->get())[0];
97                 default:
98                 {
99                     ::com::sun::star::uno::Sequence<sal_Int8> aSeq;
100                     m_rAny >>= aSeq;
101                     return aSeq == (_rRH->get())[0];
102                 }
103             }
104         }
105     };
106 }
107 #endif // DBACCESS_CORE_API_ROWSETROW_HXX
108 
109