From 618463a450fe5bd318dc1bb552980f090ae3caef Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 17 Nov 2015 13:33:44 +0100 Subject: Simplify down to a single appendSQLWCHARs function Change-Id: I882746f9c4a1c332c6657b93f104ecbf1c7be6f1 --- connectivity/Library_odbc.mk | 1 - connectivity/source/drivers/odbc/OTools.cxx | 16 +++++++-- .../source/drivers/odbc/appendsqlwchars.cxx | 38 ---------------------- .../source/drivers/odbc/appendsqlwchars.hxx | 30 ----------------- 4 files changed, 14 insertions(+), 71 deletions(-) delete mode 100644 connectivity/source/drivers/odbc/appendsqlwchars.cxx delete mode 100644 connectivity/source/drivers/odbc/appendsqlwchars.hxx (limited to 'connectivity') diff --git a/connectivity/Library_odbc.mk b/connectivity/Library_odbc.mk index 8ff5fd0daaed..181114ad3be5 100644 --- a/connectivity/Library_odbc.mk +++ b/connectivity/Library_odbc.mk @@ -45,7 +45,6 @@ $(eval $(call gb_Library_use_libraries,odbc,\ )) $(eval $(call gb_Library_add_exception_objects,odbc,\ - connectivity/source/drivers/odbc/appendsqlwchars \ connectivity/source/drivers/odbc/oservices \ connectivity/source/drivers/odbc/ORealDriver \ connectivity/source/drivers/odbc/OFunctions \ diff --git a/connectivity/source/drivers/odbc/OTools.cxx b/connectivity/source/drivers/odbc/OTools.cxx index 695d162b7761..06d11c63145f 100644 --- a/connectivity/source/drivers/odbc/OTools.cxx +++ b/connectivity/source/drivers/odbc/OTools.cxx @@ -24,8 +24,6 @@ #include "odbc/OConnection.hxx" #include -#include - #include #include #include @@ -107,6 +105,20 @@ size_t sqlTypeLen ( SQLSMALLINT _nType ) return static_cast(-1); } } + +void appendSQLWCHARs(OUStringBuffer & s, SQLWCHAR const * d, sal_Int32 n) +{ + static_assert( + sizeof (SQLWCHAR) == sizeof (sal_Unicode) || sizeof (SQLWCHAR) == 4, + "bad SQLWCHAR"); + if (sizeof (SQLWCHAR) == sizeof (sal_Unicode)) { + s.append(reinterpret_cast(d), n); + } else { + for (sal_Int32 i = 0; i != n; ++i) { + s.appendUtf32(d[i]); + } + } +} } diff --git a/connectivity/source/drivers/odbc/appendsqlwchars.cxx b/connectivity/source/drivers/odbc/appendsqlwchars.cxx deleted file mode 100644 index 544573861cd8..000000000000 --- a/connectivity/source/drivers/odbc/appendsqlwchars.cxx +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#include - -#include -#include - -#include - -namespace connectivity { namespace odbc { - -void appendSQLWCHARs(OUStringBuffer & s, const sal_Unicode* d, sal_Int32 n) -{ - s.append(d, n); -} - -#if defined SAL_UNICODE_NOTEQUAL_WCHAR_T -static_assert(sizeof (wchar_t) == 4, "sizeof wchar_t must be 4 for this to work"); -void appendSQLWCHARs(OUStringBuffer & s, const wchar_t* d, sal_Int32 n) -{ - const wchar_t * const end = d + n; - for (; d < end; ++d) - { - s.appendUtf32(*d); - } -} -#endif - -} } - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/odbc/appendsqlwchars.hxx b/connectivity/source/drivers/odbc/appendsqlwchars.hxx deleted file mode 100644 index b1424d1643a5..000000000000 --- a/connectivity/source/drivers/odbc/appendsqlwchars.hxx +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_ODBC_APPENDSQLWCHARS_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_ODBC_APPENDSQLWCHARS_HXX - -#include - -#include -#include - -namespace connectivity { namespace odbc { - -void appendSQLWCHARs(OUStringBuffer & s, const sal_Unicode* d, sal_Int32 n); - -#if defined SAL_UNICODE_NOTEQUAL_WCHAR_T -void appendSQLWCHARs(OUStringBuffer & s, const wchar_t* d, sal_Int32 n); -#endif - -} } - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit