sss
parent
46a6e1dce5
commit
f2764c656c
|
@ -1,27 +1,35 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
*
|
||||||
The MySQL Connector/C++ is licensed under the terms of the GPLv2
|
* This program is free software; you can redistribute it and/or modify
|
||||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
* it under the terms of the GNU General Public License, version 2.0, as
|
||||||
MySQL Connectors. There are special exceptions to the terms and
|
* published by the Free Software Foundation.
|
||||||
conditions of the GPLv2 as it is applied to this software, see the
|
*
|
||||||
FLOSS License Exception
|
* This program is also distributed with certain software (including
|
||||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
* but not limited to OpenSSL) that is licensed under separate terms,
|
||||||
|
* as designated in a particular file or component or in included license
|
||||||
This program is free software; you can redistribute it and/or modify
|
* documentation. The authors of MySQL hereby grant you an
|
||||||
it under the terms of the GNU General Public License as published
|
* additional permission to link the program and your derivative works
|
||||||
by the Free Software Foundation; version 2 of the License.
|
* with the separately licensed software that they have included with
|
||||||
|
* MySQL.
|
||||||
This program is distributed in the hope that it will be useful, but
|
*
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* Without limiting anything contained in the foregoing, this file,
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
* which is part of MySQL Connector/C++, is also subject to the
|
||||||
for more details.
|
* Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||||
|
* http://oss.oracle.com/licenses/universal-foss-exception.
|
||||||
You should have received a copy of the GNU General Public License along
|
*
|
||||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
* This program is distributed in the hope that it will be useful, but
|
||||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License, version 2.0, for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _SQL_BUILD_CONFIG_H_
|
#ifndef _SQL_BUILD_CONFIG_H_
|
||||||
#define _SQL_BUILD_CONFIG_H_
|
#define _SQL_BUILD_CONFIG_H_
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,31 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
*
|
||||||
The MySQL Connector/C++ is licensed under the terms of the GPL
|
* This program is free software; you can redistribute it and/or modify
|
||||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
* it under the terms of the GNU General Public License, version 2.0, as
|
||||||
MySQL Connectors. There are special exceptions to the terms and
|
* published by the Free Software Foundation.
|
||||||
conditions of the GPL as it is applied to this software, see the
|
*
|
||||||
FLOSS License Exception
|
* This program is also distributed with certain software (including
|
||||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
* but not limited to OpenSSL) that is licensed under separate terms,
|
||||||
|
* as designated in a particular file or component or in included license
|
||||||
|
* documentation. The authors of MySQL hereby grant you an
|
||||||
|
* additional permission to link the program and your derivative works
|
||||||
|
* with the separately licensed software that they have included with
|
||||||
|
* MySQL.
|
||||||
|
*
|
||||||
|
* Without limiting anything contained in the foregoing, this file,
|
||||||
|
* which is part of MySQL Connector/C++, is also subject to the
|
||||||
|
* Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||||
|
* http://oss.oracle.com/licenses/universal-foss-exception.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License, version 2.0, for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// libmysql defines HAVE_STRTOUL (on win), so we have to follow different pattern in definitions names
|
// libmysql defines HAVE_STRTOUL (on win), so we have to follow different pattern in definitions names
|
||||||
|
@ -35,27 +54,34 @@
|
||||||
#define HAVE_UINT32_T 1
|
#define HAVE_UINT32_T 1
|
||||||
#define HAVE_INT64_T 1
|
#define HAVE_INT64_T 1
|
||||||
#define HAVE_UINT64_T 1
|
#define HAVE_UINT64_T 1
|
||||||
/* #undef HAVE_MS_INT8 */
|
#define HAVE_MS_INT8 1
|
||||||
/* #undef HAVE_MS_UINT8 */
|
#define HAVE_MS_UINT8 1
|
||||||
/* #undef HAVE_MS_INT16 */
|
#define HAVE_MS_INT16 1
|
||||||
/* #undef HAVE_MS_UINT16 */
|
#define HAVE_MS_UINT16 1
|
||||||
/* #undef HAVE_MS_INT32 */
|
#define HAVE_MS_INT32 1
|
||||||
/* #undef HAVE_MS_UINT32 */
|
#define HAVE_MS_UINT32 1
|
||||||
/* #undef HAVE_MS_INT64 */
|
#define HAVE_MS_INT64 1
|
||||||
/* #undef HAVE_MS_UINT64 */
|
#define HAVE_MS_UINT64 1
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_STDINT_H
|
#ifdef HAVE_STDINT_H
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_INTTYPES_H
|
|
||||||
|
#if defined(HAVE_INTTYPES_H) && !defined(_WIN32)
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#ifndef CPPCONN_DONT_TYPEDEF_MS_TYPES_TO_C99_TYPES
|
#ifndef CPPCONN_DONT_TYPEDEF_MS_TYPES_TO_C99_TYPES
|
||||||
|
|
||||||
|
#if _MSC_VER >= 1600
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
#if !defined(HAVE_INT8_T) && defined(HAVE_MS_INT8)
|
#if !defined(HAVE_INT8_T) && defined(HAVE_MS_INT8)
|
||||||
typedef __int8 int8_t;
|
typedef __int8 int8_t;
|
||||||
#endif
|
#endif
|
||||||
|
@ -86,5 +112,6 @@ typedef __int64 int64_t;
|
||||||
typedef unsigned __int64 uint64_t;
|
typedef unsigned __int64 uint64_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // _MSC_VER >= 1600
|
||||||
#endif // CPPCONN_DONT_TYPEDEF_MS_TYPES_TO_C99_TYPES
|
#endif // CPPCONN_DONT_TYPEDEF_MS_TYPES_TO_C99_TYPES
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
|
@ -1,42 +1,49 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
*
|
||||||
The MySQL Connector/C++ is licensed under the terms of the GPLv2
|
* This program is free software; you can redistribute it and/or modify
|
||||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
* it under the terms of the GNU General Public License, version 2.0, as
|
||||||
MySQL Connectors. There are special exceptions to the terms and
|
* published by the Free Software Foundation.
|
||||||
conditions of the GPLv2 as it is applied to this software, see the
|
*
|
||||||
FLOSS License Exception
|
* This program is also distributed with certain software (including
|
||||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
* but not limited to OpenSSL) that is licensed under separate terms,
|
||||||
|
* as designated in a particular file or component or in included license
|
||||||
This program is free software; you can redistribute it and/or modify
|
* documentation. The authors of MySQL hereby grant you an
|
||||||
it under the terms of the GNU General Public License as published
|
* additional permission to link the program and your derivative works
|
||||||
by the Free Software Foundation; version 2 of the License.
|
* with the separately licensed software that they have included with
|
||||||
|
* MySQL.
|
||||||
This program is distributed in the hope that it will be useful, but
|
*
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* Without limiting anything contained in the foregoing, this file,
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
* which is part of MySQL Connector/C++, is also subject to the
|
||||||
for more details.
|
* Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||||
|
* http://oss.oracle.com/licenses/universal-foss-exception.
|
||||||
You should have received a copy of the GNU General Public License along
|
*
|
||||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
* This program is distributed in the hope that it will be useful, but
|
||||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License, version 2.0, for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _SQL_CONNECTION_H_
|
#ifndef _SQL_CONNECTION_H_
|
||||||
#define _SQL_CONNECTION_H_
|
#define _SQL_CONNECTION_H_
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <boost/variant.hpp>
|
|
||||||
|
|
||||||
#include "build_config.h"
|
#include "build_config.h"
|
||||||
#include "warning.h"
|
#include "warning.h"
|
||||||
#include "sqlstring.h"
|
#include "sqlstring.h"
|
||||||
|
#include "variant.h"
|
||||||
|
|
||||||
namespace sql
|
namespace sql
|
||||||
{
|
{
|
||||||
|
|
||||||
|
typedef sql::Variant ConnectPropertyVal;
|
||||||
typedef boost::variant<int, double, bool, sql::SQLString > ConnectPropertyVal;
|
|
||||||
|
|
||||||
typedef std::map< sql::SQLString, ConnectPropertyVal > ConnectOptionsMap;
|
typedef std::map< sql::SQLString, ConnectPropertyVal > ConnectOptionsMap;
|
||||||
|
|
||||||
|
@ -54,6 +61,12 @@ typedef enum transaction_isolation
|
||||||
TRANSACTION_SERIALIZABLE
|
TRANSACTION_SERIALIZABLE
|
||||||
} enum_transaction_isolation;
|
} enum_transaction_isolation;
|
||||||
|
|
||||||
|
enum ssl_mode
|
||||||
|
{
|
||||||
|
SSL_MODE_DISABLED= 1, SSL_MODE_PREFERRED, SSL_MODE_REQUIRED,
|
||||||
|
SSL_MODE_VERIFY_CA, SSL_MODE_VERIFY_IDENTITY
|
||||||
|
};
|
||||||
|
|
||||||
class Savepoint
|
class Savepoint
|
||||||
{
|
{
|
||||||
/* Prevent use of these */
|
/* Prevent use of these */
|
||||||
|
@ -99,6 +112,8 @@ public:
|
||||||
|
|
||||||
virtual void getClientOption(const sql::SQLString & optionName, void * optionValue) = 0;
|
virtual void getClientOption(const sql::SQLString & optionName, void * optionValue) = 0;
|
||||||
|
|
||||||
|
virtual sql::SQLString getClientOption(const sql::SQLString & optionName) = 0;
|
||||||
|
|
||||||
virtual DatabaseMetaData * getMetaData() = 0;
|
virtual DatabaseMetaData * getMetaData() = 0;
|
||||||
|
|
||||||
virtual enum_transaction_isolation getTransactionIsolation() = 0;
|
virtual enum_transaction_isolation getTransactionIsolation() = 0;
|
||||||
|
@ -109,6 +124,10 @@ public:
|
||||||
|
|
||||||
virtual bool isReadOnly() = 0;
|
virtual bool isReadOnly() = 0;
|
||||||
|
|
||||||
|
virtual bool isValid() = 0;
|
||||||
|
|
||||||
|
virtual bool reconnect() = 0;
|
||||||
|
|
||||||
virtual sql::SQLString nativeSQL(const sql::SQLString& sql) = 0;
|
virtual sql::SQLString nativeSQL(const sql::SQLString& sql) = 0;
|
||||||
|
|
||||||
virtual PreparedStatement * prepareStatement(const sql::SQLString& sql) = 0;
|
virtual PreparedStatement * prepareStatement(const sql::SQLString& sql) = 0;
|
||||||
|
@ -137,6 +156,8 @@ public:
|
||||||
|
|
||||||
virtual sql::Connection * setClientOption(const sql::SQLString & optionName, const void * optionValue) = 0;
|
virtual sql::Connection * setClientOption(const sql::SQLString & optionName, const void * optionValue) = 0;
|
||||||
|
|
||||||
|
virtual sql::Connection * setClientOption(const sql::SQLString & optionName, const sql::SQLString & optionValue) = 0;
|
||||||
|
|
||||||
virtual void setHoldability(int holdability) = 0;
|
virtual void setHoldability(int holdability) = 0;
|
||||||
|
|
||||||
virtual void setReadOnly(bool readOnly) = 0;
|
virtual void setReadOnly(bool readOnly) = 0;
|
||||||
|
|
|
@ -1,27 +1,35 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
*
|
||||||
The MySQL Connector/C++ is licensed under the terms of the GPLv2
|
* This program is free software; you can redistribute it and/or modify
|
||||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
* it under the terms of the GNU General Public License, version 2.0, as
|
||||||
MySQL Connectors. There are special exceptions to the terms and
|
* published by the Free Software Foundation.
|
||||||
conditions of the GPLv2 as it is applied to this software, see the
|
*
|
||||||
FLOSS License Exception
|
* This program is also distributed with certain software (including
|
||||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
* but not limited to OpenSSL) that is licensed under separate terms,
|
||||||
|
* as designated in a particular file or component or in included license
|
||||||
This program is free software; you can redistribute it and/or modify
|
* documentation. The authors of MySQL hereby grant you an
|
||||||
it under the terms of the GNU General Public License as published
|
* additional permission to link the program and your derivative works
|
||||||
by the Free Software Foundation; version 2 of the License.
|
* with the separately licensed software that they have included with
|
||||||
|
* MySQL.
|
||||||
This program is distributed in the hope that it will be useful, but
|
*
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* Without limiting anything contained in the foregoing, this file,
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
* which is part of MySQL Connector/C++, is also subject to the
|
||||||
for more details.
|
* Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||||
|
* http://oss.oracle.com/licenses/universal-foss-exception.
|
||||||
You should have received a copy of the GNU General Public License along
|
*
|
||||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
* This program is distributed in the hope that it will be useful, but
|
||||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License, version 2.0, for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _SQL_DATATYPE_H_
|
#ifndef _SQL_DATATYPE_H_
|
||||||
#define _SQL_DATATYPE_H_
|
#define _SQL_DATATYPE_H_
|
||||||
|
|
||||||
|
@ -57,7 +65,8 @@ public:
|
||||||
GEOMETRY,
|
GEOMETRY,
|
||||||
ENUM,
|
ENUM,
|
||||||
SET,
|
SET,
|
||||||
SQLNULL
|
SQLNULL,
|
||||||
|
JSON
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,35 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
*
|
||||||
The MySQL Connector/C++ is licensed under the terms of the GPLv2
|
* This program is free software; you can redistribute it and/or modify
|
||||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
* it under the terms of the GNU General Public License, version 2.0, as
|
||||||
MySQL Connectors. There are special exceptions to the terms and
|
* published by the Free Software Foundation.
|
||||||
conditions of the GPLv2 as it is applied to this software, see the
|
*
|
||||||
FLOSS License Exception
|
* This program is also distributed with certain software (including
|
||||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
* but not limited to OpenSSL) that is licensed under separate terms,
|
||||||
|
* as designated in a particular file or component or in included license
|
||||||
This program is free software; you can redistribute it and/or modify
|
* documentation. The authors of MySQL hereby grant you an
|
||||||
it under the terms of the GNU General Public License as published
|
* additional permission to link the program and your derivative works
|
||||||
by the Free Software Foundation; version 2 of the License.
|
* with the separately licensed software that they have included with
|
||||||
|
* MySQL.
|
||||||
This program is distributed in the hope that it will be useful, but
|
*
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* Without limiting anything contained in the foregoing, this file,
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
* which is part of MySQL Connector/C++, is also subject to the
|
||||||
for more details.
|
* Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||||
|
* http://oss.oracle.com/licenses/universal-foss-exception.
|
||||||
You should have received a copy of the GNU General Public License along
|
*
|
||||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
* This program is distributed in the hope that it will be useful, but
|
||||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License, version 2.0, for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _SQL_DRIVER_H_
|
#ifndef _SQL_DRIVER_H_
|
||||||
#define _SQL_DRIVER_H_
|
#define _SQL_DRIVER_H_
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,35 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
*
|
||||||
The MySQL Connector/C++ is licensed under the terms of the GPLv2
|
* This program is free software; you can redistribute it and/or modify
|
||||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
* it under the terms of the GNU General Public License, version 2.0, as
|
||||||
MySQL Connectors. There are special exceptions to the terms and
|
* published by the Free Software Foundation.
|
||||||
conditions of the GPLv2 as it is applied to this software, see the
|
*
|
||||||
FLOSS License Exception
|
* This program is also distributed with certain software (including
|
||||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
* but not limited to OpenSSL) that is licensed under separate terms,
|
||||||
|
* as designated in a particular file or component or in included license
|
||||||
This program is free software; you can redistribute it and/or modify
|
* documentation. The authors of MySQL hereby grant you an
|
||||||
it under the terms of the GNU General Public License as published
|
* additional permission to link the program and your derivative works
|
||||||
by the Free Software Foundation; version 2 of the License.
|
* with the separately licensed software that they have included with
|
||||||
|
* MySQL.
|
||||||
This program is distributed in the hope that it will be useful, but
|
*
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* Without limiting anything contained in the foregoing, this file,
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
* which is part of MySQL Connector/C++, is also subject to the
|
||||||
for more details.
|
* Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||||
|
* http://oss.oracle.com/licenses/universal-foss-exception.
|
||||||
You should have received a copy of the GNU General Public License along
|
*
|
||||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
* This program is distributed in the hope that it will be useful, but
|
||||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License, version 2.0, for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _SQL_EXCEPTION_H_
|
#ifndef _SQL_EXCEPTION_H_
|
||||||
#define _SQL_EXCEPTION_H_
|
#define _SQL_EXCEPTION_H_
|
||||||
|
|
||||||
|
@ -33,6 +41,7 @@
|
||||||
namespace sql
|
namespace sql
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#if (__cplusplus < 201103L)
|
||||||
#define MEMORY_ALLOC_OPERATORS(Class) \
|
#define MEMORY_ALLOC_OPERATORS(Class) \
|
||||||
void* operator new(size_t size) throw (std::bad_alloc) { return ::operator new(size); } \
|
void* operator new(size_t size) throw (std::bad_alloc) { return ::operator new(size); } \
|
||||||
void* operator new(size_t, void*) throw(); \
|
void* operator new(size_t, void*) throw(); \
|
||||||
|
@ -41,7 +50,17 @@ namespace sql
|
||||||
void* operator new[](size_t, void*) throw(); \
|
void* operator new[](size_t, void*) throw(); \
|
||||||
void* operator new[](size_t, const std::nothrow_t&) throw(); \
|
void* operator new[](size_t, const std::nothrow_t&) throw(); \
|
||||||
void* operator new(size_t N, std::allocator<Class>&);
|
void* operator new(size_t N, std::allocator<Class>&);
|
||||||
|
#else
|
||||||
|
#define MEMORY_ALLOC_OPERATORS(Class) \
|
||||||
|
void* operator new(size_t size){ return ::operator new(size); } \
|
||||||
|
void* operator new(size_t, void*) noexcept; \
|
||||||
|
void* operator new(size_t, const std::nothrow_t&) noexcept; \
|
||||||
|
void* operator new[](size_t); \
|
||||||
|
void* operator new[](size_t, void*) noexcept; \
|
||||||
|
void* operator new[](size_t, const std::nothrow_t&) noexcept; \
|
||||||
|
void* operator new(size_t N, std::allocator<Class>&);
|
||||||
|
|
||||||
|
#endif
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#pragma warning (disable : 4290)
|
#pragma warning (disable : 4290)
|
||||||
//warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
//warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
||||||
|
@ -121,6 +140,29 @@ struct CPPCONN_PUBLIC_FUNC NonScrollableException : public SQLException
|
||||||
NonScrollableException(const std::string& reason) : SQLException(reason, "", 0) {}
|
NonScrollableException(const std::string& reason) : SQLException(reason, "", 0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct CPPCONN_PUBLIC_FUNC SQLUnsupportedOptionException : public SQLException
|
||||||
|
{
|
||||||
|
SQLUnsupportedOptionException(const SQLUnsupportedOptionException& e, const std::string conn_option) :
|
||||||
|
SQLException(e.what(), e.sql_state, e.errNo),
|
||||||
|
option(conn_option )
|
||||||
|
{}
|
||||||
|
|
||||||
|
SQLUnsupportedOptionException(const std::string& reason, const std::string conn_option) :
|
||||||
|
SQLException(reason, "", 0),
|
||||||
|
option(conn_option )
|
||||||
|
{}
|
||||||
|
|
||||||
|
const char *getConnectionOption() const
|
||||||
|
{
|
||||||
|
return option.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
~SQLUnsupportedOptionException() throw () {};
|
||||||
|
protected:
|
||||||
|
const std::string option;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
} /* namespace sql */
|
} /* namespace sql */
|
||||||
|
|
||||||
#endif /* _SQL_EXCEPTION_H_ */
|
#endif /* _SQL_EXCEPTION_H_ */
|
||||||
|
|
|
@ -1,27 +1,35 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
*
|
||||||
The MySQL Connector/C++ is licensed under the terms of the GPLv2
|
* This program is free software; you can redistribute it and/or modify
|
||||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
* it under the terms of the GNU General Public License, version 2.0, as
|
||||||
MySQL Connectors. There are special exceptions to the terms and
|
* published by the Free Software Foundation.
|
||||||
conditions of the GPLv2 as it is applied to this software, see the
|
*
|
||||||
FLOSS License Exception
|
* This program is also distributed with certain software (including
|
||||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
* but not limited to OpenSSL) that is licensed under separate terms,
|
||||||
|
* as designated in a particular file or component or in included license
|
||||||
This program is free software; you can redistribute it and/or modify
|
* documentation. The authors of MySQL hereby grant you an
|
||||||
it under the terms of the GNU General Public License as published
|
* additional permission to link the program and your derivative works
|
||||||
by the Free Software Foundation; version 2 of the License.
|
* with the separately licensed software that they have included with
|
||||||
|
* MySQL.
|
||||||
This program is distributed in the hope that it will be useful, but
|
*
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* Without limiting anything contained in the foregoing, this file,
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
* which is part of MySQL Connector/C++, is also subject to the
|
||||||
for more details.
|
* Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||||
|
* http://oss.oracle.com/licenses/universal-foss-exception.
|
||||||
You should have received a copy of the GNU General Public License along
|
*
|
||||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
* This program is distributed in the hope that it will be useful, but
|
||||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License, version 2.0, for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _SQL_METADATA_H_
|
#ifndef _SQL_METADATA_H_
|
||||||
#define _SQL_METADATA_H_
|
#define _SQL_METADATA_H_
|
||||||
|
|
||||||
|
@ -245,6 +253,10 @@ public:
|
||||||
|
|
||||||
virtual const sql::SQLString& getSchemaTerm() = 0;
|
virtual const sql::SQLString& getSchemaTerm() = 0;
|
||||||
|
|
||||||
|
virtual ResultSet * getSchemaCollation(const sql::SQLString& catalog, const sql::SQLString& schemaPattern) = 0;
|
||||||
|
|
||||||
|
virtual ResultSet * getSchemaCharset(const sql::SQLString& catalog, const sql::SQLString& schemaPattern) = 0;
|
||||||
|
|
||||||
virtual const sql::SQLString& getSearchStringEscape() = 0;
|
virtual const sql::SQLString& getSearchStringEscape() = 0;
|
||||||
|
|
||||||
virtual const sql::SQLString& getSQLKeywords() = 0;
|
virtual const sql::SQLString& getSQLKeywords() = 0;
|
||||||
|
@ -265,6 +277,10 @@ public:
|
||||||
|
|
||||||
virtual ResultSet * getTableTypes() = 0;
|
virtual ResultSet * getTableTypes() = 0;
|
||||||
|
|
||||||
|
virtual ResultSet * getTableCollation(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern) = 0;
|
||||||
|
|
||||||
|
virtual ResultSet * getTableCharset(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern) = 0;
|
||||||
|
|
||||||
virtual const sql::SQLString& getTimeDateFunctions() = 0;
|
virtual const sql::SQLString& getTimeDateFunctions() = 0;
|
||||||
|
|
||||||
virtual ResultSet * getTypeInfo() = 0;
|
virtual ResultSet * getTypeInfo() = 0;
|
||||||
|
|
|
@ -1,27 +1,35 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
*
|
||||||
The MySQL Connector/C++ is licensed under the terms of the GPLv2
|
* This program is free software; you can redistribute it and/or modify
|
||||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
* it under the terms of the GNU General Public License, version 2.0, as
|
||||||
MySQL Connectors. There are special exceptions to the terms and
|
* published by the Free Software Foundation.
|
||||||
conditions of the GPLv2 as it is applied to this software, see the
|
*
|
||||||
FLOSS License Exception
|
* This program is also distributed with certain software (including
|
||||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
* but not limited to OpenSSL) that is licensed under separate terms,
|
||||||
|
* as designated in a particular file or component or in included license
|
||||||
This program is free software; you can redistribute it and/or modify
|
* documentation. The authors of MySQL hereby grant you an
|
||||||
it under the terms of the GNU General Public License as published
|
* additional permission to link the program and your derivative works
|
||||||
by the Free Software Foundation; version 2 of the License.
|
* with the separately licensed software that they have included with
|
||||||
|
* MySQL.
|
||||||
This program is distributed in the hope that it will be useful, but
|
*
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* Without limiting anything contained in the foregoing, this file,
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
* which is part of MySQL Connector/C++, is also subject to the
|
||||||
for more details.
|
* Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||||
|
* http://oss.oracle.com/licenses/universal-foss-exception.
|
||||||
You should have received a copy of the GNU General Public License along
|
*
|
||||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
* This program is distributed in the hope that it will be useful, but
|
||||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License, version 2.0, for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _SQL_PARAMETER_METADATA_H_
|
#ifndef _SQL_PARAMETER_METADATA_H_
|
||||||
#define _SQL_PARAMETER_METADATA_H_
|
#define _SQL_PARAMETER_METADATA_H_
|
||||||
|
|
||||||
|
|
|
@ -1,28 +1,36 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
*
|
||||||
The MySQL Connector/C++ is licensed under the terms of the GPLv2
|
* This program is free software; you can redistribute it and/or modify
|
||||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
* it under the terms of the GNU General Public License, version 2.0, as
|
||||||
MySQL Connectors. There are special exceptions to the terms and
|
* published by the Free Software Foundation.
|
||||||
conditions of the GPLv2 as it is applied to this software, see the
|
*
|
||||||
FLOSS License Exception
|
* This program is also distributed with certain software (including
|
||||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
* but not limited to OpenSSL) that is licensed under separate terms,
|
||||||
|
* as designated in a particular file or component or in included license
|
||||||
This program is free software; you can redistribute it and/or modify
|
* documentation. The authors of MySQL hereby grant you an
|
||||||
it under the terms of the GNU General Public License as published
|
* additional permission to link the program and your derivative works
|
||||||
by the Free Software Foundation; version 2 of the License.
|
* with the separately licensed software that they have included with
|
||||||
|
* MySQL.
|
||||||
This program is distributed in the hope that it will be useful, but
|
*
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* Without limiting anything contained in the foregoing, this file,
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
* which is part of MySQL Connector/C++, is also subject to the
|
||||||
for more details.
|
* Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||||
|
* http://oss.oracle.com/licenses/universal-foss-exception.
|
||||||
You should have received a copy of the GNU General Public License along
|
*
|
||||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
* This program is distributed in the hope that it will be useful, but
|
||||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License, version 2.0, for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _SQL_PREPARED_STATEMENT_H_
|
#ifndef _SQL_PREPARED_STATEMENT_H_
|
||||||
#define _SQL_PREPARED_STATEMENT_H_
|
#define _SQL_PREPARED_STATEMENT_H_
|
||||||
|
|
||||||
|
@ -58,6 +66,8 @@ public:
|
||||||
|
|
||||||
virtual ParameterMetaData * getParameterMetaData() = 0;
|
virtual ParameterMetaData * getParameterMetaData() = 0;
|
||||||
|
|
||||||
|
virtual bool getMoreResults() = 0;
|
||||||
|
|
||||||
virtual void setBigInt(unsigned int parameterIndex, const sql::SQLString& value) = 0;
|
virtual void setBigInt(unsigned int parameterIndex, const sql::SQLString& value) = 0;
|
||||||
|
|
||||||
virtual void setBlob(unsigned int parameterIndex, std::istream * blob) = 0;
|
virtual void setBlob(unsigned int parameterIndex, std::istream * blob) = 0;
|
||||||
|
|
|
@ -1,27 +1,35 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
*
|
||||||
The MySQL Connector/C++ is licensed under the terms of the GPLv2
|
* This program is free software; you can redistribute it and/or modify
|
||||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
* it under the terms of the GNU General Public License, version 2.0, as
|
||||||
MySQL Connectors. There are special exceptions to the terms and
|
* published by the Free Software Foundation.
|
||||||
conditions of the GPLv2 as it is applied to this software, see the
|
*
|
||||||
FLOSS License Exception
|
* This program is also distributed with certain software (including
|
||||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
* but not limited to OpenSSL) that is licensed under separate terms,
|
||||||
|
* as designated in a particular file or component or in included license
|
||||||
This program is free software; you can redistribute it and/or modify
|
* documentation. The authors of MySQL hereby grant you an
|
||||||
it under the terms of the GNU General Public License as published
|
* additional permission to link the program and your derivative works
|
||||||
by the Free Software Foundation; version 2 of the License.
|
* with the separately licensed software that they have included with
|
||||||
|
* MySQL.
|
||||||
This program is distributed in the hope that it will be useful, but
|
*
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* Without limiting anything contained in the foregoing, this file,
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
* which is part of MySQL Connector/C++, is also subject to the
|
||||||
for more details.
|
* Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||||
|
* http://oss.oracle.com/licenses/universal-foss-exception.
|
||||||
You should have received a copy of the GNU General Public License along
|
*
|
||||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
* This program is distributed in the hope that it will be useful, but
|
||||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License, version 2.0, for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _SQL_RESULTSET_H_
|
#ifndef _SQL_RESULTSET_H_
|
||||||
#define _SQL_RESULTSET_H_
|
#define _SQL_RESULTSET_H_
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,35 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
*
|
||||||
The MySQL Connector/C++ is licensed under the terms of the GPLv2
|
* This program is free software; you can redistribute it and/or modify
|
||||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
* it under the terms of the GNU General Public License, version 2.0, as
|
||||||
MySQL Connectors. There are special exceptions to the terms and
|
* published by the Free Software Foundation.
|
||||||
conditions of the GPLv2 as it is applied to this software, see the
|
*
|
||||||
FLOSS License Exception
|
* This program is also distributed with certain software (including
|
||||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
* but not limited to OpenSSL) that is licensed under separate terms,
|
||||||
|
* as designated in a particular file or component or in included license
|
||||||
This program is free software; you can redistribute it and/or modify
|
* documentation. The authors of MySQL hereby grant you an
|
||||||
it under the terms of the GNU General Public License as published
|
* additional permission to link the program and your derivative works
|
||||||
by the Free Software Foundation; version 2 of the License.
|
* with the separately licensed software that they have included with
|
||||||
|
* MySQL.
|
||||||
This program is distributed in the hope that it will be useful, but
|
*
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* Without limiting anything contained in the foregoing, this file,
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
* which is part of MySQL Connector/C++, is also subject to the
|
||||||
for more details.
|
* Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||||
|
* http://oss.oracle.com/licenses/universal-foss-exception.
|
||||||
You should have received a copy of the GNU General Public License along
|
*
|
||||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
* This program is distributed in the hope that it will be useful, but
|
||||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License, version 2.0, for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _SQL_RESULTSET_METADATA_H_
|
#ifndef _SQL_RESULTSET_METADATA_H_
|
||||||
#define _SQL_RESULTSET_METADATA_H_
|
#define _SQL_RESULTSET_METADATA_H_
|
||||||
|
|
||||||
|
@ -55,6 +63,10 @@ public:
|
||||||
|
|
||||||
virtual SQLString getColumnTypeName(unsigned int column) = 0;
|
virtual SQLString getColumnTypeName(unsigned int column) = 0;
|
||||||
|
|
||||||
|
virtual SQLString getColumnCharset(unsigned int columnIndex) = 0;
|
||||||
|
|
||||||
|
virtual SQLString getColumnCollation(unsigned int columnIndex) = 0;
|
||||||
|
|
||||||
virtual unsigned int getPrecision(unsigned int column) = 0;
|
virtual unsigned int getPrecision(unsigned int column) = 0;
|
||||||
|
|
||||||
virtual unsigned int getScale(unsigned int column) = 0;
|
virtual unsigned int getScale(unsigned int column) = 0;
|
||||||
|
@ -73,6 +85,8 @@ public:
|
||||||
|
|
||||||
virtual int isNullable(unsigned int column) = 0;
|
virtual int isNullable(unsigned int column) = 0;
|
||||||
|
|
||||||
|
virtual bool isNumeric(unsigned int column) = 0;
|
||||||
|
|
||||||
virtual bool isReadOnly(unsigned int column) = 0;
|
virtual bool isReadOnly(unsigned int column) = 0;
|
||||||
|
|
||||||
virtual bool isSearchable(unsigned int column) = 0;
|
virtual bool isSearchable(unsigned int column) = 0;
|
||||||
|
|
|
@ -1,31 +1,40 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
*
|
||||||
The MySQL Connector/C++ is licensed under the terms of the GPLv2
|
* This program is free software; you can redistribute it and/or modify
|
||||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
* it under the terms of the GNU General Public License, version 2.0, as
|
||||||
MySQL Connectors. There are special exceptions to the terms and
|
* published by the Free Software Foundation.
|
||||||
conditions of the GPLv2 as it is applied to this software, see the
|
*
|
||||||
FLOSS License Exception
|
* This program is also distributed with certain software (including
|
||||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
* but not limited to OpenSSL) that is licensed under separate terms,
|
||||||
|
* as designated in a particular file or component or in included license
|
||||||
This program is free software; you can redistribute it and/or modify
|
* documentation. The authors of MySQL hereby grant you an
|
||||||
it under the terms of the GNU General Public License as published
|
* additional permission to link the program and your derivative works
|
||||||
by the Free Software Foundation; version 2 of the License.
|
* with the separately licensed software that they have included with
|
||||||
|
* MySQL.
|
||||||
This program is distributed in the hope that it will be useful, but
|
*
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* Without limiting anything contained in the foregoing, this file,
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
* which is part of MySQL Connector/C++, is also subject to the
|
||||||
for more details.
|
* Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||||
|
* http://oss.oracle.com/licenses/universal-foss-exception.
|
||||||
You should have received a copy of the GNU General Public License along
|
*
|
||||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
* This program is distributed in the hope that it will be useful, but
|
||||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License, version 2.0, for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _SQL_STRING_H_
|
#ifndef _SQL_STRING_H_
|
||||||
#define _SQL_STRING_H_
|
#define _SQL_STRING_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <algorithm>
|
||||||
#include "build_config.h"
|
#include "build_config.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
@ -102,6 +111,30 @@ namespace sql
|
||||||
return realStr.compare(pos1, n1, s);
|
return realStr.compare(pos1, n1, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int caseCompare(const SQLString &s) const
|
||||||
|
{
|
||||||
|
std::string tmp(realStr), str(s);
|
||||||
|
std::transform(tmp.begin(), tmp.end(), tmp.begin(), ::tolower);
|
||||||
|
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
|
||||||
|
return tmp.compare(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
int caseCompare(const char * s) const
|
||||||
|
{
|
||||||
|
std::string tmp(realStr), str(s);
|
||||||
|
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
|
||||||
|
std::transform(tmp.begin(), tmp.end(), tmp.begin(), ::tolower);
|
||||||
|
return tmp.compare(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
int caseCompare(size_t pos1, size_t n1, const char * s) const
|
||||||
|
{
|
||||||
|
std::string tmp(realStr.c_str() + pos1, n1), str(s);
|
||||||
|
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
|
||||||
|
std::transform(tmp.begin(), tmp.end(), tmp.begin(), ::tolower);
|
||||||
|
return tmp.compare(str);
|
||||||
|
}
|
||||||
|
|
||||||
const std::string & asStdString() const
|
const std::string & asStdString() const
|
||||||
{
|
{
|
||||||
return realStr;
|
return realStr;
|
||||||
|
|
|
@ -1,27 +1,35 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
*
|
||||||
The MySQL Connector/C++ is licensed under the terms of the GPLv2
|
* This program is free software; you can redistribute it and/or modify
|
||||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
* it under the terms of the GNU General Public License, version 2.0, as
|
||||||
MySQL Connectors. There are special exceptions to the terms and
|
* published by the Free Software Foundation.
|
||||||
conditions of the GPLv2 as it is applied to this software, see the
|
*
|
||||||
FLOSS License Exception
|
* This program is also distributed with certain software (including
|
||||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
* but not limited to OpenSSL) that is licensed under separate terms,
|
||||||
|
* as designated in a particular file or component or in included license
|
||||||
This program is free software; you can redistribute it and/or modify
|
* documentation. The authors of MySQL hereby grant you an
|
||||||
it under the terms of the GNU General Public License as published
|
* additional permission to link the program and your derivative works
|
||||||
by the Free Software Foundation; version 2 of the License.
|
* with the separately licensed software that they have included with
|
||||||
|
* MySQL.
|
||||||
This program is distributed in the hope that it will be useful, but
|
*
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* Without limiting anything contained in the foregoing, this file,
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
* which is part of MySQL Connector/C++, is also subject to the
|
||||||
for more details.
|
* Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||||
|
* http://oss.oracle.com/licenses/universal-foss-exception.
|
||||||
You should have received a copy of the GNU General Public License along
|
*
|
||||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
* This program is distributed in the hope that it will be useful, but
|
||||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License, version 2.0, for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _SQL_STATEMENT_H_
|
#ifndef _SQL_STATEMENT_H_
|
||||||
#define _SQL_STATEMENT_H_
|
#define _SQL_STATEMENT_H_
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,35 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
*
|
||||||
The MySQL Connector/C++ is licensed under the terms of the GPLv2
|
* This program is free software; you can redistribute it and/or modify
|
||||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
* it under the terms of the GNU General Public License, version 2.0, as
|
||||||
MySQL Connectors. There are special exceptions to the terms and
|
* published by the Free Software Foundation.
|
||||||
conditions of the GPLv2 as it is applied to this software, see the
|
*
|
||||||
FLOSS License Exception
|
* This program is also distributed with certain software (including
|
||||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
* but not limited to OpenSSL) that is licensed under separate terms,
|
||||||
|
* as designated in a particular file or component or in included license
|
||||||
This program is free software; you can redistribute it and/or modify
|
* documentation. The authors of MySQL hereby grant you an
|
||||||
it under the terms of the GNU General Public License as published
|
* additional permission to link the program and your derivative works
|
||||||
by the Free Software Foundation; version 2 of the License.
|
* with the separately licensed software that they have included with
|
||||||
|
* MySQL.
|
||||||
This program is distributed in the hope that it will be useful, but
|
*
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* Without limiting anything contained in the foregoing, this file,
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
* which is part of MySQL Connector/C++, is also subject to the
|
||||||
for more details.
|
* Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||||
|
* http://oss.oracle.com/licenses/universal-foss-exception.
|
||||||
You should have received a copy of the GNU General Public License along
|
*
|
||||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
* This program is distributed in the hope that it will be useful, but
|
||||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License, version 2.0, for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _SQL_WARNING_H_
|
#ifndef _SQL_WARNING_H_
|
||||||
#define _SQL_WARNING_H_
|
#define _SQL_WARNING_H_
|
||||||
|
|
||||||
|
@ -59,7 +67,7 @@ protected:
|
||||||
|
|
||||||
virtual ~SQLWarning(){};
|
virtual ~SQLWarning(){};
|
||||||
|
|
||||||
SQLWarning(const SQLWarning& e){};
|
SQLWarning(const SQLWarning&){};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const SQLWarning & operator = (const SQLWarning & rhs);
|
const SQLWarning & operator = (const SQLWarning & rhs);
|
||||||
|
|
|
@ -46,19 +46,6 @@
|
||||||
#include "httpdef.h"
|
#include "httpdef.h"
|
||||||
#include "http_content.h"
|
#include "http_content.h"
|
||||||
|
|
||||||
namespace hv {
|
|
||||||
|
|
||||||
struct NetAddr {
|
|
||||||
std::string ip;
|
|
||||||
int port;
|
|
||||||
|
|
||||||
std::string ipport() {
|
|
||||||
return hv::asprintf("%s:%d", ip.c_str(), port);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie
|
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie
|
||||||
// Cookie: sessionid=1; domain=.example.com; path=/; max-age=86400; secure; httponly
|
// Cookie: sessionid=1; domain=.example.com; path=/; max-age=86400; secure; httponly
|
||||||
struct HV_EXPORT HttpCookie {
|
struct HV_EXPORT HttpCookie {
|
||||||
|
@ -297,6 +284,7 @@ public:
|
||||||
void* Content() {
|
void* Content() {
|
||||||
if (content == NULL && body.size() != 0) {
|
if (content == NULL && body.size() != 0) {
|
||||||
content = (void*)body.data();
|
content = (void*)body.data();
|
||||||
|
content_length = body.size();
|
||||||
}
|
}
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,11 +72,9 @@ int main() {
|
||||||
return 200;
|
return 200;
|
||||||
});
|
});
|
||||||
|
|
||||||
HttpServer server;
|
HttpServer server(&service);
|
||||||
server.registerHttpService(&service);
|
|
||||||
server.setPort(8080);
|
|
||||||
server.setThreadNum(4);
|
server.setThreadNum(4);
|
||||||
server.run();
|
server.run(":8080");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
@ -130,12 +128,20 @@ public:
|
||||||
return setSslCtx(ssl_ctx);
|
return setSslCtx(ssl_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
int run(bool wait = true) {
|
// run(":8080")
|
||||||
|
// run("0.0.0.0:8080")
|
||||||
|
// run("[::]:8080")
|
||||||
|
int run(const char* ip_port = NULL, bool wait = true) {
|
||||||
|
if (ip_port) {
|
||||||
|
hv::NetAddr listen_addr(ip_port);
|
||||||
|
if (listen_addr.ip.size() != 0) setHost(listen_addr.ip.c_str());
|
||||||
|
if (listen_addr.port != 0) setPort(listen_addr.port);
|
||||||
|
}
|
||||||
return http_server_run(this, wait);
|
return http_server_run(this, wait);
|
||||||
}
|
}
|
||||||
|
|
||||||
int start() {
|
int start(const char* ip_port = NULL) {
|
||||||
return run(false);
|
return run(ip_port, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int stop() {
|
int stop() {
|
||||||
|
|
|
@ -60,6 +60,7 @@ public:
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
perror("bind");
|
perror("bind");
|
||||||
}
|
}
|
||||||
|
hio_set_localaddr(channel->io(), &local_addr.sa, SOCKADDR_LEN(&local_addr));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_STDATOMIC_H
|
#ifndef HAVE_STDATOMIC_H
|
||||||
#define HAVE_STDATOMIC_H 1
|
#define HAVE_STDATOMIC_H 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_SYS_TYPES_H
|
#ifndef HAVE_SYS_TYPES_H
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_SYS_TIME_H
|
#ifndef HAVE_SYS_TIME_H
|
||||||
#define HAVE_SYS_TIME_H 1
|
#define HAVE_SYS_TIME_H 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_FCNTL_H
|
#ifndef HAVE_FCNTL_H
|
||||||
|
@ -30,11 +30,11 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_PTHREAD_H
|
#ifndef HAVE_PTHREAD_H
|
||||||
#define HAVE_PTHREAD_H 1
|
#define HAVE_PTHREAD_H 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_ENDIAN_H
|
#ifndef HAVE_ENDIAN_H
|
||||||
#define HAVE_ENDIAN_H 1
|
#define HAVE_ENDIAN_H 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_SYS_ENDIAN_H
|
#ifndef HAVE_SYS_ENDIAN_H
|
||||||
|
@ -54,46 +54,49 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_CLOCK_GETTIME
|
#ifndef HAVE_CLOCK_GETTIME
|
||||||
#define HAVE_CLOCK_GETTIME 1
|
#define HAVE_CLOCK_GETTIME 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_GETTIMEOFDAY
|
#ifndef HAVE_GETTIMEOFDAY
|
||||||
#define HAVE_GETTIMEOFDAY 1
|
#define HAVE_GETTIMEOFDAY 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_PTHREAD_SPIN_LOCK
|
#ifndef HAVE_PTHREAD_SPIN_LOCK
|
||||||
#define HAVE_PTHREAD_SPIN_LOCK 1
|
#define HAVE_PTHREAD_SPIN_LOCK 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK
|
#ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK
|
||||||
#define HAVE_PTHREAD_MUTEX_TIMEDLOCK 1
|
#define HAVE_PTHREAD_MUTEX_TIMEDLOCK 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_SEM_TIMEDWAIT
|
#ifndef HAVE_SEM_TIMEDWAIT
|
||||||
#define HAVE_SEM_TIMEDWAIT 1
|
#define HAVE_SEM_TIMEDWAIT 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_PIPE
|
#ifndef HAVE_PIPE
|
||||||
#define HAVE_PIPE 1
|
#define HAVE_PIPE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_SOCKETPAIR
|
#ifndef HAVE_SOCKETPAIR
|
||||||
#define HAVE_SOCKETPAIR 1
|
#define HAVE_SOCKETPAIR 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_EVENTFD
|
#ifndef HAVE_EVENTFD
|
||||||
#define HAVE_EVENTFD 1
|
#define HAVE_EVENTFD 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_SETPROCTITLE
|
#ifndef HAVE_SETPROCTITLE
|
||||||
#define HAVE_SETPROCTITLE 0
|
#define HAVE_SETPROCTITLE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* #undef WITH_OPENSSL */
|
#define WITH_OPENSSL 1
|
||||||
/* #undef WITH_GNUTLS */
|
/* #undef WITH_GNUTLS */
|
||||||
/* #undef WITH_MBEDTLS */
|
/* #undef WITH_MBEDTLS */
|
||||||
|
|
||||||
/* #undef ENABLE_UDS */
|
/* #undef ENABLE_UDS */
|
||||||
/* #undef USE_MULTIMAP */
|
/* #undef USE_MULTIMAP */
|
||||||
|
|
||||||
|
#define WITH_WEPOLL 1
|
||||||
/* #undef WITH_KCP */
|
/* #undef WITH_KCP */
|
||||||
|
|
||||||
#endif // HV_CONFIG_H_
|
#endif // HV_CONFIG_H_
|
||||||
|
|
|
@ -31,7 +31,8 @@ typedef void (*hclose_cb) (hio_t* io);
|
||||||
typedef enum {
|
typedef enum {
|
||||||
HLOOP_STATUS_STOP,
|
HLOOP_STATUS_STOP,
|
||||||
HLOOP_STATUS_RUNNING,
|
HLOOP_STATUS_RUNNING,
|
||||||
HLOOP_STATUS_PAUSE
|
HLOOP_STATUS_PAUSE,
|
||||||
|
HLOOP_STATUS_DESTROY
|
||||||
} hloop_status_e;
|
} hloop_status_e;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
|
@ -75,6 +75,18 @@ HV_EXPORT std::string trim_pairs(const std::string& str, const char* pairs = PAI
|
||||||
HV_EXPORT std::string replace(const std::string& str, const std::string& find, const std::string& rep);
|
HV_EXPORT std::string replace(const std::string& str, const std::string& find, const std::string& rep);
|
||||||
HV_EXPORT std::string replaceAll(const std::string& str, const std::string& find, const std::string& rep);
|
HV_EXPORT std::string replaceAll(const std::string& str, const std::string& find, const std::string& rep);
|
||||||
|
|
||||||
|
struct HV_EXPORT NetAddr {
|
||||||
|
std::string ip;
|
||||||
|
int port;
|
||||||
|
|
||||||
|
NetAddr() : port(0) {}
|
||||||
|
NetAddr(const std::string& _ip, int _port) : ip(_ip), port(_port) {}
|
||||||
|
NetAddr(const std::string& ipport) { from_string(ipport); }
|
||||||
|
|
||||||
|
void from_string(const std::string& ipport);
|
||||||
|
std::string to_string();
|
||||||
|
};
|
||||||
|
|
||||||
} // end namespace hv
|
} // end namespace hv
|
||||||
|
|
||||||
#endif // HV_STRING_H_
|
#endif // HV_STRING_H_
|
||||||
|
|
|
@ -29,6 +29,7 @@ struct mqtt_client_s {
|
||||||
unsigned char alloced_ssl_ctx: 1; // intern
|
unsigned char alloced_ssl_ctx: 1; // intern
|
||||||
unsigned char connected : 1;
|
unsigned char connected : 1;
|
||||||
unsigned short keepalive;
|
unsigned short keepalive;
|
||||||
|
int ping_cnt;
|
||||||
char client_id[64];
|
char client_id[64];
|
||||||
// will
|
// will
|
||||||
mqtt_message_t* will;
|
mqtt_message_t* will;
|
||||||
|
@ -125,4 +126,210 @@ HV_EXPORT int mqtt_client_unsubscribe(mqtt_client_t* cli,
|
||||||
|
|
||||||
END_EXTERN_C
|
END_EXTERN_C
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <map>
|
||||||
|
#include <mutex>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace hv {
|
||||||
|
|
||||||
|
// @usage examples/mqtt/mqtt_client_test.cpp
|
||||||
|
class MqttClient {
|
||||||
|
public:
|
||||||
|
mqtt_client_t* client;
|
||||||
|
// callbacks
|
||||||
|
typedef std::function<void(MqttClient*)> MqttCallback;
|
||||||
|
typedef std::function<void(MqttClient*, mqtt_message_t*)> MqttMessageCallback;
|
||||||
|
MqttCallback onConnect;
|
||||||
|
MqttCallback onClose;
|
||||||
|
MqttMessageCallback onMessage;
|
||||||
|
|
||||||
|
MqttClient(hloop_t* loop = NULL) {
|
||||||
|
client = mqtt_client_new(loop);
|
||||||
|
}
|
||||||
|
|
||||||
|
~MqttClient() {
|
||||||
|
if (client) {
|
||||||
|
mqtt_client_free(client);
|
||||||
|
client = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void run() {
|
||||||
|
mqtt_client_set_callback(client, on_mqtt);
|
||||||
|
mqtt_client_set_userdata(client, this);
|
||||||
|
mqtt_client_run(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
void stop() {
|
||||||
|
mqtt_client_stop(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setID(const char* id) {
|
||||||
|
mqtt_client_set_id(client, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setWill(mqtt_message_t* will) {
|
||||||
|
mqtt_client_set_will(client, will);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAuth(const char* username, const char* password) {
|
||||||
|
mqtt_client_set_auth(client, username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPingInterval(int sec) {
|
||||||
|
client->keepalive = sec;
|
||||||
|
}
|
||||||
|
|
||||||
|
int lastError() {
|
||||||
|
return mqtt_client_get_last_error(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SSL/TLS
|
||||||
|
int setSslCtx(hssl_ctx_t ssl_ctx) {
|
||||||
|
return mqtt_client_set_ssl_ctx(client, ssl_ctx);
|
||||||
|
}
|
||||||
|
int newSslCtx(hssl_ctx_opt_t* opt) {
|
||||||
|
return mqtt_client_new_ssl_ctx(client, opt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setReconnect(reconn_setting_t* reconn) {
|
||||||
|
mqtt_client_set_reconnect(client, reconn);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setConnectTimeout(int ms) {
|
||||||
|
mqtt_client_set_connect_timeout(client, ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
int connect(const char* host, int port = DEFAULT_MQTT_PORT, int ssl = 0) {
|
||||||
|
return mqtt_client_connect(client, host, port, ssl);
|
||||||
|
}
|
||||||
|
|
||||||
|
int reconnect() {
|
||||||
|
return mqtt_client_reconnect(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
int disconnect() {
|
||||||
|
return mqtt_client_disconnect(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isConnected() {
|
||||||
|
return mqtt_client_is_connected(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
int publish(mqtt_message_t* msg, MqttCallback ack_cb = NULL) {
|
||||||
|
int mid = mqtt_client_publish(client, msg);
|
||||||
|
if (msg->qos > 0 && mid >= 0 && ack_cb) {
|
||||||
|
setAckCallback(mid, ack_cb);
|
||||||
|
}
|
||||||
|
return mid;
|
||||||
|
}
|
||||||
|
|
||||||
|
int publish(const std::string& topic, const std::string& payload, int qos = 0, int retain = 0, MqttCallback ack_cb = NULL) {
|
||||||
|
mqtt_message_t msg;
|
||||||
|
memset(&msg, 0, sizeof(msg));
|
||||||
|
msg.topic_len = topic.size();
|
||||||
|
msg.topic = topic.c_str();
|
||||||
|
msg.payload_len = payload.size();
|
||||||
|
msg.payload = payload.c_str();
|
||||||
|
msg.qos = qos;
|
||||||
|
msg.retain = retain;
|
||||||
|
return publish(&msg, ack_cb);
|
||||||
|
}
|
||||||
|
|
||||||
|
int subscribe(const char* topic, int qos = 0, MqttCallback ack_cb = NULL) {
|
||||||
|
int mid = mqtt_client_subscribe(client, topic, qos);
|
||||||
|
if (qos > 0 && mid >= 0 && ack_cb) {
|
||||||
|
setAckCallback(mid, ack_cb);
|
||||||
|
}
|
||||||
|
return mid;
|
||||||
|
}
|
||||||
|
|
||||||
|
int unsubscribe(const char* topic, MqttCallback ack_cb = NULL) {
|
||||||
|
int mid = mqtt_client_unsubscribe(client, topic);
|
||||||
|
if (mid >= 0 && ack_cb) {
|
||||||
|
setAckCallback(mid, ack_cb);
|
||||||
|
}
|
||||||
|
return mid;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void setAckCallback(int mid, MqttCallback cb) {
|
||||||
|
ack_cbs_mutex.lock();
|
||||||
|
ack_cbs[mid] = std::move(cb);
|
||||||
|
ack_cbs_mutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void invokeAckCallback(int mid) {
|
||||||
|
MqttCallback ack_cb = NULL;
|
||||||
|
ack_cbs_mutex.lock();
|
||||||
|
auto iter = ack_cbs.find(mid);
|
||||||
|
if (iter != ack_cbs.end()) {
|
||||||
|
ack_cb = std::move(iter->second);
|
||||||
|
ack_cbs.erase(iter);
|
||||||
|
}
|
||||||
|
ack_cbs_mutex.unlock();
|
||||||
|
if (ack_cb) ack_cb(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void on_mqtt(mqtt_client_t* cli, int type) {
|
||||||
|
MqttClient* client = (MqttClient*)mqtt_client_get_userdata(cli);
|
||||||
|
// printf("on_mqtt type=%d\n", type);
|
||||||
|
switch(type) {
|
||||||
|
case MQTT_TYPE_CONNECT:
|
||||||
|
// printf("mqtt connected!\n");
|
||||||
|
break;
|
||||||
|
case MQTT_TYPE_DISCONNECT:
|
||||||
|
// printf("mqtt disconnected!\n");
|
||||||
|
if (client->onClose) {
|
||||||
|
client->onClose(client);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MQTT_TYPE_CONNACK:
|
||||||
|
// printf("mqtt connack!\n");
|
||||||
|
if (client->onConnect) {
|
||||||
|
client->onConnect(client);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MQTT_TYPE_PUBLISH:
|
||||||
|
if (client->onMessage) {
|
||||||
|
client->onMessage(client, &cli->message);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MQTT_TYPE_PUBACK: /* qos = 1 */
|
||||||
|
// printf("mqtt puback mid=%d\n", cli->mid);
|
||||||
|
client->invokeAckCallback(cli->mid);
|
||||||
|
break;
|
||||||
|
case MQTT_TYPE_PUBREC: /* qos = 2 */
|
||||||
|
// printf("mqtt pubrec mid=%d\n", cli->mid);
|
||||||
|
// wait MQTT_TYPE_PUBCOMP
|
||||||
|
break;
|
||||||
|
case MQTT_TYPE_PUBCOMP: /* qos = 2 */
|
||||||
|
// printf("mqtt pubcomp mid=%d\n", cli->mid);
|
||||||
|
client->invokeAckCallback(cli->mid);
|
||||||
|
break;
|
||||||
|
case MQTT_TYPE_SUBACK:
|
||||||
|
// printf("mqtt suback mid=%d\n", cli->mid);
|
||||||
|
client->invokeAckCallback(cli->mid);
|
||||||
|
break;
|
||||||
|
case MQTT_TYPE_UNSUBACK:
|
||||||
|
// printf("mqtt unsuback mid=%d\n", cli->mid);
|
||||||
|
client->invokeAckCallback(cli->mid);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
// mid => ack callback
|
||||||
|
std::map<int, MqttCallback> ack_cbs;
|
||||||
|
std::mutex ack_cbs_mutex;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // HV_MQTT_CLIENT_H_
|
#endif // HV_MQTT_CLIENT_H_
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#define _LIBICONV_H
|
#define _LIBICONV_H
|
||||||
|
|
||||||
#define _LIBICONV_VERSION 0x0111 /* version number: (major<<8) + minor */
|
#define _LIBICONV_VERSION 0x0111 /* version number: (major<<8) + minor */
|
||||||
extern int _libiconv_version; /* Likewise */
|
extern __declspec (dllimport) int _libiconv_version; /* Likewise */
|
||||||
|
|
||||||
/* We would like to #include any system header file which could define
|
/* We would like to #include any system header file which could define
|
||||||
iconv_t, 1. in order to eliminate the risk that the user gets compilation
|
iconv_t, 1. in order to eliminate the risk that the user gets compilation
|
||||||
|
|
|
@ -2,22 +2,33 @@
|
||||||
This file is part of the GNU CHARSET Library.
|
This file is part of the GNU CHARSET Library.
|
||||||
|
|
||||||
The GNU CHARSET Library is free software; you can redistribute it and/or
|
The GNU CHARSET Library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public License as
|
modify it under the terms of the GNU Library General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the
|
published by the Free Software Foundation; either version 2 of the
|
||||||
License, or (at your option) any later version.
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
The GNU CHARSET Library is distributed in the hope that it will be useful,
|
The GNU CHARSET Library is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
Lesser General Public License for more details.
|
Library General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Library General Public License
|
||||||
along with the GNU CHARSET Library; see the file COPYING.LIB. If not,
|
along with the GNU CHARSET Library; see the file COPYING.LIB. If not,
|
||||||
see <https://www.gnu.org/licenses/>. */
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#ifndef _LIBCHARSET_H
|
#ifndef _LIBCHARSET_H
|
||||||
#define _LIBCHARSET_H
|
#define _LIBCHARSET_H
|
||||||
|
|
||||||
|
#ifdef LIBCHARSET_STATIC
|
||||||
|
#define LIBCHARSET_DLL_EXPORTED
|
||||||
|
#else /* LIBCHARSET_STATIC */
|
||||||
|
#ifdef BUILDING_LIBCHARSET
|
||||||
|
#define LIBCHARSET_DLL_EXPORTED __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define LIBCHARSET_DLL_EXPORTED __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
#endif /* LIBCHARSET_STATIC */
|
||||||
|
|
||||||
#include <localcharset.h>
|
#include <localcharset.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,7 +44,7 @@ extern "C" {
|
||||||
by the corresponding pathname with the current prefix instead. Both
|
by the corresponding pathname with the current prefix instead. Both
|
||||||
prefixes should be directory names without trailing slash (i.e. use ""
|
prefixes should be directory names without trailing slash (i.e. use ""
|
||||||
instead of "/"). */
|
instead of "/"). */
|
||||||
extern void libcharset_set_relocation_prefix (const char *orig_prefix,
|
extern LIBCHARSET_DLL_EXPORTED void libcharset_set_relocation_prefix (const char *orig_prefix,
|
||||||
const char *curr_prefix);
|
const char *curr_prefix);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,34 @@
|
||||||
/* Determine a canonical name for the current locale's character encoding.
|
/* Determine a canonical name for the current locale's character encoding.
|
||||||
Copyright (C) 2000-2003, 2009-2019 Free Software Foundation, Inc.
|
Copyright (C) 2000-2003 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU CHARSET Library.
|
This file is part of the GNU CHARSET Library.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it
|
This program is free software; you can redistribute it and/or modify it
|
||||||
under the terms of the GNU Lesser General Public License as published
|
under the terms of the GNU Library General Public License as published
|
||||||
by the Free Software Foundation; either version 2, or (at your option)
|
by the Free Software Foundation; either version 2, or (at your option)
|
||||||
any later version.
|
any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
Lesser General Public License for more details.
|
Library General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Library General Public
|
||||||
along with this program; if not, see <https://www.gnu.org/licenses/>. */
|
License along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
USA. */
|
||||||
|
|
||||||
#ifndef _LOCALCHARSET_H
|
#ifndef _LOCALCHARSET_H
|
||||||
#define _LOCALCHARSET_H
|
#define _LOCALCHARSET_H
|
||||||
|
|
||||||
|
#ifdef LIBCHARSET_STATIC
|
||||||
|
#define LIBCHARSET_DLL_EXPORTED
|
||||||
|
#else /* LIBCHARSET_STATIC */
|
||||||
|
#ifdef BUILDING_LIBCHARSET
|
||||||
|
#define LIBCHARSET_DLL_EXPORTED __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define LIBCHARSET_DLL_EXPORTED __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
#endif /* LIBCHARSET_STATIC */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -25,108 +36,11 @@ extern "C" {
|
||||||
|
|
||||||
|
|
||||||
/* Determine the current locale's character encoding, and canonicalize it
|
/* Determine the current locale's character encoding, and canonicalize it
|
||||||
into one of the canonical names listed below.
|
into one of the canonical names listed in config.charset.
|
||||||
The result must not be freed; it is statically allocated. The result
|
The result must not be freed; it is statically allocated.
|
||||||
becomes invalid when setlocale() is used to change the global locale, or
|
|
||||||
when the value of one of the environment variables LC_ALL, LC_CTYPE, LANG
|
|
||||||
is changed; threads in multithreaded programs should not do this.
|
|
||||||
If the canonical name cannot be determined, the result is a non-canonical
|
If the canonical name cannot be determined, the result is a non-canonical
|
||||||
name. */
|
name. */
|
||||||
extern const char * locale_charset (void);
|
extern LIBCHARSET_DLL_EXPORTED const char * locale_charset (void);
|
||||||
|
|
||||||
/* About GNU canonical names for character encodings:
|
|
||||||
|
|
||||||
Every canonical name must be supported by GNU libiconv. Support by GNU libc
|
|
||||||
is also desirable.
|
|
||||||
|
|
||||||
The name is case insensitive. Usually an upper case MIME charset name is
|
|
||||||
preferred.
|
|
||||||
|
|
||||||
The current list of these GNU canonical names is:
|
|
||||||
|
|
||||||
name MIME? used by which systems
|
|
||||||
(darwin = Mac OS X, windows = native Windows)
|
|
||||||
|
|
||||||
ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin minix cygwin
|
|
||||||
ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
|
|
||||||
ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
|
|
||||||
ISO-8859-3 Y glibc solaris cygwin
|
|
||||||
ISO-8859-4 Y hpux osf solaris freebsd netbsd openbsd darwin
|
|
||||||
ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
|
|
||||||
ISO-8859-6 Y glibc aix hpux solaris cygwin
|
|
||||||
ISO-8859-7 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
|
|
||||||
ISO-8859-8 Y glibc aix hpux osf solaris cygwin zos
|
|
||||||
ISO-8859-9 Y glibc aix hpux irix osf solaris freebsd darwin cygwin zos
|
|
||||||
ISO-8859-13 glibc hpux solaris freebsd netbsd openbsd darwin cygwin
|
|
||||||
ISO-8859-14 glibc cygwin
|
|
||||||
ISO-8859-15 glibc aix irix osf solaris freebsd netbsd openbsd darwin cygwin
|
|
||||||
KOI8-R Y glibc hpux solaris freebsd netbsd openbsd darwin
|
|
||||||
KOI8-U Y glibc freebsd netbsd openbsd darwin cygwin
|
|
||||||
KOI8-T glibc
|
|
||||||
CP437 dos
|
|
||||||
CP775 dos
|
|
||||||
CP850 aix osf dos
|
|
||||||
CP852 dos
|
|
||||||
CP855 dos
|
|
||||||
CP856 aix
|
|
||||||
CP857 dos
|
|
||||||
CP861 dos
|
|
||||||
CP862 dos
|
|
||||||
CP864 dos
|
|
||||||
CP865 dos
|
|
||||||
CP866 freebsd netbsd openbsd darwin dos
|
|
||||||
CP869 dos
|
|
||||||
CP874 windows dos
|
|
||||||
CP922 aix
|
|
||||||
CP932 aix cygwin windows dos
|
|
||||||
CP943 aix zos
|
|
||||||
CP949 osf darwin windows dos
|
|
||||||
CP950 windows dos
|
|
||||||
CP1046 aix
|
|
||||||
CP1124 aix
|
|
||||||
CP1125 dos
|
|
||||||
CP1129 aix
|
|
||||||
CP1131 freebsd darwin
|
|
||||||
CP1250 windows
|
|
||||||
CP1251 glibc hpux solaris freebsd netbsd openbsd darwin cygwin windows
|
|
||||||
CP1252 aix windows
|
|
||||||
CP1253 windows
|
|
||||||
CP1254 windows
|
|
||||||
CP1255 glibc windows
|
|
||||||
CP1256 windows
|
|
||||||
CP1257 windows
|
|
||||||
GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin cygwin zos
|
|
||||||
EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin
|
|
||||||
EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin zos
|
|
||||||
EUC-TW glibc aix hpux irix osf solaris netbsd
|
|
||||||
BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin cygwin zos
|
|
||||||
BIG5-HKSCS glibc hpux solaris netbsd darwin
|
|
||||||
GBK glibc aix osf solaris freebsd darwin cygwin windows dos
|
|
||||||
GB18030 glibc hpux solaris freebsd netbsd darwin
|
|
||||||
SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin
|
|
||||||
JOHAB glibc solaris windows
|
|
||||||
TIS-620 glibc aix hpux osf solaris cygwin zos
|
|
||||||
VISCII Y glibc
|
|
||||||
TCVN5712-1 glibc
|
|
||||||
ARMSCII-8 glibc freebsd netbsd darwin
|
|
||||||
GEORGIAN-PS glibc cygwin
|
|
||||||
PT154 glibc netbsd cygwin
|
|
||||||
HP-ROMAN8 hpux
|
|
||||||
HP-ARABIC8 hpux
|
|
||||||
HP-GREEK8 hpux
|
|
||||||
HP-HEBREW8 hpux
|
|
||||||
HP-TURKISH8 hpux
|
|
||||||
HP-KANA8 hpux
|
|
||||||
DEC-KANJI osf
|
|
||||||
DEC-HANYU osf
|
|
||||||
UTF-8 Y glibc aix hpux osf solaris netbsd darwin cygwin zos
|
|
||||||
|
|
||||||
Note: Names which are not marked as being a MIME name should not be used in
|
|
||||||
Internet protocols for information interchange (mail, news, etc.).
|
|
||||||
|
|
||||||
Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications
|
|
||||||
must understand both names and treat them as equivalent.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -1,32 +1,41 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
*
|
||||||
The MySQL Connector/C++ is licensed under the terms of the GPLv2
|
* This program is free software; you can redistribute it and/or modify
|
||||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
* it under the terms of the GNU General Public License, version 2.0, as
|
||||||
MySQL Connectors. There are special exceptions to the terms and
|
* published by the Free Software Foundation.
|
||||||
conditions of the GPLv2 as it is applied to this software, see the
|
*
|
||||||
FLOSS License Exception
|
* This program is also distributed with certain software (including
|
||||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
* but not limited to OpenSSL) that is licensed under separate terms,
|
||||||
|
* as designated in a particular file or component or in included license
|
||||||
This program is free software; you can redistribute it and/or modify
|
* documentation. The authors of MySQL hereby grant you an
|
||||||
it under the terms of the GNU General Public License as published
|
* additional permission to link the program and your derivative works
|
||||||
by the Free Software Foundation; version 2 of the License.
|
* with the separately licensed software that they have included with
|
||||||
|
* MySQL.
|
||||||
This program is distributed in the hope that it will be useful, but
|
*
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* Without limiting anything contained in the foregoing, this file,
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
* which is part of MySQL Connector/C++, is also subject to the
|
||||||
for more details.
|
* Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||||
|
* http://oss.oracle.com/licenses/universal-foss-exception.
|
||||||
You should have received a copy of the GNU General Public License along
|
*
|
||||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
* This program is distributed in the hope that it will be useful, but
|
||||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License, version 2.0, for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _MYSQL_CONNECTION_H_
|
#ifndef _MYSQL_CONNECTION_H_
|
||||||
#define _MYSQL_CONNECTION_H_
|
#define _MYSQL_CONNECTION_H_
|
||||||
|
|
||||||
#include <cppconn/connection.h>
|
#include <cppconn/connection.h>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
|
||||||
namespace sql
|
namespace sql
|
||||||
{
|
{
|
||||||
|
@ -53,7 +62,8 @@ private:
|
||||||
|
|
||||||
|
|
||||||
class MySQL_DebugLogger;
|
class MySQL_DebugLogger;
|
||||||
class MySQL_ConnectionData; /* PIMPL */
|
struct MySQL_ConnectionData; /* PIMPL */
|
||||||
|
class MySQL_Statement;
|
||||||
|
|
||||||
namespace NativeAPI
|
namespace NativeAPI
|
||||||
{
|
{
|
||||||
|
@ -62,6 +72,8 @@ class NativeConnectionWrapper;
|
||||||
|
|
||||||
class CPPCONN_PUBLIC_FUNC MySQL_Connection : public sql::Connection
|
class CPPCONN_PUBLIC_FUNC MySQL_Connection : public sql::Connection
|
||||||
{
|
{
|
||||||
|
MySQL_Statement * createServiceStmt();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MySQL_Connection(Driver * _driver,
|
MySQL_Connection(Driver * _driver,
|
||||||
::sql::mysql::NativeAPI::NativeConnectionWrapper & _proxy,
|
::sql::mysql::NativeAPI::NativeConnectionWrapper & _proxy,
|
||||||
|
@ -96,6 +108,8 @@ public:
|
||||||
|
|
||||||
void getClientOption(const sql::SQLString & optionName, void * optionValue);
|
void getClientOption(const sql::SQLString & optionName, void * optionValue);
|
||||||
|
|
||||||
|
sql::SQLString getClientOption(const sql::SQLString & optionName);
|
||||||
|
|
||||||
sql::DatabaseMetaData * getMetaData();
|
sql::DatabaseMetaData * getMetaData();
|
||||||
|
|
||||||
enum_transaction_isolation getTransactionIsolation();
|
enum_transaction_isolation getTransactionIsolation();
|
||||||
|
@ -106,6 +120,10 @@ public:
|
||||||
|
|
||||||
bool isReadOnly();
|
bool isReadOnly();
|
||||||
|
|
||||||
|
bool isValid();
|
||||||
|
|
||||||
|
bool reconnect();
|
||||||
|
|
||||||
sql::SQLString nativeSQL(const sql::SQLString& sql);
|
sql::SQLString nativeSQL(const sql::SQLString& sql);
|
||||||
|
|
||||||
sql::PreparedStatement * prepareStatement(const sql::SQLString& sql);
|
sql::PreparedStatement * prepareStatement(const sql::SQLString& sql);
|
||||||
|
@ -134,6 +152,8 @@ public:
|
||||||
|
|
||||||
sql::Connection * setClientOption(const sql::SQLString & optionName, const void * optionValue);
|
sql::Connection * setClientOption(const sql::SQLString & optionName, const void * optionValue);
|
||||||
|
|
||||||
|
sql::Connection * setClientOption(const sql::SQLString & optionName, const sql::SQLString & optionValue);
|
||||||
|
|
||||||
void setHoldability(int holdability);
|
void setHoldability(int holdability);
|
||||||
|
|
||||||
void setReadOnly(bool readOnly);
|
void setReadOnly(bool readOnly);
|
||||||
|
@ -144,20 +164,28 @@ public:
|
||||||
|
|
||||||
void setTransactionIsolation(enum_transaction_isolation level);
|
void setTransactionIsolation(enum_transaction_isolation level);
|
||||||
|
|
||||||
sql::SQLString getSessionVariable(const sql::SQLString & varname);
|
virtual sql::SQLString getSessionVariable(const sql::SQLString & varname);
|
||||||
|
|
||||||
void setSessionVariable(const sql::SQLString & varname, const sql::SQLString & value);
|
virtual void setSessionVariable(const sql::SQLString & varname, const sql::SQLString & value);
|
||||||
|
|
||||||
protected:
|
virtual void setSessionVariable(const sql::SQLString & varname, unsigned int value);
|
||||||
|
|
||||||
|
virtual sql::SQLString getLastStatementInfo();
|
||||||
|
|
||||||
|
private:
|
||||||
|
/* We do not really think this class has to be subclassed*/
|
||||||
void checkClosed();
|
void checkClosed();
|
||||||
void init(std::map< sql::SQLString, sql::ConnectPropertyVal > & properties);
|
void init(std::map< sql::SQLString, sql::ConnectPropertyVal > & properties);
|
||||||
|
|
||||||
Driver * driver;
|
Driver * driver;
|
||||||
boost::shared_ptr< NativeAPI::NativeConnectionWrapper > proxy;
|
boost::shared_ptr< NativeAPI::NativeConnectionWrapper > proxy;
|
||||||
|
|
||||||
MySQL_ConnectionData * intern; /* pimpl */
|
/* statement handle to execute queries initiated by driver. Perhaps it is
|
||||||
|
a good idea to move it to a separate helper class */
|
||||||
|
boost::scoped_ptr< ::sql::mysql::MySQL_Statement > service;
|
||||||
|
|
||||||
|
boost::scoped_ptr< ::sql::mysql::MySQL_ConnectionData > intern; /* pimpl */
|
||||||
|
|
||||||
private:
|
|
||||||
/* Prevent use of these */
|
/* Prevent use of these */
|
||||||
MySQL_Connection(const MySQL_Connection &);
|
MySQL_Connection(const MySQL_Connection &);
|
||||||
void operator=(MySQL_Connection &);
|
void operator=(MySQL_Connection &);
|
||||||
|
|
|
@ -1,27 +1,35 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
*
|
||||||
The MySQL Connector/C++ is licensed under the terms of the GPLv2
|
* This program is free software; you can redistribute it and/or modify
|
||||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
* it under the terms of the GNU General Public License, version 2.0, as
|
||||||
MySQL Connectors. There are special exceptions to the terms and
|
* published by the Free Software Foundation.
|
||||||
conditions of the GPLv2 as it is applied to this software, see the
|
*
|
||||||
FLOSS License Exception
|
* This program is also distributed with certain software (including
|
||||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
* but not limited to OpenSSL) that is licensed under separate terms,
|
||||||
|
* as designated in a particular file or component or in included license
|
||||||
This program is free software; you can redistribute it and/or modify
|
* documentation. The authors of MySQL hereby grant you an
|
||||||
it under the terms of the GNU General Public License as published
|
* additional permission to link the program and your derivative works
|
||||||
by the Free Software Foundation; version 2 of the License.
|
* with the separately licensed software that they have included with
|
||||||
|
* MySQL.
|
||||||
This program is distributed in the hope that it will be useful, but
|
*
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* Without limiting anything contained in the foregoing, this file,
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
* which is part of MySQL Connector/C++, is also subject to the
|
||||||
for more details.
|
* Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||||
|
* http://oss.oracle.com/licenses/universal-foss-exception.
|
||||||
You should have received a copy of the GNU General Public License along
|
*
|
||||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
* This program is distributed in the hope that it will be useful, but
|
||||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License, version 2.0, for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _MYSQL_DRIVER_H_
|
#ifndef _MYSQL_DRIVER_H_
|
||||||
#define _MYSQL_DRIVER_H_
|
#define _MYSQL_DRIVER_H_
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
#ifndef ZCONF_H
|
#ifndef ZCONF_H
|
||||||
#define ZCONF_H
|
#define ZCONF_H
|
||||||
|
/* #undef Z_PREFIX */
|
||||||
|
/* #undef Z_HAVE_UNISTD_H */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If you *really* need a unique prefix for all types and library functions,
|
* If you *really* need a unique prefix for all types and library functions,
|
||||||
|
@ -433,11 +435,11 @@ typedef uLong FAR uLongf;
|
||||||
typedef unsigned long z_crc_t;
|
typedef unsigned long z_crc_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 1 /* was set to #if 1 by ./configure */
|
#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
|
||||||
# define Z_HAVE_UNISTD_H
|
# define Z_HAVE_UNISTD_H
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 1 /* was set to #if 1 by ./configure */
|
#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */
|
||||||
# define Z_HAVE_STDARG_H
|
# define Z_HAVE_STDARG_H
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue