xref: /trunk/main/connectivity/source/inc/file/fcomp.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
1*caf5cd79SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*caf5cd79SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*caf5cd79SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*caf5cd79SAndrew Rist  * distributed with this work for additional information
6*caf5cd79SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*caf5cd79SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*caf5cd79SAndrew Rist  * "License"); you may not use this file except in compliance
9*caf5cd79SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*caf5cd79SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*caf5cd79SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*caf5cd79SAndrew Rist  * software distributed under the License is distributed on an
15*caf5cd79SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*caf5cd79SAndrew Rist  * KIND, either express or implied.  See the License for the
17*caf5cd79SAndrew Rist  * specific language governing permissions and limitations
18*caf5cd79SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*caf5cd79SAndrew Rist  *************************************************************/
21*caf5cd79SAndrew Rist 
22*caf5cd79SAndrew Rist 
23cdf0e10cSrcweir #ifndef _CONNECTIVITY_FILE_FCOMP_HXX_
24cdf0e10cSrcweir #define _CONNECTIVITY_FILE_FCOMP_HXX_
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "file/fcode.hxx"
27cdf0e10cSrcweir #include "file/filedllapi.hxx"
28cdf0e10cSrcweir #ifndef _LIST_
29cdf0e10cSrcweir #include <list>
30cdf0e10cSrcweir #endif
31cdf0e10cSrcweir 
32cdf0e10cSrcweir namespace connectivity
33cdf0e10cSrcweir {
34cdf0e10cSrcweir     class OSQLParseNode;
35cdf0e10cSrcweir     namespace file
36cdf0e10cSrcweir     {
37cdf0e10cSrcweir         class OCode;
38cdf0e10cSrcweir         class OOperand;
39cdf0e10cSrcweir         class OSQLAnalyzer;
40cdf0e10cSrcweir         typedef::std::vector<OCode*> OCodeList;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir         class OPredicateCompiler : public ::vos::OReference
43cdf0e10cSrcweir         {
44cdf0e10cSrcweir             friend class OPredicateInterpreter;
45cdf0e10cSrcweir             friend class OSQLAnalyzer;
46cdf0e10cSrcweir 
47cdf0e10cSrcweir             OCodeList                               m_aCodeList;
48cdf0e10cSrcweir             OFileColumns                            m_orgColumns; // in filecurs this are the filecolumns
49cdf0e10cSrcweir             OSQLAnalyzer*                           m_pAnalyzer;
50cdf0e10cSrcweir             ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xIndexes;
51cdf0e10cSrcweir             sal_Int32                               m_nParamCounter;
52cdf0e10cSrcweir             sal_Bool                                m_bORCondition;
53cdf0e10cSrcweir         public:
54cdf0e10cSrcweir             OPredicateCompiler(OSQLAnalyzer* pAnalyzer);
55cdf0e10cSrcweir 
56cdf0e10cSrcweir             virtual ~OPredicateCompiler();
57cdf0e10cSrcweir 
operator new(size_t nSize)58cdf0e10cSrcweir             inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
59cdf0e10cSrcweir                 { return ::rtl_allocateMemory( nSize ); }
operator new(size_t,void * _pHint)60cdf0e10cSrcweir             inline static void * SAL_CALL operator new( size_t /*nSize*/,void* _pHint ) SAL_THROW( () )
61cdf0e10cSrcweir                 { return _pHint; }
operator delete(void * pMem)62cdf0e10cSrcweir             inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () )
63cdf0e10cSrcweir                 { ::rtl_freeMemory( pMem ); }
operator delete(void *,void *)64cdf0e10cSrcweir             inline static void SAL_CALL operator delete( void * /*pMem*/,void* /*_pHint*/ ) SAL_THROW( () )
65cdf0e10cSrcweir                 {  }
66cdf0e10cSrcweir             void dispose();
67cdf0e10cSrcweir 
68cdf0e10cSrcweir             void start(connectivity::OSQLParseNode* pSQLParseNode);
69cdf0e10cSrcweir             OOperand* execute(connectivity::OSQLParseNode* pPredicateNode);
70cdf0e10cSrcweir 
71cdf0e10cSrcweir             void Clean();
isClean() const72cdf0e10cSrcweir             sal_Bool isClean() const {return m_aCodeList.empty();}
hasCode() const73cdf0e10cSrcweir             sal_Bool hasCode() const {return !isClean();}
hasORCondition() const74cdf0e10cSrcweir             sal_Bool hasORCondition() const {return m_bORCondition;}
setOrigColumns(const OFileColumns & rCols)75cdf0e10cSrcweir             void     setOrigColumns(const OFileColumns& rCols) { m_orgColumns = rCols; }
getOrigColumns() const76cdf0e10cSrcweir             const OFileColumns getOrigColumns() const { return m_orgColumns; }
77cdf0e10cSrcweir         protected:
78cdf0e10cSrcweir             OOperand* execute_COMPARE(connectivity::OSQLParseNode* pPredicateNode) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
79cdf0e10cSrcweir             OOperand* execute_LIKE(connectivity::OSQLParseNode* pPredicateNode) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
80cdf0e10cSrcweir             OOperand* execute_BETWEEN(connectivity::OSQLParseNode* pPredicateNode) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
81cdf0e10cSrcweir             OOperand* execute_ISNULL(connectivity::OSQLParseNode* pPredicateNode) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
82cdf0e10cSrcweir             OOperand* execute_Operand(connectivity::OSQLParseNode* pPredicateNode) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
83cdf0e10cSrcweir             OOperand* execute_Fold(OSQLParseNode* pPredicateNode) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
84cdf0e10cSrcweir             OOperand* executeFunction(OSQLParseNode* pPredicateNode) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
85cdf0e10cSrcweir         };
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 
88cdf0e10cSrcweir         class OPredicateInterpreter :
89cdf0e10cSrcweir             public ::vos::OReference
90cdf0e10cSrcweir         {
91cdf0e10cSrcweir             OCodeStack          m_aStack;
92cdf0e10cSrcweir             ::vos::ORef<OPredicateCompiler> m_rCompiler;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir         public:
OPredicateInterpreter(const::vos::ORef<OPredicateCompiler> & rComp)95cdf0e10cSrcweir             OPredicateInterpreter(const ::vos::ORef<OPredicateCompiler>& rComp) : m_rCompiler(rComp){}
96cdf0e10cSrcweir             virtual ~OPredicateInterpreter();
97cdf0e10cSrcweir 
98cdf0e10cSrcweir             sal_Bool    evaluate(OCodeList& rCodeList);
99cdf0e10cSrcweir             void        evaluateSelection(OCodeList& rCodeList,ORowSetValueDecoratorRef& _rVal);
100cdf0e10cSrcweir 
start()101cdf0e10cSrcweir             inline sal_Bool start()
102cdf0e10cSrcweir             {
103cdf0e10cSrcweir                 return evaluate(m_rCompiler->m_aCodeList);
104cdf0e10cSrcweir             }
105cdf0e10cSrcweir 
startSelection(ORowSetValueDecoratorRef & _rVal)106cdf0e10cSrcweir             inline void startSelection(ORowSetValueDecoratorRef& _rVal)
107cdf0e10cSrcweir             {
108cdf0e10cSrcweir                 evaluateSelection(m_rCompiler->m_aCodeList,_rVal);
109cdf0e10cSrcweir             }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 
112cdf0e10cSrcweir         };
113cdf0e10cSrcweir     }
114cdf0e10cSrcweir }
115cdf0e10cSrcweir #endif // _CONNECTIVITY_FILE_FCOMP_HXX_
116