1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: RowFunctionParser.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef CONNECTIVITY_ROWFUNCTIONPARSER_HXX_INCLUDED
32 #define CONNECTIVITY_ROWFUNCTIONPARSER_HXX_INCLUDED
34 #include <sal/config.h>
35 #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
36 #include <boost/shared_ptr.hpp>
38 #include "FDatabaseMetaDataResultSet.hxx"
40 #include "connectivity/dbtoolsdllapi.hxx"
42 // -------------------------------------------------------------------------
43 namespace connectivity
45 // -------------------------------------------------------------------------
46 struct OOO_DLLPUBLIC_DBTOOLS RowEquation
49 ORowSetValueDecoratorRef nPara
[ 3 ];
68 #define EXPRESSION_FLAG_SUMANGLE_MODE 1
70 class OOO_DLLPUBLIC_DBTOOLS SAL_NO_VTABLE ExpressionNode
73 virtual ~ExpressionNode(){}
75 /** Operator to calculate function value.
77 This method calculates the function value.
79 virtual ORowSetValueDecoratorRef
evaluate(const ODatabaseMetaDataResultSet::ORow
& _aRow
) const = 0;
81 virtual void fill(const ODatabaseMetaDataResultSet::ORow
& _aRow
) const = 0;
83 /** Operator to retrieve the type of expression node
85 virtual ExpressionFunct
getType() const = 0;
87 /** Operator to retrieve the ms version of expression
89 virtual ODatabaseMetaDataResultSet::ORow
fillNode(
90 std::vector
< RowEquation
>& rEquations
, ExpressionNode
* pOptionalArg
, sal_uInt32 nFlags
) = 0;
92 typedef ::boost::shared_ptr
< ExpressionNode
> ExpressionNodeSharedPtr
;
94 /** This exception is thrown, when the arithmetic expression
95 parser failed to parse a string.
97 struct OOO_DLLPUBLIC_DBTOOLS ParseError
100 ParseError( const char* ) {}
103 class OOO_DLLPUBLIC_DBTOOLS FunctionParser
109 The following grammar is accepted by this method:
112 number_digit = '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'
114 number = number number_digit | number_digit
117 ternary_function = 'if'
119 string_reference = 'a-z,A-Z,0-9' ' '
120 modifier_reference = '$' '0-9' ' '
125 additive_expression equal_function additive_expression |
126 unary_function '(' number_digit ')'
127 ternary_function '(' additive_expression ',' additive_expression ',
128 ' additive_expression ')' | '(' additive_expression ')'
135 @throws ParseError if an invalid expression is given.
137 @return the generated function object.
140 static ExpressionNodeSharedPtr
parseFunction( const ::rtl::OUString
& _sFunction
);
143 // disabled constructor/destructor, since this is
144 // supposed to be a singleton
147 // default: disabled copy/assignment
148 FunctionParser(const FunctionParser
&);
149 FunctionParser
& operator=( const FunctionParser
& );
152 // -------------------------------------------------------------------------
153 } // namespace connectivity
154 // -------------------------------------------------------------------------
155 #endif /* CONNECTIVITY_ROWFUNCTIONPARSER_HXX_INCLUDED */