1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fcomp.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _CONNECTIVITY_FILE_FCOMP_HXX_
31 #define _CONNECTIVITY_FILE_FCOMP_HXX_
33 #include "file/fcode.hxx"
34 #include "file/filedllapi.hxx"
39 namespace connectivity
47 typedef::std::vector
<OCode
*> OCodeList
;
49 class OPredicateCompiler
: public ::vos::OReference
51 friend class OPredicateInterpreter
;
52 friend class OSQLAnalyzer
;
54 OCodeList m_aCodeList
;
55 OFileColumns m_orgColumns
; // in filecurs this are the filecolumns
56 OSQLAnalyzer
* m_pAnalyzer
;
57 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> m_xIndexes
;
58 sal_Int32 m_nParamCounter
;
59 sal_Bool m_bORCondition
;
61 OPredicateCompiler(OSQLAnalyzer
* pAnalyzer
);
63 virtual ~OPredicateCompiler();
65 inline static void * SAL_CALL
operator new( size_t nSize
) SAL_THROW( () )
66 { return ::rtl_allocateMemory( nSize
); }
67 inline static void * SAL_CALL
operator new( size_t /*nSize*/,void* _pHint
) SAL_THROW( () )
69 inline static void SAL_CALL
operator delete( void * pMem
) SAL_THROW( () )
70 { ::rtl_freeMemory( pMem
); }
71 inline static void SAL_CALL
operator delete( void * /*pMem*/,void* /*_pHint*/ ) SAL_THROW( () )
75 void start(connectivity::OSQLParseNode
* pSQLParseNode
);
76 OOperand
* execute(connectivity::OSQLParseNode
* pPredicateNode
);
79 sal_Bool
isClean() const {return m_aCodeList
.empty();}
80 sal_Bool
hasCode() const {return !isClean();}
81 sal_Bool
hasORCondition() const {return m_bORCondition
;}
82 void setOrigColumns(const OFileColumns
& rCols
) { m_orgColumns
= rCols
; }
83 const OFileColumns
getOrigColumns() const { return m_orgColumns
; }
85 OOperand
* execute_COMPARE(connectivity::OSQLParseNode
* pPredicateNode
) throw( ::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
86 OOperand
* execute_LIKE(connectivity::OSQLParseNode
* pPredicateNode
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
87 OOperand
* execute_BETWEEN(connectivity::OSQLParseNode
* pPredicateNode
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
88 OOperand
* execute_ISNULL(connectivity::OSQLParseNode
* pPredicateNode
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
89 OOperand
* execute_Operand(connectivity::OSQLParseNode
* pPredicateNode
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
90 OOperand
* execute_Fold(OSQLParseNode
* pPredicateNode
) throw( ::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
91 OOperand
* executeFunction(OSQLParseNode
* pPredicateNode
) throw( ::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
95 class OPredicateInterpreter
:
96 public ::vos::OReference
99 ::vos::ORef
<OPredicateCompiler
> m_rCompiler
;
102 OPredicateInterpreter(const ::vos::ORef
<OPredicateCompiler
>& rComp
) : m_rCompiler(rComp
){}
103 virtual ~OPredicateInterpreter();
105 sal_Bool
evaluate(OCodeList
& rCodeList
);
106 void evaluateSelection(OCodeList
& rCodeList
,ORowSetValueDecoratorRef
& _rVal
);
108 inline sal_Bool
start()
110 return evaluate(m_rCompiler
->m_aCodeList
);
113 inline void startSelection(ORowSetValueDecoratorRef
& _rVal
)
115 return evaluateSelection(m_rCompiler
->m_aCodeList
,_rVal
);
122 #endif // _CONNECTIVITY_FILE_FCOMP_HXX_