Bump for 3.6-28
[LibreOffice.git] / connectivity / source / inc / RowFunctionParser.hxx
blobf65539da3f772fe54908b71c5ddcc4944d3c1da1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef CONNECTIVITY_ROWFUNCTIONPARSER_HXX_INCLUDED
30 #define CONNECTIVITY_ROWFUNCTIONPARSER_HXX_INCLUDED
32 #include <sal/config.h>
33 #include <boost/shared_ptr.hpp>
34 #include "FDatabaseMetaDataResultSet.hxx"
35 #include <vector>
36 #include "connectivity/dbtoolsdllapi.hxx"
38 // -------------------------------------------------------------------------
39 namespace connectivity
41 // -------------------------------------------------------------------------
42 struct OOO_DLLPUBLIC_DBTOOLS RowEquation
44 sal_Int32 nOperation;
45 ORowSetValueDecoratorRef nPara[ 3 ];
47 RowEquation() :
48 nOperation ( 0 )
53 enum ExpressionFunct
55 FUNC_CONST,
57 ENUM_FUNC_EQUATION,
59 UNARY_FUNC_COLUMN,
60 ENUM_FUNC_AND,
61 ENUM_FUNC_OR
64 #define EXPRESSION_FLAG_SUMANGLE_MODE 1
66 class OOO_DLLPUBLIC_DBTOOLS SAL_NO_VTABLE ExpressionNode
68 public:
69 virtual ~ExpressionNode(){}
71 /** Operator to calculate function value.
73 This method calculates the function value.
75 virtual ORowSetValueDecoratorRef evaluate(const ODatabaseMetaDataResultSet::ORow& _aRow ) const = 0;
77 virtual void fill(const ODatabaseMetaDataResultSet::ORow& _aRow ) const = 0;
79 /** Operator to retrieve the type of expression node
81 virtual ExpressionFunct getType() const = 0;
83 /** Operator to retrieve the ms version of expression
85 virtual ODatabaseMetaDataResultSet::ORow fillNode(
86 std::vector< RowEquation >& rEquations, ExpressionNode* pOptionalArg, sal_uInt32 nFlags ) = 0;
88 typedef ::boost::shared_ptr< ExpressionNode > ExpressionNodeSharedPtr;
90 /** This exception is thrown, when the arithmetic expression
91 parser failed to parse a string.
93 struct OOO_DLLPUBLIC_DBTOOLS ParseError
95 ParseError() {}
96 ParseError( const char* ) {}
99 class OOO_DLLPUBLIC_DBTOOLS FunctionParser
101 public:
103 /** Parse a string
105 The following grammar is accepted by this method:
106 <code>
108 number_digit = '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'
110 number = number number_digit | number_digit
112 equal_function = '='
113 ternary_function = 'if'
115 string_reference = 'a-z,A-Z,0-9' ' '
116 modifier_reference = '$' '0-9' ' '
118 basic_expression =
119 number |
120 string_reference |
121 additive_expression equal_function additive_expression |
122 unary_function '(' number_digit ')'
123 ternary_function '(' additive_expression ',' additive_expression ',
124 ' additive_expression ')' | '(' additive_expression ')'
126 </code>
128 @param rFunction
129 The string to parse
131 @throws ParseError if an invalid expression is given.
133 @return the generated function object.
136 static ExpressionNodeSharedPtr parseFunction( const ::rtl::OUString& _sFunction);
138 private:
139 // disabled constructor/destructor, since this is
140 // supposed to be a singleton
141 FunctionParser();
143 // default: disabled copy/assignment
144 FunctionParser(const FunctionParser&);
145 FunctionParser& operator=( const FunctionParser& );
148 // -------------------------------------------------------------------------
149 } // namespace connectivity
150 // -------------------------------------------------------------------------
151 #endif /* CONNECTIVITY_ROWFUNCTIONPARSER_HXX_INCLUDED */
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */