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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <config_lgpl.h>
24 #include <com/sun/star/uno/XInterface.hpp>
25 #include <com/sun/star/sdbc/SQLException.hpp>
27 #include <osl/diagnose.h>
31 #pragma GCC diagnostic push
32 #pragma GCC diagnostic ignored "-Wdeprecated"
36 #pragma GCC diagnostic pop
39 namespace mysqlc_sdbc_driver
42 void resetSqlVar(void** target
, T
* pValue
, enum_field_types type
, sal_Int32 nSize
= 0)
49 constexpr auto nUnitSize
= sizeof(T
);
52 case MYSQL_TYPE_INT24
:
54 case MYSQL_TYPE_NEWDATE
:
56 case MYSQL_TYPE_GEOMETRY
:
58 case MYSQL_TYPE_SHORT
:
60 case MYSQL_TYPE_LONGLONG
:
61 case MYSQL_TYPE_FLOAT
:
62 case MYSQL_TYPE_DOUBLE
:
65 case MYSQL_TYPE_DATETIME
:
66 case MYSQL_TYPE_TIMESTAMP
:
67 *target
= malloc(nUnitSize
);
68 memcpy(*target
, pValue
, nUnitSize
);
70 case MYSQL_TYPE_STRING
:
72 case MYSQL_TYPE_DECIMAL
:
73 case MYSQL_TYPE_VARCHAR
:
74 case MYSQL_TYPE_NEWDECIMAL
:
77 case MYSQL_TYPE_VAR_STRING
:
78 case MYSQL_TYPE_TINY_BLOB
:
79 case MYSQL_TYPE_MEDIUM_BLOB
:
80 case MYSQL_TYPE_LONG_BLOB
:
81 *target
= malloc(nUnitSize
* nSize
);
82 memcpy(*target
, pValue
, nUnitSize
* nSize
);
88 OSL_FAIL("resetSqlVar: unknown enum_field_type");
92 void allocateSqlVar(void** mem
, enum_field_types eType
, unsigned nSize
= 0);
94 void throwFeatureNotImplementedException(
95 const char* _pAsciiFeatureName
, const css::uno::Reference
<css::uno::XInterface
>& _rxContext
);
97 void throwInvalidArgumentException(const char* _pAsciiFeatureName
,
98 const css::uno::Reference
<css::uno::XInterface
>& _rxContext
);
100 void throwSQLExceptionWithMsg(const char* msg
, const char* SQLSTATE
, unsigned int errorNum
,
101 const css::uno::Reference
<css::uno::XInterface
>& _context
,
102 const rtl_TextEncoding encoding
);
104 void throwSQLExceptionWithMsg(const OUString
& msg
, const char* SQLSTATE
, unsigned int errorNum
,
105 const css::uno::Reference
<css::uno::XInterface
>& _context
);
107 sal_Int32
mysqlToOOOType(int eType
, int charsetnr
) noexcept
;
109 OUString
mysqlTypeToStr(unsigned mysql_type
, unsigned mysql_flags
);
111 sal_Int32
mysqlStrToOOOType(const OUString
& sType
);
113 OUString
convert(const ::std::string
& _string
, const rtl_TextEncoding encoding
);
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */