Simplify down to a single appendSQLWCHARs function

Change-Id: I882746f9c4a1c332c6657b93f104ecbf1c7be6f1
This commit is contained in:
Stephan Bergmann
2015-11-17 13:33:44 +01:00
parent 9579e458a5
commit 618463a450
5 changed files with 14 additions and 72 deletions

View File

@@ -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 \

View File

@@ -24,8 +24,6 @@
#include "odbc/OConnection.hxx"
#include <rtl/ustrbuf.hxx>
#include <appendsqlwchars.hxx>
#include <string.h>
#include <string>
#include <algorithm>
@@ -107,6 +105,20 @@ size_t sqlTypeLen ( SQLSMALLINT _nType )
return static_cast<size_t>(-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<sal_Unicode const *>(d), n);
} else {
for (sal_Int32 i = 0; i != n; ++i) {
s.appendUtf32(d[i]);
}
}
}
}

View File

@@ -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 <sal/config.h>
#include <rtl/ustrbuf.hxx>
#include <sal/types.h>
#include <appendsqlwchars.hxx>
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: */

View File

@@ -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 <sal/config.h>
#include <rtl/ustrbuf.hxx>
#include <sal/types.h>
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: */

View File

@@ -75,7 +75,6 @@ comphelper::detail::ConfigurationWrapper::getGroupReadWrite(std::shared_ptr<comp
comphelper::detail::ConfigurationWrapper::getLocalizedPropertyValue(rtl::OUString const&) const
comphelper::detail::ConfigurationWrapper::setLocalizedPropertyValue(std::shared_ptr<comphelper::ConfigurationChanges> const&, rtl::OUString const&, com::sun::star::uno::Any const&)
connectivity::firebird::release(int&, cppu::OBroadcastHelperVar<cppu::OMultiTypeInterfaceContainerHelper, com::sun::star::uno::Type>&, com::sun::star::uno::Reference<com::sun::star::uno::XInterface>&, com::sun::star::lang::XComponent*)
connectivity::odbc::appendSQLWCHARs(rtl::OUStringBuffer&, wchar_t const*, int)
connectivity::sdbcx::OGroup::OGroup(bool)
connectivity::sdbcx::OGroup::OGroup(rtl::OUString const&, bool)
dbaccess::OBookmarkContainer::dispose()