bump product version to 6.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / postgresql / pq_tools.hxx
blob9d4e2349fcfbb3fd09e4a3f0b6281a96b679bb75
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * Effective License of whole file:
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.
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.
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
20 * Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
22 * The Contents of this file are made available subject to the terms of
23 * the GNU Lesser General Public License Version 2.1
25 * Copyright: 2000 by Sun Microsystems, Inc.
27 * Contributor(s): Joerg Budischewski
29 * All parts contributed on or after August 2011:
31 * This Source Code Form is subject to the terms of the Mozilla Public
32 * License, v. 2.0. If a copy of the MPL was not distributed with this
33 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
35 ************************************************************************/
37 #ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_POSTGRESQL_PQ_TOOLS_HXX
38 #define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_POSTGRESQL_PQ_TOOLS_HXX
40 #include <com/sun/star/beans/XPropertySet.hpp>
41 #include <com/sun/star/sdbc/XParameters.hpp>
42 #include <com/sun/star/util/Date.hpp>
43 #include <com/sun/star/util/Time.hpp>
44 #include <com/sun/star/util/DateTime.hpp>
46 #include <rtl/ustrbuf.hxx>
47 #include <rtl/string.hxx>
49 #include "pq_connection.hxx"
50 #include <vector>
52 namespace pq_sdbc_driver
54 bool isWhitespace( sal_Unicode c );
56 OUString concatQualified( const OUString & a, const OUString &b);
58 OString OUStringToOString( const OUString& str, ConnectionSettings const *settings);
60 void bufferQuoteConstant( OUStringBuffer & buf, const OUString & str, ConnectionSettings *settings );
61 void bufferQuoteAnyConstant( OUStringBuffer & buf, const css::uno::Any &val, ConnectionSettings *settings );
63 void bufferEscapeConstant( OUStringBuffer & buf, const OUString & str, ConnectionSettings *settings );
65 OUString sqltype2string(
66 const css::uno::Reference< css::beans::XPropertySet > & column );
69 void bufferQuoteQualifiedIdentifier(
70 OUStringBuffer & buf, const OUString &schema, const OUString &name, ConnectionSettings *settings );
72 void bufferQuoteQualifiedIdentifier(
73 OUStringBuffer & buf,
74 const OUString &schema,
75 const OUString &name,
76 const OUString &col,
77 ConnectionSettings *settings );
79 void bufferQuoteIdentifier( OUStringBuffer & buf, const OUString &toQuote, ConnectionSettings *settings );
80 void bufferKey2TableConstraint(
81 OUStringBuffer &buf,
82 const css::uno::Reference< css::beans::XPropertySet > &key,
83 ConnectionSettings *settings );
85 OUString extractStringProperty(
86 const css::uno::Reference< css::beans::XPropertySet > & descriptor,
87 const OUString &name );
89 sal_Int32 extractIntProperty(
90 const css::uno::Reference< css::beans::XPropertySet > & descriptor,
91 const OUString &name );
93 bool extractBoolProperty(
94 const css::uno::Reference< css::beans::XPropertySet > & descriptor,
95 const OUString &name );
97 void disposeNoThrow( const css::uno::Reference< css::uno::XInterface > & r );
98 void disposeObject( const css::uno::Reference< css::uno::XInterface > & r );
100 OUString extractTableFromInsert( const OUString & sql );
101 OString extractSingleTableFromSelect( const std::vector< OString > &vec );
103 void tokenizeSQL( const OString & sql, std::vector< OString > &vec );
104 void splitSQL( const OString & sql, std::vector< OString > &vec );
105 std::vector< sal_Int32 > parseIntArray( const OUString & str );
106 /// @throws css::sdbc::SQLException
107 std::vector< css::uno::Any > parseArray( const OUString & str );
109 OUString array2String( const css::uno::Sequence< css::uno::Any > &seq );
111 css::uno::Reference< css::sdbc::XConnection > extractConnectionFromStatement(
112 const css::uno::Reference< css::uno::XInterface > & stmt );
114 void splitConcatenatedIdentifier( const OUString & source, OUString *first, OUString *second);
117 void fillAttnum2attnameMap(
118 Int2StringMap &map,
119 const css::uno::Reference< css::sdbc::XConnection > &conn,
120 const OUString &schema,
121 const OUString &table );
123 css::uno::Sequence< sal_Int32 > string2intarray( const OUString & str );
125 css::uno::Sequence< OUString > convertMappedIntArray2StringArray(
126 const Int2StringMap &map, const css::uno::Sequence< sal_Int32> &source );
128 typedef std::unordered_map< OString, OString > String2StringMap;
130 OUString querySingleValue(
131 const css::uno::Reference< css::sdbc::XConnection > &connection,
132 const OUString &query );
134 void extractNameValuePairsFromInsert( String2StringMap & map, const OString & lastQuery );
135 sal_Int32 typeNameToDataType( const OUString &typeName, const OUString &typtype );
137 // copied from connectivity/source/dbtools, can't use the function directly
138 bool implSetObject( const css::uno::Reference< css::sdbc::XParameters >& _rxParameters,
139 const sal_Int32 _nColumnIndex, const css::uno::Any& _rValue);
141 class DisposeGuard
143 css::uno::Reference< css::uno::XInterface > d;
144 public:
145 explicit DisposeGuard(const css::uno::Reference< css::uno::XInterface > & r );
146 ~DisposeGuard();
150 class TransactionGuard
152 css::uno::Reference< css::sdbc::XStatement > m_stmt;
153 bool m_commited;
154 public:
155 /// takes over ownership of given statement
156 explicit TransactionGuard( const css::uno::Reference< css::sdbc::XStatement > &stmt );
157 ~TransactionGuard( );
159 void commit();
160 void executeUpdate( const OUString & sql );
165 #endif
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */