summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-12-02 13:36:23 +0100
committerStephan Bergmann <sbergman@redhat.com>2019-12-02 17:48:06 +0100
commit5da0f455a63ea22b500943d7ff4c28fbb7a90cfb (patch)
treec432ab2a06450a2bb5185b3d73c34db6730ad601
parentd23c52cbf7e48130fec1e48bf726c563035a3497 (diff)
Simplify SQLError::ParamValue to just o3tl::optional<OUString>
Change-Id: Ib4878218fd758c6462de1841fb98b3ae8839d1ed Reviewed-on: https://gerrit.libreoffice.org/84217 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r--connectivity/source/commontools/sqlerror.cxx45
-rw-r--r--include/connectivity/sqlerror.hxx12
2 files changed, 25 insertions, 32 deletions
diff --git a/connectivity/source/commontools/sqlerror.cxx b/connectivity/source/commontools/sqlerror.cxx
index 11d672929094..88758dd1b531 100644
--- a/connectivity/source/commontools/sqlerror.cxx
+++ b/connectivity/source/commontools/sqlerror.cxx
@@ -44,13 +44,6 @@ namespace connectivity
using ::com::sun::star::sdbc::SQLException;
using ::com::sun::star::uno::Type;
- //using SQLError::ParamValue; // GCC (unxlngi6) does not like this
- namespace
- {
- typedef SQLError::ParamValue ParamValue;
- }
-
-
class SQLError_Impl
{
public:
@@ -58,12 +51,12 @@ namespace connectivity
// versions of the public SQLError methods which are just delegated to this impl-class
static const OUString& getMessagePrefix();
- OUString getErrorMessage( const ErrorCondition _eCondition, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 );
+ OUString getErrorMessage( const ErrorCondition _eCondition, const o3tl::optional<OUString>& _rParamValue1, const o3tl::optional<OUString>& _rParamValue2, const o3tl::optional<OUString>& _rParamValue3 );
static ErrorCode getErrorCode( const ErrorCondition _eCondition );
- void raiseException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 );
- void raiseException( const ErrorCondition _eCondition, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 );
- void raiseTypedException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext, const Type& _rExceptionType, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 );
- SQLException getSQLException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 );
+ void raiseException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext, const o3tl::optional<OUString>& _rParamValue1, const o3tl::optional<OUString>& _rParamValue2, const o3tl::optional<OUString>& _rParamValue3 );
+ void raiseException( const ErrorCondition _eCondition, const o3tl::optional<OUString>& _rParamValue1, const o3tl::optional<OUString>& _rParamValue2, const o3tl::optional<OUString>& _rParamValue3 );
+ void raiseTypedException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext, const Type& _rExceptionType, const o3tl::optional<OUString>& _rParamValue1, const o3tl::optional<OUString>& _rParamValue2, const o3tl::optional<OUString>& _rParamValue3 );
+ SQLException getSQLException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext, const o3tl::optional<OUString>& _rParamValue1, const o3tl::optional<OUString>& _rParamValue2, const o3tl::optional<OUString>& _rParamValue3 );
private:
/// returns the basic error message associated with the given error condition, without any parameter replacements
@@ -77,7 +70,7 @@ namespace connectivity
/// returns an SQLException describing the given error condition
SQLException
impl_buildSQLException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext,
- const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 );
+ const o3tl::optional<OUString>& _rParamValue1, const o3tl::optional<OUString>& _rParamValue2, const o3tl::optional<OUString>& _rParamValue3 );
private:
std::locale m_aResources;
};
@@ -98,13 +91,13 @@ namespace connectivity
/** substitutes a given placeholder in the given message with the given value
*/
- void lcl_substitutePlaceholder(OUString& _rMessage, const sal_Char* _pPlaceholder, const ParamValue& rParamValue)
+ void lcl_substitutePlaceholder(OUString& _rMessage, const sal_Char* _pPlaceholder, const o3tl::optional<OUString>& rParamValue)
{
size_t nPlaceholderLen( strlen( _pPlaceholder ) );
sal_Int32 nIndex = _rMessage.indexOfAsciiL( _pPlaceholder, nPlaceholderLen );
bool bHasPlaceholder = ( nIndex != -1 );
- bool bWantsPlaceholder = rParamValue.is();
+ bool bWantsPlaceholder = rParamValue.has_value();
OSL_ENSURE( bHasPlaceholder == bWantsPlaceholder, "lcl_substitutePlaceholder: placeholder where none is expected, or no placeholder where one is needed!" );
if ( bHasPlaceholder && bWantsPlaceholder )
@@ -150,7 +143,7 @@ namespace connectivity
}
}
- OUString SQLError_Impl::getErrorMessage( const ErrorCondition _eCondition, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 )
+ OUString SQLError_Impl::getErrorMessage( const ErrorCondition _eCondition, const o3tl::optional<OUString>& _rParamValue1, const o3tl::optional<OUString>& _rParamValue2, const o3tl::optional<OUString>& _rParamValue3 )
{
OUString sErrorMessage( impl_getErrorMessage( _eCondition ) );
@@ -168,7 +161,7 @@ namespace connectivity
}
- void SQLError_Impl::raiseException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 )
+ void SQLError_Impl::raiseException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext, const o3tl::optional<OUString>& _rParamValue1, const o3tl::optional<OUString>& _rParamValue2, const o3tl::optional<OUString>& _rParamValue3 )
{
raiseTypedException(
_eCondition,
@@ -181,7 +174,7 @@ namespace connectivity
}
- void SQLError_Impl::raiseException( const ErrorCondition _eCondition, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 )
+ void SQLError_Impl::raiseException( const ErrorCondition _eCondition, const o3tl::optional<OUString>& _rParamValue1, const o3tl::optional<OUString>& _rParamValue2, const o3tl::optional<OUString>& _rParamValue3 )
{
raiseTypedException(
_eCondition,
@@ -194,7 +187,7 @@ namespace connectivity
}
void SQLError_Impl::raiseTypedException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext,
- const Type& _rExceptionType, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 )
+ const Type& _rExceptionType, const o3tl::optional<OUString>& _rParamValue1, const o3tl::optional<OUString>& _rParamValue2, const o3tl::optional<OUString>& _rParamValue3 )
{
if ( !::cppu::UnoType< SQLException >::get().isAssignableFrom( _rExceptionType ) )
throw std::bad_cast();
@@ -211,13 +204,13 @@ namespace connectivity
}
SQLException SQLError_Impl::getSQLException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext,
- const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 )
+ const o3tl::optional<OUString>& _rParamValue1, const o3tl::optional<OUString>& _rParamValue2, const o3tl::optional<OUString>& _rParamValue3 )
{
return impl_buildSQLException( _eCondition, _rxContext, _rParamValue1, _rParamValue2, _rParamValue3 );
}
SQLException SQLError_Impl::impl_buildSQLException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext,
- const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 )
+ const o3tl::optional<OUString>& _rParamValue1, const o3tl::optional<OUString>& _rParamValue2, const o3tl::optional<OUString>& _rParamValue3 )
{
return SQLException(
getErrorMessage( _eCondition, _rParamValue1, _rParamValue2, _rParamValue3 ),
@@ -266,7 +259,7 @@ namespace connectivity
OUString SQLError::getErrorMessage( const ErrorCondition _eCondition ) const
{
- return m_pImpl->getErrorMessage( _eCondition, ParamValue(), ParamValue(), ParamValue() );
+ return m_pImpl->getErrorMessage( _eCondition, o3tl::optional<OUString>(), o3tl::optional<OUString>(), o3tl::optional<OUString>() );
}
@@ -276,7 +269,7 @@ namespace connectivity
}
- void SQLError::raiseException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 ) const
+ void SQLError::raiseException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext, const o3tl::optional<OUString>& _rParamValue1, const o3tl::optional<OUString>& _rParamValue2, const o3tl::optional<OUString>& _rParamValue3 ) const
{
m_pImpl->raiseException( _eCondition, _rxContext, _rParamValue1, _rParamValue2, _rParamValue3 );
}
@@ -284,19 +277,19 @@ namespace connectivity
void SQLError::raiseException( const ErrorCondition _eCondition ) const
{
- m_pImpl->raiseException( _eCondition, ParamValue(), ParamValue(), ParamValue() );
+ m_pImpl->raiseException( _eCondition, o3tl::optional<OUString>(), o3tl::optional<OUString>(), o3tl::optional<OUString>() );
}
void SQLError::raiseTypedException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext,
const Type& _rExceptionType ) const
{
- m_pImpl->raiseTypedException( _eCondition, _rxContext, _rExceptionType, ParamValue(), ParamValue(), ParamValue() );
+ m_pImpl->raiseTypedException( _eCondition, _rxContext, _rExceptionType, o3tl::optional<OUString>(), o3tl::optional<OUString>(), o3tl::optional<OUString>() );
}
SQLException SQLError::getSQLException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext,
- const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 ) const
+ const o3tl::optional<OUString>& _rParamValue1, const o3tl::optional<OUString>& _rParamValue2, const o3tl::optional<OUString>& _rParamValue3 ) const
{
return m_pImpl->getSQLException( _eCondition, _rxContext, _rParamValue1, _rParamValue2, _rParamValue3 );
}
diff --git a/include/connectivity/sqlerror.hxx b/include/connectivity/sqlerror.hxx
index 9b75657290f4..db0f3824ab77 100644
--- a/include/connectivity/sqlerror.hxx
+++ b/include/connectivity/sqlerror.hxx
@@ -157,9 +157,9 @@ namespace connectivity
void raiseException(
const ErrorCondition _eCondition,
const css::uno::Reference< css::uno::XInterface >& _rxContext,
- const ParamValue& _rParamValue1 = ParamValue(),
- const ParamValue& _rParamValue2 = ParamValue(),
- const ParamValue& _rParamValue3 = ParamValue()
+ const o3tl::optional<OUString>& _rParamValue1 = o3tl::nullopt,
+ const o3tl::optional<OUString>& _rParamValue2 = o3tl::nullopt,
+ const o3tl::optional<OUString>& _rParamValue3 = o3tl::nullopt
) const;
/** throws an SQLException describing the given error condition
@@ -240,9 +240,9 @@ namespace connectivity
getSQLException(
const ErrorCondition _eCondition,
const css::uno::Reference< css::uno::XInterface >& _rxContext,
- const ParamValue& _rParamValue1 = ParamValue(),
- const ParamValue& _rParamValue2 = ParamValue(),
- const ParamValue& _rParamValue3 = ParamValue()
+ const o3tl::optional<OUString>& _rParamValue1 = o3tl::nullopt,
+ const o3tl::optional<OUString>& _rParamValue2 = o3tl::nullopt,
+ const o3tl::optional<OUString>& _rParamValue3 = o3tl::nullopt
) const;
private: