LCOV - code coverage report
Current view: top level - dbaccess/source/core/inc - composertools.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 34 0.0 %
Date: 2014-04-14 Functions: 0 23 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 INCLUDED_DBACCESS_SOURCE_CORE_INC_COMPOSERTOOLS_HXX
      21             : #define INCLUDED_DBACCESS_SOURCE_CORE_INC_COMPOSERTOOLS_HXX
      22             : 
      23             : #include <rtl/ustrbuf.hxx>
      24             : 
      25             : #include <functional>
      26             : 
      27             : namespace dbaccess
      28             : {
      29             : 
      30             :     // TokenComposer
      31           0 :     struct TokenComposer : public ::std::unary_function< OUString, void >
      32             :     {
      33             :     private:
      34             :         #ifdef DBG_UTIL
      35             :         bool                    m_bUsed;
      36             :         #endif
      37             : 
      38             :     protected:
      39             :         OUStringBuffer   m_aBuffer;
      40             : 
      41             :     public:
      42           0 :         OUString getComposedAndClear()
      43             :         {
      44             :             #ifdef DBG_UTIL
      45             :             m_bUsed = true;
      46             :             #endif
      47           0 :             return m_aBuffer.makeStringAndClear();
      48             :         }
      49             : 
      50           0 :         void clear()
      51             :         {
      52             :             #ifdef DBG_UTIL
      53             :             m_bUsed = false;
      54             :             #endif
      55           0 :             m_aBuffer.makeStringAndClear();
      56           0 :         }
      57             : 
      58             :     public:
      59           0 :         TokenComposer()
      60             :         #ifdef DBG_UTIL
      61             :             :m_bUsed( false )
      62             :         #endif
      63           0 :         {
      64           0 :         }
      65             : 
      66           0 :         virtual ~TokenComposer()
      67           0 :         {
      68           0 :         }
      69             : 
      70           0 :         void operator() (const OUString& lhs)
      71             :         {
      72           0 :             append(lhs);
      73           0 :         }
      74             : 
      75           0 :         void append( const OUString& lhs )
      76             :         {
      77             :             #ifdef DBG_UTIL
      78             :             OSL_ENSURE( !m_bUsed, "FilterCreator::append: already used up!" );
      79             :             #endif
      80           0 :             if ( !lhs.isEmpty() )
      81             :             {
      82           0 :                 if ( !m_aBuffer.isEmpty() )
      83           0 :                     appendNonEmptyToNonEmpty( lhs );
      84             :                 else
      85           0 :                     m_aBuffer.append( lhs );
      86             :             }
      87           0 :         }
      88             : 
      89             :         /// append the given part. Only to be called when both the part and our buffer so far are not empty
      90             :         virtual void appendNonEmptyToNonEmpty( const OUString& lhs ) = 0;
      91             :     };
      92             : 
      93             :     // FilterCreator
      94           0 :     struct FilterCreator : public TokenComposer
      95             :     {
      96           0 :         virtual void appendNonEmptyToNonEmpty( const OUString& lhs ) SAL_OVERRIDE
      97             :         {
      98           0 :             m_aBuffer.insert( 0, (sal_Unicode)' ' );
      99           0 :             m_aBuffer.insert( 0, (sal_Unicode)'(' );
     100           0 :             m_aBuffer.appendAscii( " ) AND ( " );
     101           0 :             m_aBuffer.append( lhs );
     102           0 :             m_aBuffer.appendAscii( " )" );
     103           0 :         }
     104             :     };
     105             : 
     106             :     // FilterCreator
     107           0 :     struct OrderCreator : public TokenComposer
     108             :     {
     109           0 :         virtual void appendNonEmptyToNonEmpty( const OUString& lhs ) SAL_OVERRIDE
     110             :         {
     111           0 :             m_aBuffer.appendAscii( ", " );
     112           0 :             m_aBuffer.append( lhs );
     113           0 :         }
     114             :     };
     115             : 
     116             : } // namespace dbaccess
     117             : 
     118             : #endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_COMPOSERTOOLS_HXX
     119             : 
     120             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10