Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef _CONNECTIVITY_FILE_FCOMP_HXX_
20 : #define _CONNECTIVITY_FILE_FCOMP_HXX_
21 :
22 : #include "file/fcode.hxx"
23 : #include "file/filedllapi.hxx"
24 : #include <list>
25 :
26 : namespace connectivity
27 : {
28 : class OSQLParseNode;
29 : namespace file
30 : {
31 : class OCode;
32 : class OOperand;
33 : class OSQLAnalyzer;
34 : typedef::std::vector<OCode*> OCodeList;
35 :
36 : class OPredicateCompiler : public ::salhelper::SimpleReferenceObject
37 : {
38 : friend class OPredicateInterpreter;
39 : friend class OSQLAnalyzer;
40 :
41 : OCodeList m_aCodeList;
42 : OFileColumns m_orgColumns; // in filecurs this are the filecolumns
43 : OSQLAnalyzer* m_pAnalyzer;
44 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xIndexes;
45 : sal_Int32 m_nParamCounter;
46 : sal_Bool m_bORCondition;
47 : public:
48 : OPredicateCompiler(OSQLAnalyzer* pAnalyzer);
49 :
50 : virtual ~OPredicateCompiler();
51 :
52 0 : inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW(())
53 0 : { return ::rtl_allocateMemory( nSize ); }
54 : inline static void * SAL_CALL operator new( size_t /*nSize*/,void* _pHint ) SAL_THROW(())
55 : { return _pHint; }
56 0 : inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW(())
57 0 : { ::rtl_freeMemory( pMem ); }
58 : inline static void SAL_CALL operator delete( void * /*pMem*/,void* /*_pHint*/ ) SAL_THROW(())
59 : { }
60 : void dispose();
61 :
62 : void start(connectivity::OSQLParseNode* pSQLParseNode);
63 : OOperand* execute(connectivity::OSQLParseNode* pPredicateNode);
64 :
65 : void Clean();
66 0 : sal_Bool isClean() const {return m_aCodeList.empty();}
67 0 : sal_Bool hasCode() const {return !isClean();}
68 0 : sal_Bool hasORCondition() const {return m_bORCondition;}
69 0 : void setOrigColumns(const OFileColumns& rCols) { m_orgColumns = rCols; }
70 0 : const OFileColumns getOrigColumns() const { return m_orgColumns; }
71 : protected:
72 : OOperand* execute_COMPARE(connectivity::OSQLParseNode* pPredicateNode) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
73 : OOperand* execute_LIKE(connectivity::OSQLParseNode* pPredicateNode) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
74 : OOperand* execute_BETWEEN(connectivity::OSQLParseNode* pPredicateNode) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
75 : OOperand* execute_ISNULL(connectivity::OSQLParseNode* pPredicateNode) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
76 : OOperand* execute_Operand(connectivity::OSQLParseNode* pPredicateNode) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
77 : OOperand* execute_Fold(OSQLParseNode* pPredicateNode) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
78 : OOperand* executeFunction(OSQLParseNode* pPredicateNode) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
79 : };
80 :
81 :
82 : class OPredicateInterpreter :
83 : public ::salhelper::SimpleReferenceObject
84 : {
85 : OCodeStack m_aStack;
86 : ::rtl::Reference<OPredicateCompiler> m_rCompiler;
87 :
88 : public:
89 0 : OPredicateInterpreter(const ::rtl::Reference<OPredicateCompiler>& rComp) : m_rCompiler(rComp){}
90 : virtual ~OPredicateInterpreter();
91 :
92 : sal_Bool evaluate(OCodeList& rCodeList);
93 : void evaluateSelection(OCodeList& rCodeList,ORowSetValueDecoratorRef& _rVal);
94 :
95 0 : inline sal_Bool start()
96 : {
97 0 : return evaluate(m_rCompiler->m_aCodeList);
98 : }
99 :
100 0 : inline void startSelection(ORowSetValueDecoratorRef& _rVal)
101 : {
102 0 : evaluateSelection(m_rCompiler->m_aCodeList,_rVal);
103 0 : }
104 :
105 :
106 : };
107 : }
108 : }
109 : #endif // _CONNECTIVITY_FILE_FCOMP_HXX_
110 :
111 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|