bump product version to 5.0.4.1
[LibreOffice.git] / connectivity / source / inc / file / fcomp.hxx
blob7f09023ae4b60851be963b411252be8671ecf58c
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 INCLUDED_CONNECTIVITY_SOURCE_INC_FILE_FCOMP_HXX
20 #define INCLUDED_CONNECTIVITY_SOURCE_INC_FILE_FCOMP_HXX
22 #include "file/fcode.hxx"
23 #include "file/filedllapi.hxx"
24 #include <list>
26 namespace connectivity
28 class OSQLParseNode;
29 namespace file
31 class OCode;
32 class OOperand;
33 class OSQLAnalyzer;
34 typedef::std::vector<OCode*> OCodeList;
36 class OPredicateCompiler : public ::salhelper::SimpleReferenceObject
38 friend class OPredicateInterpreter;
39 friend class OSQLAnalyzer;
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 bool m_bORCondition;
47 public:
48 OPredicateCompiler(OSQLAnalyzer* pAnalyzer);
50 virtual ~OPredicateCompiler();
52 inline static void * SAL_CALL operator new( size_t nSize )
53 { return ::rtl_allocateMemory( nSize ); }
54 inline static void * SAL_CALL operator new( size_t /*nSize*/,void* _pHint )
55 { return _pHint; }
56 inline static void SAL_CALL operator delete( void * pMem )
57 { ::rtl_freeMemory( pMem ); }
58 inline static void SAL_CALL operator delete( void * /*pMem*/,void* /*_pHint*/ )
59 { }
60 void dispose();
62 void start(connectivity::OSQLParseNode* pSQLParseNode);
63 OOperand* execute(connectivity::OSQLParseNode* pPredicateNode);
65 void Clean();
66 bool isClean() const {return m_aCodeList.empty();}
67 bool hasCode() const {return !isClean();}
68 bool hasORCondition() const {return m_bORCondition;}
69 void setOrigColumns(const OFileColumns& rCols) { m_orgColumns = rCols; }
70 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);
82 class OPredicateInterpreter :
83 public ::salhelper::SimpleReferenceObject
85 OCodeStack m_aStack;
86 ::rtl::Reference<OPredicateCompiler> m_rCompiler;
88 public:
89 OPredicateInterpreter(const ::rtl::Reference<OPredicateCompiler>& rComp) : m_rCompiler(rComp){}
90 virtual ~OPredicateInterpreter();
92 bool evaluate(OCodeList& rCodeList);
93 void evaluateSelection(OCodeList& rCodeList,ORowSetValueDecoratorRef& _rVal);
95 inline bool start()
97 return evaluate(m_rCompiler->m_aCodeList);
100 inline void startSelection(ORowSetValueDecoratorRef& _rVal)
102 evaluateSelection(m_rCompiler->m_aCodeList,_rVal);
109 #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_FILE_FCOMP_HXX
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */