update dev300-m58
[ooovba.git] / connectivity / source / inc / RowFunctionParser.hxx
blobe966722a242d26d64534f00a938cbaee1ca7f346
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: RowFunctionParser.hxx,v $
10 * $Revision: 1.3 $
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>
37 #endif
38 #include "FDatabaseMetaDataResultSet.hxx"
39 #include <vector>
40 #include "connectivity/dbtoolsdllapi.hxx"
42 // -------------------------------------------------------------------------
43 namespace connectivity
45 // -------------------------------------------------------------------------
46 struct OOO_DLLPUBLIC_DBTOOLS RowEquation
48 sal_Int32 nOperation;
49 ORowSetValueDecoratorRef nPara[ 3 ];
51 RowEquation() :
52 nOperation ( 0 )
57 enum ExpressionFunct
59 FUNC_CONST,
61 ENUM_FUNC_EQUATION,
63 UNARY_FUNC_COLUMN,
64 ENUM_FUNC_AND,
65 ENUM_FUNC_OR
68 #define EXPRESSION_FLAG_SUMANGLE_MODE 1
70 class OOO_DLLPUBLIC_DBTOOLS SAL_NO_VTABLE ExpressionNode
72 public:
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
99 ParseError() {}
100 ParseError( const char* ) {}
103 class OOO_DLLPUBLIC_DBTOOLS FunctionParser
105 public:
107 /** Parse a string
109 The following grammar is accepted by this method:
110 <code>
112 number_digit = '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'
114 number = number number_digit | number_digit
116 equal_function = '='
117 ternary_function = 'if'
119 string_reference = 'a-z,A-Z,0-9' ' '
120 modifier_reference = '$' '0-9' ' '
122 basic_expression =
123 number |
124 string_reference |
125 additive_expression equal_function additive_expression |
126 unary_function '(' number_digit ')'
127 ternary_function '(' additive_expression ',' additive_expression ',
128 ' additive_expression ')' | '(' additive_expression ')'
130 </code>
132 @param rFunction
133 The string to parse
135 @throws ParseError if an invalid expression is given.
137 @return the generated function object.
140 static ExpressionNodeSharedPtr parseFunction( const ::rtl::OUString& _sFunction);
142 private:
143 // disabled constructor/destructor, since this is
144 // supposed to be a singleton
145 FunctionParser();
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 */