2010-10-27 13:11:31 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-12 22:04:38 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2014-04-18 18:41:08 +02:00
|
|
|
#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_FILE_FCOMP_HXX
|
|
|
|
#define INCLUDED_CONNECTIVITY_SOURCE_INC_FILE_FCOMP_HXX
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2017-10-23 22:43:41 +02:00
|
|
|
#include <file/fcode.hxx>
|
|
|
|
#include <file/filedllapi.hxx>
|
2000-09-18 15:18:56 +00:00
|
|
|
#include <list>
|
|
|
|
|
|
|
|
namespace connectivity
|
|
|
|
{
|
|
|
|
class OSQLParseNode;
|
|
|
|
namespace file
|
|
|
|
{
|
|
|
|
class OCode;
|
|
|
|
class OOperand;
|
2005-06-14 15:21:58 +00:00
|
|
|
class OSQLAnalyzer;
|
2018-08-16 10:31:35 +02:00
|
|
|
typedef std::vector<std::unique_ptr<OCode>> OCodeList;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2017-11-07 10:08:18 +02:00
|
|
|
class OPredicateCompiler final : public ::salhelper::SimpleReferenceObject
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
friend class OPredicateInterpreter;
|
|
|
|
friend class OSQLAnalyzer;
|
|
|
|
|
|
|
|
OCodeList m_aCodeList;
|
2016-05-27 12:31:29 +02:00
|
|
|
css::uno::Reference< css::container::XNameAccess> m_orgColumns; // in filecurs this are the filecolumns
|
2000-09-18 15:18:56 +00:00
|
|
|
OSQLAnalyzer* m_pAnalyzer;
|
2001-04-10 07:51:30 +00:00
|
|
|
sal_Int32 m_nParamCounter;
|
2000-09-18 15:18:56 +00:00
|
|
|
public:
|
|
|
|
OPredicateCompiler(OSQLAnalyzer* pAnalyzer);
|
|
|
|
|
2016-09-13 13:09:01 +02:00
|
|
|
virtual ~OPredicateCompiler() override;
|
2002-07-05 07:07:52 +00:00
|
|
|
|
2000-11-03 12:49:39 +00:00
|
|
|
void dispose();
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2017-07-18 13:40:38 +02:00
|
|
|
void start(connectivity::OSQLParseNode const * pSQLParseNode);
|
2017-07-28 11:47:51 +02:00
|
|
|
OOperand* execute(connectivity::OSQLParseNode const * pPredicateNode);
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
void Clean();
|
2014-04-16 09:14:24 +02:00
|
|
|
bool isClean() const {return m_aCodeList.empty();}
|
|
|
|
bool hasCode() const {return !isClean();}
|
2015-10-21 12:42:16 +02:00
|
|
|
void setOrigColumns(const css::uno::Reference< css::container::XNameAccess>& rCols) { m_orgColumns = rCols; }
|
2016-04-13 10:42:52 +02:00
|
|
|
const css::uno::Reference< css::container::XNameAccess>& getOrigColumns() const { return m_orgColumns; }
|
2017-11-07 10:08:18 +02:00
|
|
|
private:
|
2017-01-19 17:59:45 +01:00
|
|
|
/// @throws css::sdbc::SQLException
|
|
|
|
/// @throws css::uno::RuntimeException
|
2017-07-18 13:40:38 +02:00
|
|
|
void execute_COMPARE(connectivity::OSQLParseNode const * pPredicateNode);
|
2017-01-19 17:59:45 +01:00
|
|
|
/// @throws css::sdbc::SQLException
|
|
|
|
/// @throws css::uno::RuntimeException
|
2017-07-18 13:40:38 +02:00
|
|
|
void execute_LIKE(connectivity::OSQLParseNode const * pPredicateNode);
|
2017-01-19 17:59:45 +01:00
|
|
|
/// @throws css::sdbc::SQLException
|
|
|
|
/// @throws css::uno::RuntimeException
|
2017-07-18 13:40:38 +02:00
|
|
|
void execute_BETWEEN(connectivity::OSQLParseNode const * pPredicateNode);
|
2017-01-19 17:59:45 +01:00
|
|
|
/// @throws css::sdbc::SQLException
|
|
|
|
/// @throws css::uno::RuntimeException
|
2017-07-18 13:40:38 +02:00
|
|
|
void execute_ISNULL(connectivity::OSQLParseNode const * pPredicateNode);
|
2017-01-19 17:59:45 +01:00
|
|
|
/// @throws css::sdbc::SQLException
|
|
|
|
/// @throws css::uno::RuntimeException
|
2017-07-28 11:47:51 +02:00
|
|
|
OOperand* execute_Operand(connectivity::OSQLParseNode const * pPredicateNode);
|
2017-01-19 17:59:45 +01:00
|
|
|
/// @throws css::sdbc::SQLException
|
|
|
|
/// @throws css::uno::RuntimeException
|
2017-07-18 13:40:38 +02:00
|
|
|
void execute_Fold(OSQLParseNode const * pPredicateNode);
|
2017-01-19 17:59:45 +01:00
|
|
|
/// @throws css::sdbc::SQLException
|
|
|
|
/// @throws css::uno::RuntimeException
|
2017-07-18 13:40:38 +02:00
|
|
|
void executeFunction(OSQLParseNode const * pPredicateNode);
|
2000-09-18 15:18:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-04-23 10:42:05 +00:00
|
|
|
class OPredicateInterpreter :
|
2010-10-15 12:10:06 -05:00
|
|
|
public ::salhelper::SimpleReferenceObject
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
OCodeStack m_aStack;
|
2010-10-15 12:10:06 -05:00
|
|
|
::rtl::Reference<OPredicateCompiler> m_rCompiler;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
public:
|
2010-10-15 12:10:06 -05:00
|
|
|
OPredicateInterpreter(const ::rtl::Reference<OPredicateCompiler>& rComp) : m_rCompiler(rComp){}
|
2016-09-13 13:09:01 +02:00
|
|
|
virtual ~OPredicateInterpreter() override;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2014-04-16 09:14:24 +02:00
|
|
|
bool evaluate(OCodeList& rCodeList);
|
2017-07-18 13:40:38 +02:00
|
|
|
void evaluateSelection(OCodeList& rCodeList, ORowSetValueDecoratorRef const & _rVal);
|
2003-09-04 07:29:01 +00:00
|
|
|
|
2017-03-03 20:57:02 +01:00
|
|
|
bool start()
|
2003-09-04 07:29:01 +00:00
|
|
|
{
|
|
|
|
return evaluate(m_rCompiler->m_aCodeList);
|
|
|
|
}
|
|
|
|
|
2017-07-18 13:40:38 +02:00
|
|
|
void startSelection(ORowSetValueDecoratorRef const & _rVal)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2010-09-27 15:26:48 +02:00
|
|
|
evaluateSelection(m_rCompiler->m_aCodeList,_rVal);
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2003-09-04 07:29:01 +00:00
|
|
|
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2014-04-18 18:41:08 +02:00
|
|
|
#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_FILE_FCOMP_HXX
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2010-10-27 13:11:31 +01:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|