diff options
Diffstat (limited to 'connectivity/source/drivers/mysql_jdbc/YDriver.cxx')
-rw-r--r-- | connectivity/source/drivers/mysql_jdbc/YDriver.cxx | 63 |
1 files changed, 28 insertions, 35 deletions
diff --git a/connectivity/source/drivers/mysql_jdbc/YDriver.cxx b/connectivity/source/drivers/mysql_jdbc/YDriver.cxx index 7ee501d42e81..e4e338ee0b31 100644 --- a/connectivity/source/drivers/mysql_jdbc/YDriver.cxx +++ b/connectivity/source/drivers/mysql_jdbc/YDriver.cxx @@ -49,8 +49,8 @@ namespace { OUString getJavaDriverClass(css::uno::Sequence<css::beans::PropertyValue> const& info) { - return comphelper::NamedValueCollection(info).getOrDefault("JavaDriverClass", - OUString("com.mysql.jdbc.Driver")); + return comphelper::NamedValueCollection::getOrDefault(info, u"JavaDriverClass", + OUString("com.mysql.jdbc.Driver")); } } @@ -115,9 +115,9 @@ T_DRIVERTYPE lcl_getDriverType(std::u16string_view _sUrl) return eRet; } -OUString transformUrl(const OUString& _sUrl) +OUString transformUrl(std::u16string_view _sUrl) { - OUString sNewUrl = _sUrl.copy(11); + OUString sNewUrl(_sUrl.substr(11)); if (isOdbcUrl(_sUrl)) sNewUrl = "sdbc:" + sNewUrl; else if (isNativeUrl(_sUrl)) @@ -158,36 +158,30 @@ Sequence<PropertyValue> lcl_convertProperties(T_DRIVERTYPE _eType, if (_eType == T_DRIVERTYPE::Odbc) { - aProps.push_back(PropertyValue("Silent", 0, makeAny(true), PropertyState_DIRECT_VALUE)); - aProps.push_back(PropertyValue("PreventGetVersionColumns", 0, makeAny(true), - PropertyState_DIRECT_VALUE)); + aProps.emplace_back("Silent", 0, Any(true), PropertyState_DIRECT_VALUE); + aProps.emplace_back("PreventGetVersionColumns", 0, Any(true), PropertyState_DIRECT_VALUE); } else if (_eType == T_DRIVERTYPE::Jdbc) { if (!jdc) { - aProps.push_back(PropertyValue("JavaDriverClass", 0, - makeAny(OUString("com.mysql.jdbc.Driver")), - PropertyState_DIRECT_VALUE)); + aProps.emplace_back("JavaDriverClass", 0, Any(OUString("com.mysql.jdbc.Driver")), + PropertyState_DIRECT_VALUE); } } else { - aProps.push_back( - PropertyValue("PublicConnectionURL", 0, makeAny(_sUrl), PropertyState_DIRECT_VALUE)); + aProps.emplace_back("PublicConnectionURL", 0, Any(_sUrl), PropertyState_DIRECT_VALUE); } - aProps.push_back( - PropertyValue("IsAutoRetrievingEnabled", 0, makeAny(true), PropertyState_DIRECT_VALUE)); - aProps.push_back(PropertyValue("AutoRetrievingStatement", 0, - makeAny(OUString("SELECT LAST_INSERT_ID()")), - PropertyState_DIRECT_VALUE)); - aProps.push_back( - PropertyValue("ParameterNameSubstitution", 0, makeAny(true), PropertyState_DIRECT_VALUE)); + aProps.emplace_back("IsAutoRetrievingEnabled", 0, Any(true), PropertyState_DIRECT_VALUE); + aProps.emplace_back("AutoRetrievingStatement", 0, Any(OUString("SELECT LAST_INSERT_ID()")), + PropertyState_DIRECT_VALUE); + aProps.emplace_back("ParameterNameSubstitution", 0, Any(true), PropertyState_DIRECT_VALUE); return Sequence<PropertyValue>(aProps.data(), aProps.size()); } } -Reference<XDriver> ODriverDelegator::loadDriver(const OUString& url, +Reference<XDriver> ODriverDelegator::loadDriver(std::u16string_view url, const Sequence<PropertyValue>& info) { Reference<XDriver> xDriver; @@ -232,8 +226,8 @@ Reference<XConnection> SAL_CALL ODriverDelegator::connect(const OUString& url, Sequence<PropertyValue> aConvertedProperties = lcl_convertProperties(eType, info, url); if (eType == T_DRIVERTYPE::Jdbc) { - ::comphelper::NamedValueCollection aSettings(info); - OUString sIanaName = aSettings.getOrDefault("CharSet", OUString()); + OUString sIanaName = ::comphelper::NamedValueCollection::getOrDefault( + info, u"CharSet", OUString()); if (!sIanaName.isEmpty()) { ::dbtools::OCharsetMap aLookupIanaName; @@ -244,7 +238,7 @@ Reference<XConnection> SAL_CALL ODriverDelegator::connect(const OUString& url, OUString sAdd; if (RTL_TEXTENCODING_UTF8 == (*aLookup).getEncoding()) { - static constexpr OUStringLiteral s_sCharSetOp = u"useUnicode=true&"; + static constexpr OUString s_sCharSetOp = u"useUnicode=true&"_ustr; if (!sCuttedUrl.matchIgnoreAsciiCase(s_sCharSetOp)) { sAdd = s_sCharSetOp; @@ -266,9 +260,9 @@ Reference<XConnection> SAL_CALL ODriverDelegator::connect(const OUString& url, auto pMetaConnection = comphelper::getFromUnoTunnel<OMetaConnection>(xConnection); if (pMetaConnection) pMetaConnection->setURL(url); - m_aConnections.push_back( - TWeakPair(WeakReferenceHelper(xConnection), - TWeakConnectionPair(WeakReferenceHelper(), pMetaConnection))); + m_aConnections.emplace_back( + WeakReferenceHelper(xConnection), + TWeakConnectionPair(WeakReferenceHelper(), pMetaConnection)); } } } @@ -300,18 +294,17 @@ ODriverDelegator::getPropertyInfo(const OUString& url, const Sequence<PropertyVa const T_DRIVERTYPE eType = lcl_getDriverType(url); if (eType == T_DRIVERTYPE::Jdbc) { - aDriverInfo.push_back(DriverPropertyInfo("JavaDriverClass", "The JDBC driver class name.", - true, getJavaDriverClass(info), - Sequence<OUString>())); + aDriverInfo.emplace_back("JavaDriverClass", "The JDBC driver class name.", true, + getJavaDriverClass(info), Sequence<OUString>()); } else if (eType == T_DRIVERTYPE::Native) { - aDriverInfo.push_back(DriverPropertyInfo( - "LocalSocket", "The file path of a socket to connect to a local MySQL server.", false, - OUString(), Sequence<OUString>())); - aDriverInfo.push_back(DriverPropertyInfo( - "NamedPipe", "The name of a pipe to connect to a local MySQL server.", false, - OUString(), Sequence<OUString>())); + aDriverInfo.emplace_back("LocalSocket", + "The file path of a socket to connect to a local MySQL server.", + false, OUString(), Sequence<OUString>()); + aDriverInfo.emplace_back("NamedPipe", + "The name of a pipe to connect to a local MySQL server.", false, + OUString(), Sequence<OUString>()); } return Sequence<DriverPropertyInfo>(aDriverInfo.data(), aDriverInfo.size()); |