1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
10 #ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_FIREBIRD_UTIL_HXX
11 #define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_FIREBIRD_UTIL_HXX
15 #include <rtl/ustring.hxx>
16 #include <rtl/ustrbuf.hxx>
18 #include <com/sun/star/sdbc/DataType.hpp>
19 #include <com/sun/star/sdbc/SQLException.hpp>
23 namespace connectivity
27 typedef ::std::vector
< OString
> OStringVector
;
28 // Type Blob has 2 subtypes values
29 // 0 for BLOB, 1 for CLOB
30 // see http://www.firebirdfaq.org/faq48/
31 enum class BlobSubtype
{
37 * Make sure an identifier is safe to use within the databse. Currently
38 * firebird seems to return identifiers with 93 character (instead of
39 * 31), whereby the name is simply padded with trailing whitespace.
40 * This removes all trailing whitespace (i.e. if necessary so that
41 * the length is below 31 characters). Firebird automatically compensates
42 * for such shorter strings, however any trailing padding makes the gui
43 * editing of such names harder, hence we remove all trailing whitespace.
45 OUString
sanitizeIdentifier(const OUString
& rIdentifier
);
47 inline bool IndicatesError(const ISC_STATUS_ARRAY
& rStatusVector
)
49 return rStatusVector
[0]==1 && rStatusVector
[1]; // indicates error;
52 OUString
StatusVectorToString(const ISC_STATUS_ARRAY
& rStatusVector
,
53 const OUString
& rCause
);
56 * Evaluate a firebird status vector and throw exceptions as necessary.
57 * The content of the status vector is included in the thrown exception.
59 void evaluateStatusVector(const ISC_STATUS_ARRAY
& rStatusVector
,
60 const ::rtl::OUString
& aCause
,
61 const css::uno::Reference
< css::uno::XInterface
>& _rxContext
)
62 throw (css::sdbc::SQLException
);
64 sal_Int32
getColumnTypeFromFBType(short aType
, short aSubType
);
65 ::rtl::OUString
getColumnTypeNameFromFBType(short aType
, short aSubType
);
68 * Internally (i.e. in RDB$FIELD_TYPE) firebird stores the data type
69 * for a column as defined in blr_*, however in the firebird
70 * api the SQL_* types are used, hence we need to be able to convert
71 * between the two when retrieving column metadata.
73 short getFBTypeFromBlrType(short blrType
);
75 void mallocSQLVAR(XSQLDA
* pSqlda
);
77 void freeSQLVAR(XSQLDA
* pSqlda
);
79 OUString
escapeWith( const OUString
& sText
, const char aKey
, const char aEscapeChar
);
80 sal_Int64
pow10Integer( int nDecimalCount
);
83 #endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_FIREBIRD_UTIL_HXX
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */