/src/libreoffice/connectivity/source/inc/file/fcomp.hxx
Line | Count | Source |
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 | | #pragma once |
20 | | |
21 | | #include <file/fcode.hxx> |
22 | | #include <utility> |
23 | | |
24 | | namespace connectivity |
25 | | { |
26 | | class OSQLParseNode; |
27 | | namespace file |
28 | | { |
29 | | class OSQLAnalyzer; |
30 | | typedef std::vector<std::unique_ptr<OCode>> OCodeList; |
31 | | |
32 | | class OPredicateCompiler final : public ::salhelper::SimpleReferenceObject |
33 | | { |
34 | | friend class OPredicateInterpreter; |
35 | | friend class OSQLAnalyzer; |
36 | | |
37 | | OCodeList m_aCodeList; |
38 | | css::uno::Reference< css::container::XNameAccess> m_orgColumns; // in filecurs this are the filecolumns |
39 | | OSQLAnalyzer* m_pAnalyzer; |
40 | | sal_Int32 m_nParamCounter; |
41 | | public: |
42 | | OPredicateCompiler(OSQLAnalyzer* pAnalyzer); |
43 | | |
44 | | virtual ~OPredicateCompiler() override; |
45 | | |
46 | | void dispose(); |
47 | | |
48 | | void start(connectivity::OSQLParseNode const * pSQLParseNode); |
49 | | OOperand* execute(connectivity::OSQLParseNode const * pPredicateNode); |
50 | | |
51 | | void Clean(); |
52 | 2.55M | bool isClean() const {return m_aCodeList.empty();} |
53 | 2.55M | bool hasCode() const {return !isClean();} |
54 | 33.3k | void setOrigColumns(const css::uno::Reference< css::container::XNameAccess>& rCols) { m_orgColumns = rCols; } |
55 | 0 | const css::uno::Reference< css::container::XNameAccess>& getOrigColumns() const { return m_orgColumns; } |
56 | | private: |
57 | | /// @throws css::sdbc::SQLException |
58 | | /// @throws css::uno::RuntimeException |
59 | | void execute_COMPARE(connectivity::OSQLParseNode const * pPredicateNode); |
60 | | /// @throws css::sdbc::SQLException |
61 | | /// @throws css::uno::RuntimeException |
62 | | void execute_LIKE(connectivity::OSQLParseNode const * pPredicateNode); |
63 | | /// @throws css::sdbc::SQLException |
64 | | /// @throws css::uno::RuntimeException |
65 | | void execute_BETWEEN(connectivity::OSQLParseNode const * pPredicateNode); |
66 | | /// @throws css::sdbc::SQLException |
67 | | /// @throws css::uno::RuntimeException |
68 | | void execute_ISNULL(connectivity::OSQLParseNode const * pPredicateNode); |
69 | | /// @throws css::sdbc::SQLException |
70 | | /// @throws css::uno::RuntimeException |
71 | | OOperand* execute_Operand(connectivity::OSQLParseNode const * pPredicateNode); |
72 | | /// @throws css::sdbc::SQLException |
73 | | /// @throws css::uno::RuntimeException |
74 | | void execute_Fold(OSQLParseNode const * pPredicateNode); |
75 | | /// @throws css::sdbc::SQLException |
76 | | /// @throws css::uno::RuntimeException |
77 | | void executeFunction(OSQLParseNode const * pPredicateNode); |
78 | | }; |
79 | | |
80 | | |
81 | | class OPredicateInterpreter : |
82 | | public ::salhelper::SimpleReferenceObject |
83 | | { |
84 | | OCodeStack m_aStack; |
85 | | ::rtl::Reference<OPredicateCompiler> m_rCompiler; |
86 | | |
87 | | public: |
88 | 33.3k | OPredicateInterpreter(::rtl::Reference<OPredicateCompiler> xComp) : m_rCompiler(std::move(xComp)){} |
89 | | virtual ~OPredicateInterpreter() override; |
90 | | |
91 | | bool evaluate(OCodeList& rCodeList); |
92 | | void evaluateSelection(OCodeList& rCodeList, ORowSetValueDecoratorRef const & _rVal); |
93 | | |
94 | | bool start() |
95 | 0 | { |
96 | 0 | return evaluate(m_rCompiler->m_aCodeList); |
97 | 0 | } |
98 | | |
99 | | void startSelection(ORowSetValueDecoratorRef const & _rVal) |
100 | 0 | { |
101 | 0 | evaluateSelection(m_rCompiler->m_aCodeList,_rVal); |
102 | 0 | } |
103 | | |
104 | | |
105 | | }; |
106 | | } |
107 | | } |
108 | | |
109 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |