LCOV - code coverage report
Current view: top level - connectivity/source/drivers/mork - MQueryHelper.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 25 0.0 %
Date: 2014-04-14 Functions: 0 17 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_MORK_QUERYHELPER_HXX_
      21             : #define _CONNECTIVITY_MORK_QUERYHELPER_HXX_
      22             : 
      23             : #include <sal/types.h>
      24             : #include <rtl/ustring.hxx>
      25             : #include <osl/mutex.hxx>
      26             : #include <osl/conditn.hxx>
      27             : #include <osl/thread.hxx>
      28             : #include <connectivity/FValue.hxx>
      29             : 
      30             : #include <boost/unordered_map.hpp>
      31             : 
      32             : #include "MErrorResource.hxx"
      33             : 
      34             : namespace connectivity
      35             : {
      36             :     namespace mork
      37             :     {
      38             :         class OConnection;
      39             :         class MQueryHelper;
      40             :         class ErrorDescriptor;
      41             : 
      42             :         namespace MQueryOp {
      43             :              typedef enum {
      44             :                  Exists         = 0,
      45             :                  DoesNotExist   = 1,
      46             :                  Contains       = 2,
      47             :                  DoesNotContain = 3,
      48             :                  Is             = 4,
      49             :                  IsNot          = 5,
      50             :                  BeginsWith     = 6,
      51             :                  EndsWith       = 7,
      52             :                  RegExp         = 8
      53             :             } cond_type;
      54             :         }
      55             : 
      56             :         class MQueryExpressionBase {
      57             :         public:
      58             :             typedef enum {
      59             :                 Unknown,
      60             :                 StringExpr,
      61             :                 Expr
      62             :             } node_type;
      63             : 
      64             :         protected:
      65             :             node_type   m_eNodeType;
      66             : 
      67             :             MQueryExpressionBase() : m_eNodeType( Unknown ) {}
      68           0 :             MQueryExpressionBase( node_type _eNodeType ) : m_eNodeType( _eNodeType ) {}
      69             : 
      70             :         public:
      71             :             sal_Bool   isUnknown( ) const { return m_eNodeType == Unknown; }
      72           0 :             sal_Bool   isStringExpr( ) const { return m_eNodeType == StringExpr; }
      73           0 :             sal_Bool   isExpr( ) const { return m_eNodeType == Expr; }
      74             :         };
      75             : 
      76             :         class MQueryExpressionString : public MQueryExpressionBase {
      77             :         protected:
      78             :             OUString     m_aName;         // LHS
      79             :             MQueryOp::cond_type m_aBooleanCondition;
      80             :             OUString     m_aValue;        // RHS
      81             : 
      82             :         public:
      83             : 
      84           0 :             MQueryExpressionString( const OUString&     lhs,
      85             :                                     MQueryOp::cond_type cond,
      86             :                                     const OUString&     rhs )
      87             :                 : MQueryExpressionBase( MQueryExpressionBase::StringExpr )
      88             :                 , m_aName( lhs )
      89             :                 , m_aBooleanCondition( cond )
      90           0 :                 , m_aValue( rhs )
      91             :             {
      92           0 :             }
      93             : 
      94           0 :             MQueryExpressionString( const OUString&     lhs,
      95             :                                     MQueryOp::cond_type cond )
      96             :                 : MQueryExpressionBase( MQueryExpressionBase::StringExpr )
      97             :                 , m_aName( lhs )
      98             :                 , m_aBooleanCondition( cond )
      99           0 :                 , m_aValue( OUString() )
     100             :             {
     101           0 :             }
     102             : 
     103           0 :             const OUString&    getName() const { return m_aName; }
     104           0 :             MQueryOp::cond_type getCond() const { return m_aBooleanCondition; }
     105           0 :             const OUString&    getValue() const { return m_aValue; }
     106             :         };
     107             : 
     108           0 :         class MQueryExpression : public MQueryExpressionBase
     109             :         {
     110             :             friend class MQueryHelper;
     111             : 
     112             :         public:
     113             :             typedef ::std::vector< MQueryExpressionBase* > ExprVector;
     114             : 
     115             :             typedef enum {
     116             :                 AND,
     117             :                 OR
     118             :             } bool_cond;
     119             : 
     120             :             void setExpressions( ExprVector& _exprVector )
     121             :                             { m_aExprVector = _exprVector; }
     122             : 
     123             :             // All expressions on a peer level use same condition operator
     124           0 :             void setExpressionCondition( bool_cond _cond )
     125           0 :                             { m_aExprCondType = _cond; }
     126             : 
     127           0 :             ExprVector& getExpressions( )
     128           0 :                             { return m_aExprVector; }
     129             : 
     130             :             // All expressions on a peer level use same condition operator
     131           0 :             bool_cond getExpressionCondition( ) const
     132           0 :                             { return m_aExprCondType; }
     133             : 
     134           0 :             MQueryExpression() : MQueryExpressionBase( MQueryExpressionBase::Expr ),
     135           0 :                                  m_aExprCondType( OR )
     136           0 :                             { m_aExprVector.clear(); }
     137             : 
     138             : 
     139             :         protected:
     140             :             ExprVector          m_aExprVector;
     141             :             bool_cond           m_aExprCondType;
     142             : 
     143             :         };
     144             : 
     145             :         class MQueryHelperResultEntry
     146             :         {
     147             :         private:
     148             :             typedef ::boost::unordered_map< OString, OUString, OStringHash >  FieldMap;
     149             : 
     150             :             mutable ::osl::Mutex    m_aMutex;
     151             :             FieldMap                m_Fields;
     152             : 
     153             :         public:
     154             :             MQueryHelperResultEntry();
     155             :             ~MQueryHelperResultEntry();
     156             : 
     157             :             OUString   getValue( const OString &key ) const;
     158             :             void            setValue( const OString &key, const OUString & rValue);
     159             :         };
     160             : 
     161             :         class MQueryHelper
     162             :         {
     163             :         private:
     164             :             typedef std::vector< MQueryHelperResultEntry* > resultsArray;
     165             : 
     166             :             mutable ::osl::Mutex        m_aMutex;
     167             :             ::osl::Condition    m_aCondition;
     168             :             resultsArray        m_aResults;
     169             :             sal_uInt32          m_nIndex;
     170             :             sal_Bool            m_bHasMore;
     171             :             sal_Bool            m_bAtEnd;
     172             :             void            append(MQueryHelperResultEntry* resEnt );
     173             :             void            clear_results();
     174             :             OColumnAlias        m_rColumnAlias;
     175             :             ErrorDescriptor     m_aError;
     176             :             OUString     m_aAddressbook;
     177             :             MQueryExpression    m_aExpr;
     178             : 
     179             : /*
     180             :             void            clearResultOrComplete();
     181             :             void            notifyResultOrComplete();
     182             :             sal_Bool        waitForResultOrComplete( );
     183             :             void            getCardValues(nsIAbCard  *card,sal_uInt32 rowIndex=0);
     184             : */
     185             : 
     186             :             sal_Int32 doQueryDefaultTable(OConnection* xConnection);
     187             :             sal_Int32 doQueryListTable(OConnection* xConnection, OString& ouStringTable);
     188             : 
     189             :         public:
     190             :                                        MQueryHelper(const OColumnAlias& _ca);
     191             :             virtual                    ~MQueryHelper();
     192             : 
     193             :             void                       reset();
     194             :             MQueryHelperResultEntry*   getByIndex( sal_uInt32 nRow );
     195             :             sal_Bool                   isError() const;
     196             :             sal_Bool                   queryComplete() const;
     197             :             sal_Int32                  getResultCount() const;
     198             :             sal_Bool                   checkRowAvailable( sal_Int32 nDBRow );
     199             :             sal_Bool getRowValue( ORowSetValue& rValue, sal_Int32 nDBRow,const OUString& aDBColumnName, sal_Int32 nType );
     200             :             sal_Int32 executeQuery(OConnection* xConnection);
     201           0 :             const OColumnAlias&             getColumnAlias() const { return m_rColumnAlias; }
     202           0 :             bool                            hadError() const { return m_aError.is(); }
     203           0 :             inline ErrorDescriptor& getError() { return m_aError; }
     204             : 
     205             :             void                            setAddressbook( OUString&);
     206             :             void                            setExpression( MQueryExpression &_expr );
     207             : 
     208             :         };
     209             :     }
     210             : }
     211             : 
     212             : #endif // _CONNECTIVITY_MORK_QUERYHELPER_HXX_
     213             : 
     214             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10