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"
36 #include "connectivity/dbtoolsdllapi.hxx"
38 // -------------------------------------------------------------------------
39 namespace connectivity
41 // -------------------------------------------------------------------------
42 struct OOO_DLLPUBLIC_DBTOOLS RowEquation
45 ORowSetValueDecoratorRef nPara
[ 3 ];
64 #define EXPRESSION_FLAG_SUMANGLE_MODE 1
66 class OOO_DLLPUBLIC_DBTOOLS SAL_NO_VTABLE ExpressionNode
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
96 ParseError( const char* ) {}
99 class OOO_DLLPUBLIC_DBTOOLS FunctionParser
105 The following grammar is accepted by this method:
108 number_digit = '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'
110 number = number number_digit | number_digit
113 ternary_function = 'if'
115 string_reference = 'a-z,A-Z,0-9' ' '
116 modifier_reference = '$' '0-9' ' '
121 additive_expression equal_function additive_expression |
122 unary_function '(' number_digit ')'
123 ternary_function '(' additive_expression ',' additive_expression ',
124 ' additive_expression ')' | '(' additive_expression ')'
131 @throws ParseError if an invalid expression is given.
133 @return the generated function object.
136 static ExpressionNodeSharedPtr
parseFunction( const ::rtl::OUString
& _sFunction
);
139 // disabled constructor/destructor, since this is
140 // supposed to be a singleton
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: */