nss: upgrade to release 3.73
[LibreOffice.git] / connectivity / source / inc / RowFunctionParser.hxx
blob28ed9768941046eb016f61e0dd23b1e9894782ae
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 #ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_ROWFUNCTIONPARSER_HXX
21 #define INCLUDED_CONNECTIVITY_SOURCE_INC_ROWFUNCTIONPARSER_HXX
23 #include <sal/config.h>
24 #include "FDatabaseMetaDataResultSet.hxx"
25 #include <connectivity/dbtoolsdllapi.hxx>
26 #include <memory>
28 namespace connectivity
30 enum class ExpressionFunct
32 Equation,
33 And,
37 #define EXPRESSION_FLAG_SUMANGLE_MODE 1
39 class OOO_DLLPUBLIC_DBTOOLS SAL_NO_VTABLE ExpressionNode
41 public:
42 virtual ~ExpressionNode() {}
44 /** Operator to calculate function value.
46 This method calculates the function value.
48 virtual ORowSetValueDecoratorRef
49 evaluate(const ODatabaseMetaDataResultSet::ORow& _aRow) const = 0;
51 virtual void fill(const ODatabaseMetaDataResultSet::ORow& _aRow) const = 0;
54 /** This exception is thrown, when the arithmetic expression
55 parser failed to parse a string.
57 struct OOO_DLLPUBLIC_DBTOOLS ParseError
59 ParseError(const char*) {}
62 class FunctionParser
64 public:
65 /** Parse a string
67 The following grammar is accepted by this method:
68 <code>
70 number_digit = '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'
72 number = number number_digit | number_digit
74 equal_function = '='
75 ternary_function = 'if'
77 string_reference = 'a-z,A-Z,0-9' ' '
78 modifier_reference = '$' '0-9' ' '
80 basic_expression =
81 number |
82 string_reference |
83 additive_expression equal_function additive_expression |
84 unary_function '(' number_digit ')'
85 ternary_function '(' additive_expression ',' additive_expression ',
86 ' additive_expression ')' | '(' additive_expression ')'
88 </code>
90 @param rFunction
91 The string to parse
93 @throws ParseError if an invalid expression is given.
95 @return the generated function object.
98 static std::shared_ptr<ExpressionNode> const& parseFunction(const OUString& _sFunction);
100 private:
101 // disabled constructor/destructor, since this is
102 // supposed to be a singleton
103 FunctionParser() = delete;
104 FunctionParser(const FunctionParser&) = delete;
105 FunctionParser& operator=(const FunctionParser&) = delete;
108 } // namespace connectivity
110 #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_ROWFUNCTIONPARSER_HXX
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */