LCOV - code coverage report
Current view: top level - connectivity/source/inc - RowFunctionParser.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 3 0.0 %
Date: 2014-04-14 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #ifndef CONNECTIVITY_ROWFUNCTIONPARSER_HXX_INCLUDED
      21             : #define CONNECTIVITY_ROWFUNCTIONPARSER_HXX_INCLUDED
      22             : 
      23             : #include <sal/config.h>
      24             : #include <boost/shared_ptr.hpp>
      25             : #include "FDatabaseMetaDataResultSet.hxx"
      26             : #include <vector>
      27             : #include "connectivity/dbtoolsdllapi.hxx"
      28             : 
      29             : 
      30             : namespace connectivity
      31             : {
      32             : 
      33             : struct OOO_DLLPUBLIC_DBTOOLS RowEquation
      34             : {
      35             :     sal_Int32   nOperation;
      36             :     ORowSetValueDecoratorRef    nPara[ 3 ];
      37             : 
      38             :     RowEquation() :
      39             :         nOperation  ( 0 )
      40             :         {
      41             :         }
      42             : };
      43             : 
      44             : enum ExpressionFunct
      45             : {
      46             :     FUNC_CONST,
      47             : 
      48             :     ENUM_FUNC_EQUATION,
      49             : 
      50             :     UNARY_FUNC_COLUMN,
      51             :     ENUM_FUNC_AND,
      52             :     ENUM_FUNC_OR
      53             : };
      54             : 
      55             : #define EXPRESSION_FLAG_SUMANGLE_MODE 1
      56             : 
      57           0 : class OOO_DLLPUBLIC_DBTOOLS SAL_NO_VTABLE ExpressionNode
      58             : {
      59             : public:
      60           0 :     virtual ~ExpressionNode(){}
      61             : 
      62             :     /** Operator to calculate function value.
      63             : 
      64             :         This method calculates the function value.
      65             :     */
      66             :     virtual ORowSetValueDecoratorRef evaluate(const ODatabaseMetaDataResultSet::ORow& _aRow ) const = 0;
      67             : 
      68             :     virtual void fill(const ODatabaseMetaDataResultSet::ORow& _aRow ) const = 0;
      69             : 
      70             :     /** Operator to retrieve the type of expression node
      71             :     */
      72             :     virtual ExpressionFunct getType() const = 0;
      73             : 
      74             :     /** Operator to retrieve the ms version of expression
      75             :     */
      76             :     virtual ODatabaseMetaDataResultSet::ORow fillNode(
      77             :         std::vector< RowEquation >& rEquations, ExpressionNode* pOptionalArg, sal_uInt32 nFlags ) = 0;
      78             : };
      79             : typedef ::boost::shared_ptr< ExpressionNode > ExpressionNodeSharedPtr;
      80             : 
      81             : /** This exception is thrown, when the arithmetic expression
      82             :     parser failed to parse a string.
      83             :     */
      84             : struct OOO_DLLPUBLIC_DBTOOLS ParseError
      85             : {
      86             :     ParseError() {}
      87           0 :     ParseError( const char* ) {}
      88             : };
      89             : 
      90             : class OOO_DLLPUBLIC_DBTOOLS FunctionParser
      91             : {
      92             : public:
      93             : 
      94             :     /** Parse a string
      95             : 
      96             :         The following grammar is accepted by this method:
      97             :         <code>
      98             : 
      99             :         number_digit = '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'
     100             : 
     101             :         number = number number_digit | number_digit
     102             : 
     103             :         equal_function = '='
     104             :         ternary_function = 'if'
     105             : 
     106             :         string_reference = 'a-z,A-Z,0-9' ' '
     107             :         modifier_reference = '$' '0-9' ' '
     108             : 
     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 ')'
     116             : 
     117             :         </code>
     118             : 
     119             :         @param rFunction
     120             :         The string to parse
     121             : 
     122             :         @throws ParseError if an invalid expression is given.
     123             : 
     124             :         @return the generated function object.
     125             :        */
     126             : 
     127             :     static ExpressionNodeSharedPtr parseFunction( const OUString& _sFunction);
     128             : 
     129             : private:
     130             :     // disabled constructor/destructor, since this is
     131             :     // supposed to be a singleton
     132             :     FunctionParser();
     133             : 
     134             :     // default: disabled copy/assignment
     135             :     FunctionParser(const FunctionParser&);
     136             :     FunctionParser& operator=( const FunctionParser& );
     137             : };
     138             : 
     139             : 
     140             : } // namespace connectivity
     141             : 
     142             : #endif /* CONNECTIVITY_ROWFUNCTIONPARSER_HXX_INCLUDED */
     143             : 
     144             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10