LCOV - code coverage report
Current view: top level - connectivity/source/drivers/postgresql - pq_tools.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 4 0.0 %
Date: 2012-08-25 Functions: 0 3 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  *  Effective License of whole file:
       5                 :            :  *
       6                 :            :  *    This library is free software; you can redistribute it and/or
       7                 :            :  *    modify it under the terms of the GNU Lesser General Public
       8                 :            :  *    License version 2.1, as published by the Free Software Foundation.
       9                 :            :  *
      10                 :            :  *    This library is distributed in the hope that it will be useful,
      11                 :            :  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
      12                 :            :  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13                 :            :  *    Lesser General Public License for more details.
      14                 :            :  *
      15                 :            :  *    You should have received a copy of the GNU Lesser General Public
      16                 :            :  *    License along with this library; if not, write to the Free Software
      17                 :            :  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      18                 :            :  *    MA  02111-1307  USA
      19                 :            :  *
      20                 :            :  *  Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
      21                 :            :  *
      22                 :            :  *    The Contents of this file are made available subject to the terms of
      23                 :            :  *    the GNU Lesser General Public License Version 2.1
      24                 :            :  *
      25                 :            :  *    Copyright: 2000 by Sun Microsystems, Inc.
      26                 :            :  *
      27                 :            :  *    Contributor(s): Joerg Budischewski
      28                 :            :  *
      29                 :            :  *  All parts contributed on or after August 2011:
      30                 :            :  *
      31                 :            :  *    Version: MPL 1.1 / GPLv3+ / LGPLv2.1+
      32                 :            :  *
      33                 :            :  *    The contents of this file are subject to the Mozilla Public License Version
      34                 :            :  *    1.1 (the "License"); you may not use this file except in compliance with
      35                 :            :  *    the License or as specified alternatively below. You may obtain a copy of
      36                 :            :  *    the License at http://www.mozilla.org/MPL/
      37                 :            :  *
      38                 :            :  *    Software distributed under the License is distributed on an "AS IS" basis,
      39                 :            :  *    WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      40                 :            :  *    for the specific language governing rights and limitations under the
      41                 :            :  *    License.
      42                 :            :  *
      43                 :            :  *    Major Contributor(s):
      44                 :            :  *    [ Copyright (C) 2011 Lionel Elie Mamane <lionel@mamane.lu> ]
      45                 :            :  *
      46                 :            :  *    All Rights Reserved.
      47                 :            :  *
      48                 :            :  *    For minor contributions see the git repository.
      49                 :            :  *
      50                 :            :  *    Alternatively, the contents of this file may be used under the terms of
      51                 :            :  *    either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      52                 :            :  *    the GNU Lesser General Public License Version 2.1 or later (the "LGPLv2.1+"),
      53                 :            :  *    in which case the provisions of the GPLv3+ or the LGPLv2.1+ are applicable
      54                 :            :  *    instead of those above.
      55                 :            :  *
      56                 :            :  ************************************************************************/
      57                 :            : 
      58                 :            : #ifndef _PQ_TOOLS_
      59                 :            : #define _PQ_TOOLS_
      60                 :            : 
      61                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      62                 :            : #include <com/sun/star/sdbc/XParameters.hpp>
      63                 :            : #include <com/sun/star/util/Date.hpp>
      64                 :            : #include <com/sun/star/util/Time.hpp>
      65                 :            : #include <com/sun/star/util/DateTime.hpp>
      66                 :            : 
      67                 :            : #include <rtl/ustrbuf.hxx>
      68                 :            : #include <rtl/string.hxx>
      69                 :            : 
      70                 :            : #include <pq_connection.hxx>
      71                 :            : namespace pq_sdbc_driver
      72                 :            : {
      73                 :            : bool isWhitespace( sal_Unicode c );
      74                 :            : 
      75                 :            : rtl::OUString date2String( const com::sun::star::util::Date & date );
      76                 :            : com::sun::star::util::Date string2Date( const rtl::OUString & str );
      77                 :            : 
      78                 :            : rtl::OUString time2String( const com::sun::star::util::Time & time );
      79                 :            : com::sun::star::util::Time string2Time( const rtl::OUString & str );
      80                 :            : 
      81                 :            : rtl::OUString dateTime2String( const com::sun::star::util::DateTime & dateTime );
      82                 :            : com::sun::star::util::DateTime string2DateTime( const rtl::OUString & dateTime );
      83                 :            : 
      84                 :            : rtl::OUString concatQualified( const rtl::OUString & a, const rtl::OUString &b);
      85                 :            : 
      86                 :            : rtl::OString OUStringToOString( rtl::OUString str, ConnectionSettings *settings);
      87                 :            : 
      88                 :            : void bufferQuoteConstant( rtl::OUStringBuffer & buf, const rtl::OUString & str, ConnectionSettings *settings );
      89                 :            : void bufferQuoteAnyConstant( rtl::OUStringBuffer & buf, const com::sun::star::uno::Any &val, ConnectionSettings *settings );
      90                 :            : 
      91                 :            : void bufferEscapeConstant( rtl::OUStringBuffer & buf, const rtl::OUString & str, ConnectionSettings *settings );
      92                 :            : 
      93                 :            : ::rtl::OUString sqltype2string(
      94                 :            :     const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > & column );
      95                 :            : 
      96                 :            : 
      97                 :            : void bufferQuoteQualifiedIdentifier(
      98                 :            :     rtl::OUStringBuffer & buf, const rtl::OUString &schema, const rtl::OUString &name, ConnectionSettings *settings );
      99                 :            : 
     100                 :            : void bufferQuoteQualifiedIdentifier(
     101                 :            :     rtl::OUStringBuffer & buf,
     102                 :            :     const rtl::OUString &schema,
     103                 :            :     const rtl::OUString &name,
     104                 :            :     const rtl::OUString &col,
     105                 :            :     ConnectionSettings *settings );
     106                 :            : 
     107                 :            : void bufferQuoteIdentifier( rtl::OUStringBuffer & buf, const rtl::OUString &toQuote, ConnectionSettings *settings );
     108                 :            : void bufferKey2TableConstraint(
     109                 :            :     rtl::OUStringBuffer &buf,
     110                 :            :     const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > &key,
     111                 :            :     ConnectionSettings *settings  );
     112                 :            : 
     113                 :            : rtl::OUString extractStringProperty(
     114                 :            :     const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > & descriptor,
     115                 :            :     const rtl::OUString &name );
     116                 :            : 
     117                 :            : sal_Int32 extractIntProperty(
     118                 :            :     const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > & descriptor,
     119                 :            :     const rtl::OUString &name );
     120                 :            : 
     121                 :            : sal_Bool extractBoolProperty(
     122                 :            :     const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > & descriptor,
     123                 :            :     const rtl::OUString &name );
     124                 :            : 
     125                 :            : void disposeNoThrow( const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > & r );
     126                 :            : void disposeObject( const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > & r );
     127                 :            : 
     128                 :            : ::rtl::OUString extractTableFromInsert( const rtl::OUString & sql );
     129                 :            : ::rtl::OString extractSingleTableFromSelect( const OStringVector &vec );
     130                 :            : 
     131                 :            : void tokenizeSQL( const rtl::OString & sql, OStringVector &vec  );
     132                 :            : void splitSQL( const rtl::OString & sql, OStringVector &vec  );
     133                 :            : com::sun::star::uno::Sequence< sal_Int32 > parseIntArray( const ::rtl::OUString & str );
     134                 :            : com::sun::star::uno::Sequence< com::sun::star::uno::Any > parseArray( const ::rtl::OUString & str )
     135                 :            :     throw( com::sun::star::sdbc::SQLException );
     136                 :            : 
     137                 :            : rtl::OUString array2String( const com::sun::star::uno::Sequence< com::sun::star::uno::Any > &seq );
     138                 :            : 
     139                 :            : com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > extractConnectionFromStatement(
     140                 :            :     const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > & stmt );
     141                 :            : 
     142                 :            : void splitConcatenatedIdentifier( const rtl::OUString & source, rtl::OUString *first, rtl::OUString *second);
     143                 :            : 
     144                 :            : 
     145                 :            : void fillAttnum2attnameMap(
     146                 :            :     Int2StringMap &map,
     147                 :            :     const com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > &conn,
     148                 :            :     const rtl::OUString &schema,
     149                 :            :     const rtl::OUString &table );
     150                 :            : 
     151                 :            : com::sun::star::uno::Sequence< sal_Int32 > string2intarray( const ::rtl::OUString & str );
     152                 :            : 
     153                 :            : com::sun::star::uno::Sequence< rtl::OUString > convertMappedIntArray2StringArray(
     154                 :            :     const Int2StringMap &map, const com::sun::star::uno::Sequence< sal_Int32> &source );
     155                 :            : 
     156                 :            : typedef ::boost::unordered_map
     157                 :            : <
     158                 :            :     ::rtl::OString,
     159                 :            :     ::rtl::OString,
     160                 :            :     ::rtl::OStringHash,
     161                 :            :     ::std::equal_to< rtl::OString >,
     162                 :            :     Allocator< ::std::pair< rtl::OString, ::rtl::OString > >
     163                 :            : > String2StringMap;
     164                 :            : 
     165                 :            : rtl::OUString querySingleValue(
     166                 :            :     const com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > &connection,
     167                 :            :     const rtl::OUString &query );
     168                 :            : 
     169                 :            : void extractNameValuePairsFromInsert( String2StringMap & map, const rtl::OString & lastQuery );
     170                 :            : sal_Int32 typeNameToDataType( const rtl::OUString &typeName, const rtl::OUString &typtype );
     171                 :            : 
     172                 :            : // copied from connectivity/source/dbtools, can't use the function directly
     173                 :            : bool implSetObject(     const com::sun::star::uno::Reference< com::sun::star::sdbc::XParameters >& _rxParameters,
     174                 :            :                     const sal_Int32 _nColumnIndex, const com::sun::star::uno::Any& _rValue);
     175                 :            : 
     176                 :            : class DisposeGuard
     177                 :            : {
     178                 :            :     com::sun::star::uno::Reference< com::sun::star::uno::XInterface > d;
     179                 :            : public:
     180                 :            :     DisposeGuard(const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > & r );
     181                 :            :     ~DisposeGuard();
     182                 :            : 
     183                 :            : };
     184                 :            : 
     185                 :            : class TransactionGuard
     186                 :            : {
     187                 :            :     com::sun::star::uno::Reference< com::sun::star::sdbc::XStatement > m_stmt;
     188                 :            :     sal_Bool m_commited;
     189                 :            : public:
     190                 :            :     /// takes over ownership of given statemet
     191                 :            :     TransactionGuard( const com::sun::star::uno::Reference< com::sun::star::sdbc::XStatement > &stmt );
     192                 :            :     ~TransactionGuard( );
     193                 :            : 
     194                 :            :     void commit();
     195                 :            :     void executeUpdate( const rtl::OUString & sql );
     196                 :            : };
     197                 :            : 
     198                 :          0 : template < typename T, typename Allocator > com::sun::star::uno::Sequence<T> sequence_of_vector ( const std::vector<T, Allocator> &vec )
     199                 :            : {
     200                 :          0 :     if ( vec.empty() )
     201                 :          0 :         return com::sun::star::uno::Sequence<T>();
     202                 :            :     else
     203                 :          0 :         return com::sun::star::uno::Sequence<T>( &vec[0], vec.size());
     204                 :            : }
     205                 :            : 
     206                 :            : }
     207                 :            : 
     208                 :            : #endif

Generated by: LCOV version 1.10