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 .
20 #ifndef INCLUDED_MYSQLC_SOURCE_MYSQLC_GENERAL_HXX
21 #define INCLUDED_MYSQLC_SOURCE_MYSQLC_GENERAL_HXX
23 #include <config_lgpl.h>
25 #include <com/sun/star/uno/XInterface.hpp>
26 #include <com/sun/star/sdbc/SQLException.hpp>
28 #include <osl/diagnose.h>
32 #pragma GCC diagnostic push
33 #pragma GCC diagnostic ignored "-Wdeprecated"
37 #pragma GCC diagnostic pop
40 namespace mysqlc_sdbc_driver
43 void resetSqlVar(void** target
, T
* pValue
, enum_field_types type
, sal_Int32 nSize
= 0)
50 constexpr auto nUnitSize
= sizeof(T
);
53 case MYSQL_TYPE_INT24
:
55 case MYSQL_TYPE_NEWDATE
:
57 case MYSQL_TYPE_GEOMETRY
:
59 case MYSQL_TYPE_SHORT
:
61 case MYSQL_TYPE_LONGLONG
:
62 case MYSQL_TYPE_FLOAT
:
63 case MYSQL_TYPE_DOUBLE
:
66 case MYSQL_TYPE_DATETIME
:
67 case MYSQL_TYPE_TIMESTAMP
:
68 *target
= malloc(nUnitSize
);
69 memcpy(*target
, pValue
, nUnitSize
);
71 case MYSQL_TYPE_STRING
:
73 case MYSQL_TYPE_DECIMAL
:
74 case MYSQL_TYPE_VARCHAR
:
75 case MYSQL_TYPE_NEWDECIMAL
:
78 case MYSQL_TYPE_VAR_STRING
:
79 case MYSQL_TYPE_TINY_BLOB
:
80 case MYSQL_TYPE_MEDIUM_BLOB
:
81 case MYSQL_TYPE_LONG_BLOB
:
82 *target
= malloc(nUnitSize
* nSize
);
83 memcpy(*target
, pValue
, nUnitSize
* nSize
);
89 OSL_FAIL("resetSqlVar: unknown enum_field_type");
93 void allocateSqlVar(void** mem
, enum_field_types eType
, unsigned nSize
= 0);
95 void throwFeatureNotImplementedException(
96 const sal_Char
* _pAsciiFeatureName
,
97 const css::uno::Reference
<css::uno::XInterface
>& _rxContext
);
99 void throwInvalidArgumentException(const sal_Char
* _pAsciiFeatureName
,
100 const css::uno::Reference
<css::uno::XInterface
>& _rxContext
);
102 void throwSQLExceptionWithMsg(const char* msg
, unsigned int errorNum
,
103 const css::uno::Reference
<css::uno::XInterface
>& _context
,
104 const rtl_TextEncoding encoding
);
106 sal_Int32
mysqlToOOOType(int eType
, int charsetnr
) noexcept
;
108 OUString
mysqlTypeToStr(unsigned mysql_type
, unsigned mysql_flags
);
110 sal_Int32
mysqlStrToOOOType(const OUString
& sType
);
112 OUString
convert(const ::std::string
& _string
, const rtl_TextEncoding encoding
);
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */