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 .
22 #include <sal/config.h>
23 #include "FDatabaseMetaDataResultSet.hxx"
24 #include <connectivity/dbtoolsdllapi.hxx>
27 namespace connectivity
29 enum class ExpressionFunct
36 #define EXPRESSION_FLAG_SUMANGLE_MODE 1
38 class OOO_DLLPUBLIC_DBTOOLS SAL_NO_VTABLE ExpressionNode
41 virtual ~ExpressionNode() {}
43 /** Operator to calculate function value.
45 This method calculates the function value.
47 virtual ORowSetValueDecoratorRef
48 evaluate(const ODatabaseMetaDataResultSet::ORow
& _aRow
) const = 0;
50 virtual void fill(const ODatabaseMetaDataResultSet::ORow
& _aRow
) const = 0;
53 /** This exception is thrown, when the arithmetic expression
54 parser failed to parse a string.
56 struct OOO_DLLPUBLIC_DBTOOLS ParseError
58 ParseError(const char*) {}
66 The following grammar is accepted by this method:
69 number_digit = '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'
71 number = number number_digit | number_digit
74 ternary_function = 'if'
76 string_reference = 'a-z,A-Z,0-9' ' '
77 modifier_reference = '$' '0-9' ' '
82 additive_expression equal_function additive_expression |
83 unary_function '(' number_digit ')'
84 ternary_function '(' additive_expression ',' additive_expression ',
85 ' additive_expression ')' | '(' additive_expression ')'
92 @throws ParseError if an invalid expression is given.
94 @return the generated function object.
97 static std::shared_ptr
<ExpressionNode
> const& parseFunction(const OUString
& _sFunction
);
100 // disabled constructor/destructor, since this is
101 // supposed to be a singleton
102 FunctionParser() = delete;
103 FunctionParser(const FunctionParser
&) = delete;
104 FunctionParser
& operator=(const FunctionParser
&) = delete;
107 } // namespace connectivity
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */