Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / dbaccess / source / core / api / RowSetRow.hxx
blob80a2dacd1edce4bc15733d74c88df9facb1fa3c7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef DBACCESS_CORE_API_ROWSETROW_HXX
20 #define DBACCESS_CORE_API_ROWSETROW_HXX
22 #include <rtl/ref.hxx>
23 #include <connectivity/CommonTools.hxx>
24 #include "connectivity/FValue.hxx"
25 #include <comphelper/types.hxx>
27 namespace dbaccess
29 typedef connectivity::ORowVector< connectivity::ORowSetValue > ORowSetValueVector;
30 typedef ::rtl::Reference< ORowSetValueVector > ORowSetRow;
31 typedef ::std::vector< ORowSetRow > ORowSetMatrix;
33 class ORowSetOldRowHelper
35 oslInterlockedCount m_refCount;
36 ORowSetRow m_aRow;
38 ORowSetOldRowHelper& operator=(const ORowSetOldRowHelper& _rRH);
39 ORowSetOldRowHelper(const ORowSetOldRowHelper& _rRh);
40 public:
41 ORowSetOldRowHelper() : m_refCount(0){}
42 ORowSetOldRowHelper(const ORowSetRow& _rRow)
43 : m_refCount(0)
44 , m_aRow(_rRow)
47 void acquire()
49 osl_atomic_increment( &m_refCount );
51 void release()
53 if (! osl_atomic_decrement( &m_refCount ))
54 delete this;
56 inline ORowSetRow getRow() const { return m_aRow; }
57 inline void clearRow() { m_aRow = NULL; }
58 inline void setRow(const ORowSetRow& _rRow) { m_aRow = _rRow; }
61 typedef ::rtl::Reference< ORowSetOldRowHelper > TORowSetOldRowHelperRef;
63 class ORowSetValueCompare
65 const ::com::sun::star::uno::Any& m_rAny;
66 public:
67 ORowSetValueCompare(const ::com::sun::star::uno::Any& _rAny) : m_rAny(_rAny){}
69 sal_Bool operator ()(const ORowSetRow& _rRH)
71 switch((_rRH->get())[0].getTypeKind())
73 case ::com::sun::star::sdbc::DataType::TINYINT:
74 case ::com::sun::star::sdbc::DataType::SMALLINT:
75 case ::com::sun::star::sdbc::DataType::INTEGER:
76 return comphelper::getINT32(m_rAny) == (sal_Int32)(_rRH->get())[0];
77 default:
79 ::com::sun::star::uno::Sequence<sal_Int8> aSeq;
80 m_rAny >>= aSeq;
81 return aSeq == (_rRH->get())[0];
87 #endif // DBACCESS_CORE_API_ROWSETROW_HXX
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */