LibreOffice Module connectivity (master) 1
Util.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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
10#pragma once
11
12#include <ibase.h>
13
14#include <rtl/ustring.hxx>
15
16#include <com/sun/star/uno/XInterface.hpp>
17#include <utility>
18
20 {
21 // Type Blob has 2 subtypes values
22 // 0 for BLOB, 1 for CLOB
23 // see http://www.firebirdfaq.org/faq48/
24 // User-defined subtypes are negative.
25 // Use a number for image which is very unlikely to be defined by a
26 // user.
27 enum class BlobSubtype {
28 Blob = 0,
29 Clob = 1,
30 Image = -9546
31 };
32
37 enum class NumberSubType {
38 Other = 0,
39 Numeric = 1,
40 Decimal = 2
41 };
42
44private:
45 short m_aType;
47 short m_nScale;
49public:
60 explicit ColumnTypeInfo( short aType, short aSubType = 0,
61 short nScale = 0, OUString sCharset = OUString() )
62 : m_aType(aType)
63 , m_aSubType(aSubType)
64 , m_nScale(nScale)
65 , m_sCharsetName(std::move(sCharset)) {}
66 explicit ColumnTypeInfo( short aType, OUString sCharset )
67 : m_aType(aType)
68 , m_aSubType(0)
69 , m_nScale(0)
70 , m_sCharsetName(std::move(sCharset)) {}
71 short getType() const { return m_aType; }
72 short getSubType() const { return m_aSubType; }
73 short getScale() const { return m_nScale; }
74 OUString const & getCharacterSet() const { return m_sCharsetName; }
75
76 sal_Int32 getSdbcType() const;
77 OUString getColumnTypeName() const;
78
79 };
80
90 OUString sanitizeIdentifier(std::u16string_view rIdentifier);
91
92 inline bool IndicatesError(const ISC_STATUS_ARRAY& rStatusVector)
93 {
94 return rStatusVector[0]==1 && rStatusVector[1]; // indicates error;
95 }
96
97 OUString StatusVectorToString(const ISC_STATUS_ARRAY& rStatusVector,
98 std::u16string_view rCause);
99
106 void evaluateStatusVector(const ISC_STATUS_ARRAY& rStatusVector,
107 std::u16string_view aCause,
108 const css::uno::Reference< css::uno::XInterface >& _rxContext);
109
116 short getFBTypeFromBlrType(short blrType);
117
118 void mallocSQLVAR(XSQLDA* pSqlda);
119
120 void freeSQLVAR(XSQLDA* pSqlda);
121
122 sal_Int64 pow10Integer( int nDecimalCount );
123
124}
125
126/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
OUString getColumnTypeName() const
Definition: Util.cxx:183
OUString const & getCharacterSet() const
Definition: Util.hxx:74
ColumnTypeInfo(short aType, short aSubType=0, short nScale=0, OUString sCharset=OUString())
Definition: Util.hxx:60
ColumnTypeInfo(short aType, OUString sCharset)
Definition: Util.hxx:66
NumberSubType
Numeric and decimal types can be identified by their subtype in Firebird API.
Definition: Util.hxx:37
void freeSQLVAR(XSQLDA *pSqlda)
bool IndicatesError(const ISC_STATUS_ARRAY &rStatusVector)
Definition: Util.hxx:92
short getFBTypeFromBlrType(short blrType)
Internally (i.e.
OUString sanitizeIdentifier(std::u16string_view rIdentifier)
Make sure an identifier is safe to use within the database.
OUString StatusVectorToString(const ISC_STATUS_ARRAY &rStatusVector, std::u16string_view rCause)
sal_Int64 pow10Integer(int nDecimalCount)
void evaluateStatusVector(const ISC_STATUS_ARRAY &rStatusVector, std::u16string_view aCause, const css::uno::Reference< css::uno::XInterface > &_rxContext)
Evaluate a firebird status vector and throw exceptions as necessary.
void mallocSQLVAR(XSQLDA *pSqlda)