2000-09-18 15:18:56 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 10:18:10 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 10:18:10 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 10:18:10 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 10:18:10 +00:00
|
|
|
* $RCSfile: fcomp.hxx,v $
|
|
|
|
* $Revision: 1.14 $
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 10:18:10 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 10:18:10 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 10:18:10 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 10:18:10 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
#ifndef _CONNECTIVITY_FILE_FCOMP_HXX_
|
|
|
|
#define _CONNECTIVITY_FILE_FCOMP_HXX_
|
|
|
|
|
|
|
|
#include "file/fcode.hxx"
|
2008-12-30 13:32:01 +00:00
|
|
|
#include "file/filedllapi.hxx"
|
2000-09-18 15:18:56 +00:00
|
|
|
#ifndef _LIST_
|
|
|
|
#include <list>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace connectivity
|
|
|
|
{
|
|
|
|
class OSQLParseNode;
|
|
|
|
namespace file
|
|
|
|
{
|
|
|
|
class OCode;
|
|
|
|
class OOperand;
|
2005-06-14 15:21:58 +00:00
|
|
|
class OSQLAnalyzer;
|
2000-09-18 15:18:56 +00:00
|
|
|
typedef::std::vector<OCode*> OCodeList;
|
|
|
|
|
2008-12-30 13:32:01 +00:00
|
|
|
class OOO_DLLPUBLIC_FILE OPredicateCompiler : public ::vos::OReference
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
friend class OPredicateInterpreter;
|
|
|
|
friend class OSQLAnalyzer;
|
|
|
|
|
|
|
|
OCodeList m_aCodeList;
|
|
|
|
OFileColumns m_orgColumns; // in filecurs this are the filecolumns
|
|
|
|
OSQLAnalyzer* m_pAnalyzer;
|
2001-05-07 09:37:54 +00:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xIndexes;
|
2001-04-10 07:51:30 +00:00
|
|
|
sal_Int32 m_nParamCounter;
|
2000-09-18 15:18:56 +00:00
|
|
|
sal_Bool m_bORCondition;
|
|
|
|
public:
|
|
|
|
OPredicateCompiler(OSQLAnalyzer* pAnalyzer);
|
|
|
|
|
|
|
|
virtual ~OPredicateCompiler();
|
2002-07-05 07:07:52 +00:00
|
|
|
|
|
|
|
inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
|
|
|
|
{ return ::rtl_allocateMemory( nSize ); }
|
2006-06-20 01:02:18 +00:00
|
|
|
inline static void * SAL_CALL operator new( size_t /*nSize*/,void* _pHint ) SAL_THROW( () )
|
2002-07-05 07:07:52 +00:00
|
|
|
{ return _pHint; }
|
|
|
|
inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () )
|
|
|
|
{ ::rtl_freeMemory( pMem ); }
|
2006-06-20 01:02:18 +00:00
|
|
|
inline static void SAL_CALL operator delete( void * /*pMem*/,void* /*_pHint*/ ) SAL_THROW( () )
|
2002-07-05 07:07:52 +00:00
|
|
|
{ }
|
2000-11-03 12:49:39 +00:00
|
|
|
void dispose();
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
void start(connectivity::OSQLParseNode* pSQLParseNode);
|
|
|
|
OOperand* execute(connectivity::OSQLParseNode* pPredicateNode);
|
|
|
|
|
|
|
|
void Clean();
|
|
|
|
sal_Bool isClean() const {return m_aCodeList.empty();}
|
|
|
|
sal_Bool hasCode() const {return !isClean();}
|
|
|
|
sal_Bool hasORCondition() const {return m_bORCondition;}
|
|
|
|
void setOrigColumns(const OFileColumns& rCols) { m_orgColumns = rCols; }
|
|
|
|
const OFileColumns getOrigColumns() const { return m_orgColumns; }
|
|
|
|
protected:
|
2001-01-25 07:26:21 +00:00
|
|
|
OOperand* execute_COMPARE(connectivity::OSQLParseNode* pPredicateNode) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
|
|
|
|
OOperand* execute_LIKE(connectivity::OSQLParseNode* pPredicateNode) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
|
2004-08-02 16:13:40 +00:00
|
|
|
OOperand* execute_BETWEEN(connectivity::OSQLParseNode* pPredicateNode) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
|
2001-01-25 07:26:21 +00:00
|
|
|
OOperand* execute_ISNULL(connectivity::OSQLParseNode* pPredicateNode) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
|
|
|
|
OOperand* execute_Operand(connectivity::OSQLParseNode* pPredicateNode) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
|
2003-09-04 07:29:01 +00:00
|
|
|
OOperand* execute_Fold(OSQLParseNode* pPredicateNode) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
|
|
|
|
OOperand* executeFunction(OSQLParseNode* pPredicateNode) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
|
2000-09-18 15:18:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-12-30 13:32:01 +00:00
|
|
|
class OOO_DLLPUBLIC_FILE OPredicateInterpreter :
|
|
|
|
public ::vos::OReference
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
OCodeStack m_aStack;
|
2003-09-04 07:29:01 +00:00
|
|
|
::vos::ORef<OPredicateCompiler> m_rCompiler;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
public:
|
2003-09-04 07:29:01 +00:00
|
|
|
OPredicateInterpreter(const ::vos::ORef<OPredicateCompiler>& rComp) : m_rCompiler(rComp){}
|
2000-09-18 15:18:56 +00:00
|
|
|
virtual ~OPredicateInterpreter();
|
|
|
|
|
2003-09-04 07:29:01 +00:00
|
|
|
sal_Bool evaluate(OCodeList& rCodeList);
|
|
|
|
void evaluateSelection(OCodeList& rCodeList,ORowSetValueDecoratorRef& _rVal);
|
|
|
|
|
|
|
|
inline sal_Bool start()
|
|
|
|
{
|
|
|
|
return evaluate(m_rCompiler->m_aCodeList);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void startSelection(ORowSetValueDecoratorRef& _rVal)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2003-09-04 07:29:01 +00:00
|
|
|
return evaluateSelection(m_rCompiler->m_aCodeList,_rVal);
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2003-09-04 07:29:01 +00:00
|
|
|
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // _CONNECTIVITY_FILE_FCOMP_HXX_
|
|
|
|
|