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 
20 #pragma once
21 
22 #include <file/fcomp.hxx>
23 
24 namespace connectivity::file
25     {
26         class OConnection;
27         class OSQLAnalyzer final
28         {
29             typedef std::pair< ::rtl::Reference<OPredicateCompiler>,::rtl::Reference<OPredicateInterpreter> > TPredicates;
30 
31             std::vector< TPredicates >        m_aSelectionEvaluations;
32             ::rtl::Reference<OPredicateCompiler>        m_aCompiler;
33             ::rtl::Reference<OPredicateInterpreter> m_aInterpreter;
34             OConnection*                        m_pConnection;
35 
36             mutable bool                    m_bHasSelectionCode;
37             mutable bool                    m_bSelectionFirstTime;
38 
39             static void bindRow(OCodeList& rCodeList,const OValueRefRow& _pRow);
40 
41         public:
42             OSQLAnalyzer(OConnection* _pConnection);
43             ~OSQLAnalyzer();
44 
getConnection() const45             OConnection* getConnection() const { return m_pConnection; }
46             void bindEvaluationRow(OValueRefRow const & _pRow); // Bind an evaluation row to the restriction
47             /** bind the select columns if they contain a function which needs a row value
48                 @param  _pRow   the result row
49             */
50             void bindSelectRow(const OValueRefRow& _pRow);
51 
52             /** binds the row to parameter for the restrictions
53                 @param  _pRow   the parameter row
54             */
55             void bindParameterRow(OValueRefRow const & _pRow);
56 
57             void dispose();
58             void start(OSQLParseNode const * pSQLParseNode);
59             bool hasRestriction() const;
60             bool hasFunctions() const;
evaluateRestriction()61             bool evaluateRestriction()   { return m_aInterpreter->start(); }
62             void setSelectionEvaluationResult(OValueRefRow const & _pRow,const std::vector<sal_Int32>& _rColumnMapping);
63             void setOrigColumns(const css::uno::Reference< css::container::XNameAccess>& rCols);
64             static OOperandAttr* createOperandAttr(sal_Int32 _nPos,
65                                                     const css::uno::Reference< css::beans::XPropertySet>& _xCol);
66         };
67 
68 }
69 
70 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
71