bump product version to 5.0.4.1
[LibreOffice.git] / connectivity / source / inc / RowFunctionParser.hxx
blob64d07e516c89e4d9ca9d08a51d954b79af5cb1fd
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 <boost/shared_ptr.hpp>
25 #include "FDatabaseMetaDataResultSet.hxx"
26 #include <vector>
27 #include <connectivity/dbtoolsdllapi.hxx>
30 namespace connectivity
33 struct OOO_DLLPUBLIC_DBTOOLS RowEquation
35 sal_Int32 nOperation;
36 ORowSetValueDecoratorRef nPara[ 3 ];
38 RowEquation() :
39 nOperation ( 0 )
44 enum ExpressionFunct
46 FUNC_CONST,
48 ENUM_FUNC_EQUATION,
50 UNARY_FUNC_COLUMN,
51 ENUM_FUNC_AND,
52 ENUM_FUNC_OR
55 #define EXPRESSION_FLAG_SUMANGLE_MODE 1
57 class OOO_DLLPUBLIC_DBTOOLS SAL_NO_VTABLE ExpressionNode
59 public:
60 virtual ~ExpressionNode(){}
62 /** Operator to calculate function value.
64 This method calculates the function value.
66 virtual ORowSetValueDecoratorRef evaluate(const ODatabaseMetaDataResultSet::ORow& _aRow ) const = 0;
68 virtual void fill(const ODatabaseMetaDataResultSet::ORow& _aRow ) const = 0;
70 /** Operator to retrieve the type of expression node
72 virtual ExpressionFunct getType() const = 0;
74 /** Operator to retrieve the ms version of expression
76 virtual ODatabaseMetaDataResultSet::ORow fillNode(
77 std::vector< RowEquation >& rEquations, ExpressionNode* pOptionalArg, sal_uInt32 nFlags ) = 0;
79 typedef ::boost::shared_ptr< ExpressionNode > ExpressionNodeSharedPtr;
81 /** This exception is thrown, when the arithmetic expression
82 parser failed to parse a string.
84 struct OOO_DLLPUBLIC_DBTOOLS ParseError
86 ParseError() {}
87 ParseError( const char* ) {}
90 class OOO_DLLPUBLIC_DBTOOLS FunctionParser
92 public:
94 /** Parse a string
96 The following grammar is accepted by this method:
97 <code>
99 number_digit = '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'
101 number = number number_digit | number_digit
103 equal_function = '='
104 ternary_function = 'if'
106 string_reference = 'a-z,A-Z,0-9' ' '
107 modifier_reference = '$' '0-9' ' '
109 basic_expression =
110 number |
111 string_reference |
112 additive_expression equal_function additive_expression |
113 unary_function '(' number_digit ')'
114 ternary_function '(' additive_expression ',' additive_expression ',
115 ' additive_expression ')' | '(' additive_expression ')'
117 </code>
119 @param rFunction
120 The string to parse
122 @throws ParseError if an invalid expression is given.
124 @return the generated function object.
127 static ExpressionNodeSharedPtr parseFunction( const OUString& _sFunction);
129 private:
130 // disabled constructor/destructor, since this is
131 // supposed to be a singleton
132 FunctionParser();
134 FunctionParser(const FunctionParser&) SAL_DELETED_FUNCTION;
135 FunctionParser& operator=( const FunctionParser& ) SAL_DELETED_FUNCTION;
139 } // namespace connectivity
141 #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_ROWFUNCTIONPARSER_HXX
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */