1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include <file/fcode.hxx>
24 namespace connectivity
32 typedef std::vector
<std::unique_ptr
<OCode
>> OCodeList
;
34 class OPredicateCompiler final
: public ::salhelper::SimpleReferenceObject
36 friend class OPredicateInterpreter
;
37 friend class OSQLAnalyzer
;
39 OCodeList m_aCodeList
;
40 css::uno::Reference
< css::container::XNameAccess
> m_orgColumns
; // in filecurs this are the filecolumns
41 OSQLAnalyzer
* m_pAnalyzer
;
42 sal_Int32 m_nParamCounter
;
44 OPredicateCompiler(OSQLAnalyzer
* pAnalyzer
);
46 virtual ~OPredicateCompiler() override
;
50 void start(connectivity::OSQLParseNode
const * pSQLParseNode
);
51 OOperand
* execute(connectivity::OSQLParseNode
const * pPredicateNode
);
54 bool isClean() const {return m_aCodeList
.empty();}
55 bool hasCode() const {return !isClean();}
56 void setOrigColumns(const css::uno::Reference
< css::container::XNameAccess
>& rCols
) { m_orgColumns
= rCols
; }
57 const css::uno::Reference
< css::container::XNameAccess
>& getOrigColumns() const { return m_orgColumns
; }
59 /// @throws css::sdbc::SQLException
60 /// @throws css::uno::RuntimeException
61 void execute_COMPARE(connectivity::OSQLParseNode
const * pPredicateNode
);
62 /// @throws css::sdbc::SQLException
63 /// @throws css::uno::RuntimeException
64 void execute_LIKE(connectivity::OSQLParseNode
const * pPredicateNode
);
65 /// @throws css::sdbc::SQLException
66 /// @throws css::uno::RuntimeException
67 void execute_BETWEEN(connectivity::OSQLParseNode
const * pPredicateNode
);
68 /// @throws css::sdbc::SQLException
69 /// @throws css::uno::RuntimeException
70 void execute_ISNULL(connectivity::OSQLParseNode
const * pPredicateNode
);
71 /// @throws css::sdbc::SQLException
72 /// @throws css::uno::RuntimeException
73 OOperand
* execute_Operand(connectivity::OSQLParseNode
const * pPredicateNode
);
74 /// @throws css::sdbc::SQLException
75 /// @throws css::uno::RuntimeException
76 void execute_Fold(OSQLParseNode
const * pPredicateNode
);
77 /// @throws css::sdbc::SQLException
78 /// @throws css::uno::RuntimeException
79 void executeFunction(OSQLParseNode
const * pPredicateNode
);
83 class OPredicateInterpreter
:
84 public ::salhelper::SimpleReferenceObject
87 ::rtl::Reference
<OPredicateCompiler
> m_rCompiler
;
90 OPredicateInterpreter(::rtl::Reference
<OPredicateCompiler
> xComp
) : m_rCompiler(std::move(xComp
)){}
91 virtual ~OPredicateInterpreter() override
;
93 bool evaluate(OCodeList
& rCodeList
);
94 void evaluateSelection(OCodeList
& rCodeList
, ORowSetValueDecoratorRef
const & _rVal
);
98 return evaluate(m_rCompiler
->m_aCodeList
);
101 void startSelection(ORowSetValueDecoratorRef
const & _rVal
)
103 evaluateSelection(m_rCompiler
->m_aCodeList
,_rVal
);
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */