bump product version to 6.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / mysqlc / mysqlc_general.hxx
blob38852d269ae618fa018d0ce0cecf3acdb2b754c0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
29 #include <mysql.h>
31 #if defined __GNUC__
32 #pragma GCC diagnostic push
33 #pragma GCC diagnostic ignored "-Wdeprecated"
34 #endif
36 #if defined __GNUC__
37 #pragma GCC diagnostic pop
38 #endif
40 namespace mysqlc_sdbc_driver
42 template <typename T>
43 void resetSqlVar(void** target, T* pValue, enum_field_types type, sal_Int32 nSize = 0)
45 if (*target)
47 free(*target);
48 *target = nullptr;
50 constexpr auto nUnitSize = sizeof(T);
51 switch (type)
53 case MYSQL_TYPE_INT24:
54 case MYSQL_TYPE_YEAR:
55 case MYSQL_TYPE_NEWDATE:
56 case MYSQL_TYPE_BIT:
57 case MYSQL_TYPE_GEOMETRY:
58 case MYSQL_TYPE_LONG:
59 case MYSQL_TYPE_SHORT:
60 case MYSQL_TYPE_TINY:
61 case MYSQL_TYPE_LONGLONG:
62 case MYSQL_TYPE_FLOAT:
63 case MYSQL_TYPE_DOUBLE:
64 case MYSQL_TYPE_TIME:
65 case MYSQL_TYPE_DATE:
66 case MYSQL_TYPE_DATETIME:
67 case MYSQL_TYPE_TIMESTAMP:
68 *target = malloc(nUnitSize);
69 memcpy(*target, pValue, nUnitSize);
70 break;
71 case MYSQL_TYPE_STRING:
72 case MYSQL_TYPE_BLOB:
73 case MYSQL_TYPE_DECIMAL:
74 case MYSQL_TYPE_VARCHAR:
75 case MYSQL_TYPE_NEWDECIMAL:
76 case MYSQL_TYPE_ENUM:
77 case MYSQL_TYPE_SET:
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);
84 break;
85 case MYSQL_TYPE_NULL:
86 // nothing I guess
87 break;
88 default:
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);
115 #endif
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */