tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / connectivity / source / inc / RowFunctionParser.hxx
blob059544e51f2df6cd7c005b7217202f1527419027
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #pragma once
22 #include <sal/config.h>
23 #include "FDatabaseMetaDataResultSet.hxx"
24 #include <connectivity/dbtoolsdllapi.hxx>
25 #include <memory>
27 namespace connectivity
29 enum class ExpressionFunct
31 Equation,
32 And,
36 #define EXPRESSION_FLAG_SUMANGLE_MODE 1
38 class OOO_DLLPUBLIC_DBTOOLS SAL_NO_VTABLE ExpressionNode
40 public:
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*) {}
61 class FunctionParser
63 public:
64 /** Parse a string
66 The following grammar is accepted by this method:
67 <code>
69 number_digit = '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'
71 number = number number_digit | number_digit
73 equal_function = '='
74 ternary_function = 'if'
76 string_reference = 'a-z,A-Z,0-9' ' '
77 modifier_reference = '$' '0-9' ' '
79 basic_expression =
80 number |
81 string_reference |
82 additive_expression equal_function additive_expression |
83 unary_function '(' number_digit ')'
84 ternary_function '(' additive_expression ',' additive_expression ',
85 ' additive_expression ')' | '(' additive_expression ')'
87 </code>
89 @param rFunction
90 The string to parse
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);
99 private:
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: */