summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/file
diff options
context:
space:
mode:
Diffstat (limited to 'connectivity/source/drivers/file')
-rw-r--r--connectivity/source/drivers/file/FCatalog.cxx2
-rw-r--r--connectivity/source/drivers/file/FColumns.cxx7
-rw-r--r--connectivity/source/drivers/file/FConnection.cxx33
-rw-r--r--connectivity/source/drivers/file/FDatabaseMetaData.cxx56
-rw-r--r--connectivity/source/drivers/file/FDateFunctions.cxx26
-rw-r--r--connectivity/source/drivers/file/FDriver.cxx78
-rw-r--r--connectivity/source/drivers/file/FNoException.cxx2
-rw-r--r--connectivity/source/drivers/file/FNumericFunctions.cxx59
-rw-r--r--connectivity/source/drivers/file/FPreparedStatement.cxx17
-rw-r--r--connectivity/source/drivers/file/FResultSet.cxx79
-rw-r--r--connectivity/source/drivers/file/FResultSetMetaData.cxx11
-rw-r--r--connectivity/source/drivers/file/FStatement.cxx52
-rw-r--r--connectivity/source/drivers/file/FStringFunctions.cxx68
-rw-r--r--connectivity/source/drivers/file/FTable.cxx22
-rw-r--r--connectivity/source/drivers/file/FTables.cxx2
-rw-r--r--connectivity/source/drivers/file/fanalyzer.cxx1
-rw-r--r--connectivity/source/drivers/file/fcode.cxx39
-rw-r--r--connectivity/source/drivers/file/fcomp.cxx35
18 files changed, 245 insertions, 344 deletions
diff --git a/connectivity/source/drivers/file/FCatalog.cxx b/connectivity/source/drivers/file/FCatalog.cxx
index eedda26efba2..54ad24bf1d59 100644
--- a/connectivity/source/drivers/file/FCatalog.cxx
+++ b/connectivity/source/drivers/file/FCatalog.cxx
@@ -24,10 +24,8 @@
#include <com/sun/star/sdbc/XResultSet.hpp>
using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::sdbc;
-using namespace ::com::sun::star::container;
using namespace connectivity::file;
diff --git a/connectivity/source/drivers/file/FColumns.cxx b/connectivity/source/drivers/file/FColumns.cxx
index e703112f71c4..97e9d0c23a2a 100644
--- a/connectivity/source/drivers/file/FColumns.cxx
+++ b/connectivity/source/drivers/file/FColumns.cxx
@@ -25,12 +25,8 @@
using namespace connectivity::file;
using namespace connectivity;
-using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::sdbc;
-using namespace ::com::sun::star::container;
-using namespace ::com::sun::star::lang;
sdbcx::ObjectType OColumns::createObject(const OUString& _rName)
{
@@ -48,7 +44,7 @@ sdbcx::ObjectType OColumns::createObject(const OUString& _rName)
{
if(xRow->getString(4) == _rName)
{
- sdbcx::OColumn* pRet = new sdbcx::OColumn(_rName,
+ xRet = new sdbcx::OColumn(_rName,
xRow->getString(6),
xRow->getString(13),
xRow->getString(12),
@@ -63,7 +59,6 @@ sdbcx::ObjectType OColumns::createObject(const OUString& _rName)
sCatalogName,
sSchemaName,
sTableName);
- xRet = pRet;
break;
}
}
diff --git a/connectivity/source/drivers/file/FConnection.cxx b/connectivity/source/drivers/file/FConnection.cxx
index 5c56ce4d5e5d..38ce342cb5e2 100644
--- a/connectivity/source/drivers/file/FConnection.cxx
+++ b/connectivity/source/drivers/file/FConnection.cxx
@@ -21,7 +21,6 @@
#include <comphelper/processfactory.hxx>
#include <comphelper/servicehelper.hxx>
-#include <cppuhelper/typeprovider.hxx>
#include <file/FConnection.hxx>
#include <file/FDatabaseMetaData.hxx>
#include <file/FDriver.hxx>
@@ -33,6 +32,7 @@
#include <com/sun/star/ucb/XContentIdentifier.hpp>
#include <tools/urlobj.hxx>
#include <file/FCatalog.hxx>
+#include <comphelper/configuration.hxx>
#include <unotools/pathoptions.hxx>
#include <ucbhelper/content.hxx>
#include <connectivity/dbcharset.hxx>
@@ -132,6 +132,7 @@ void OConnection::construct(const OUString& url,const Sequence< PropertyValue >&
OUString aFileName = aDSN;
INetURLObject aURL;
aURL.SetSmartProtocol(INetProtocol::File);
+ if (!comphelper::IsFuzzing())
{
SvtPathOptions aPathOptions;
aFileName = aPathOptions.SubstituteVariable(aFileName);
@@ -229,8 +230,7 @@ Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const OU
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
- OPreparedStatement* pStmt = new OPreparedStatement(this);
- Reference< XPreparedStatement > xHoldAlive = pStmt;
+ rtl::Reference<OPreparedStatement> pStmt = new OPreparedStatement(this);
pStmt->construct(sql);
m_aStatements.push_back(WeakReferenceHelper(*pStmt));
return pStmt;
@@ -402,31 +402,24 @@ Reference< XDynamicResultSet > OConnection::getDir() const
sal_Int64 SAL_CALL OConnection::getSomething( const Sequence< sal_Int8 >& rId )
{
- return (isUnoTunnelId<OConnection>(rId))
- ? reinterpret_cast< sal_Int64 >( this )
- : sal_Int64(0);
+ return comphelper::getSomethingImpl(rId, this);
}
-Sequence< sal_Int8 > OConnection::getUnoTunnelId()
+const Sequence< sal_Int8 > & OConnection::getUnoTunnelId()
{
- static ::cppu::OImplementationId implId;
-
- return implId.getImplementationId();
+ static const comphelper::UnoIdInit implId;
+ return implId.getSeq();
}
void OConnection::throwUrlNotValid(const OUString & _rsUrl,const OUString & _rsMessage)
{
- SQLException aError;
- aError.Message = getResources().getResourceStringWithSubstitution(
- STR_NO_VALID_FILE_URL,
- "$URL$", _rsUrl
- );
-
- aError.SQLState = "S1000";
- aError.ErrorCode = 0;
- aError.Context = static_cast< XConnection* >(this);
+ XConnection* context = this;
+ css::uno::Any next;
if (!_rsMessage.isEmpty())
- aError.NextException <<= SQLException(_rsMessage, aError.Context, OUString(), 0, Any());
+ next <<= SQLException(_rsMessage, context, OUString(), 0, Any());
+ SQLException aError(
+ getResources().getResourceStringWithSubstitution(STR_NO_VALID_FILE_URL, "$URL$", _rsUrl),
+ context, "S1000", 0, next);
throw aError;
}
diff --git a/connectivity/source/drivers/file/FDatabaseMetaData.cxx b/connectivity/source/drivers/file/FDatabaseMetaData.cxx
index 2fffb76f78e3..6d157bb575da 100644
--- a/connectivity/source/drivers/file/FDatabaseMetaData.cxx
+++ b/connectivity/source/drivers/file/FDatabaseMetaData.cxx
@@ -17,6 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <config_fuzzers.h>
+
#include <file/FDatabaseMetaData.hxx>
#include <FDatabaseMetaDataResultSet.hxx>
#include <com/sun/star/sdbc/ResultSetType.hpp>
@@ -28,14 +30,13 @@
#include <file/FTable.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/servicehelper.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <ucbhelper/content.hxx>
using namespace com::sun::star::ucb;
using namespace connectivity::file;
using namespace connectivity;
using namespace com::sun::star::uno;
-using namespace com::sun::star::lang;
using namespace com::sun::star::beans;
using namespace com::sun::star::sdbc;
using namespace com::sun::star::sdbcx;
@@ -71,7 +72,8 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns(
namespace
{
- sal_Int16 isCaseSensitiveParentFolder( const OUString& _rFolderOrDoc, const OUString& _rDocName )
+#if !ENABLE_FUZZERS
+ sal_Int16 isCaseSensitiveParentFolder( const OUString& _rFolderOrDoc, std::u16string_view _rDocName )
{
sal_Int16 nIsCS = 1;
try
@@ -149,6 +151,7 @@ namespace
return nIsCS;
}
+#endif
}
@@ -158,14 +161,12 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
{
::osl::MutexGuard aGuard( m_aMutex );
-
- ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTables );
- Reference< XResultSet > xRef = pResult;
+ rtl::Reference<ODatabaseMetaDataResultSet> pResult = new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTables );
// check if any type is given
// when no types are given then we have to return all tables e.g. TABLE
- static constexpr OUStringLiteral aTable = u"TABLE";
+ static constexpr OUString aTable = u"TABLE"_ustr;
bool bTableFound = true;
sal_Int32 nLength = types.getLength();
@@ -185,7 +186,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
}
}
if(!bTableFound)
- return xRef;
+ return pResult;
Reference<XDynamicResultSet> xContent = m_pConnection->getDir();
Reference < XSortedDynamicResultSetFactory > xSRSFac =
@@ -229,7 +230,11 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
if ( !bKnowCaseSensitivity )
{
bKnowCaseSensitivity = true;
+#if ENABLE_FUZZERS
+ sal_Int16 nCase = 1;
+#else
sal_Int16 nCase = isCaseSensitiveParentFolder( m_pConnection->getURL(), aURL.getName() );
+#endif
switch( nCase )
{
case 1:
@@ -293,16 +298,16 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
}
if(bNewRow)
{
- aRow.push_back(new ORowSetValueDecorator(OUString(aTable)));
+ aRow.push_back(new ORowSetValueDecorator(aTable));
aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
aRows.push_back(aRow);
}
}
- pResult->setRows(aRows);
+ pResult->setRows(std::move(aRows));
- return xRef;
+ return pResult;
}
sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength( )
@@ -370,11 +375,9 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
{
::osl::MutexGuard aGuard( m_aMutex );
- ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTablePrivileges );
- Reference< XResultSet > xRef = pResult;
+ rtl::Reference<ODatabaseMetaDataResultSet> pResult = new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTablePrivileges );
ODatabaseMetaDataResultSet::ORows aRows;
-
Reference< XTablesSupplier > xTabSup = m_pConnection->createCatalog();
if( xTabSup.is())
{
@@ -397,7 +400,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
xNames->getByName(*pBegin), css::uno::UNO_QUERY);
if(xTable.is())
{
- auto pTable = comphelper::getUnoTunnelImplementation<OFileTable>(xTable);
+ auto pTable = dynamic_cast<OFileTable*>(xTable.get());
if(pTable && !pTable->isReadOnly())
{
aRow[6] = ODatabaseMetaDataResultSet::getInsertValue();
@@ -423,8 +426,8 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
}
}
- pResult->setRows(aRows);
- return xRef;
+ pResult->setRows(std::move(aRows));
+ return pResult;
}
sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( )
@@ -614,20 +617,11 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins( )
Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( )
{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTableTypes );
- Reference< XResultSet > xRef = pResult;
- static ODatabaseMetaDataResultSet::ORows aRows;
- if(aRows.empty())
- {
- ODatabaseMetaDataResultSet::ORow aRow;
- aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
- aRow.push_back(new ORowSetValueDecorator(OUString("TABLE")));
- aRows.push_back(aRow);
- }
- pResult->setRows(aRows);
- return xRef;
+ rtl::Reference<ODatabaseMetaDataResultSet> pResult = new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTableTypes );
+ ODatabaseMetaDataResultSet::ORows aRows;
+ aRows.push_back( { ODatabaseMetaDataResultSet::getEmptyValue(), new ORowSetValueDecorator(OUString("TABLE")) } );
+ pResult->setRows(std::move(aRows));
+ return pResult;
}
sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength( )
diff --git a/connectivity/source/drivers/file/FDateFunctions.cxx b/connectivity/source/drivers/file/FDateFunctions.cxx
index d5b7c48c0dcc..1be992d4b672 100644
--- a/connectivity/source/drivers/file/FDateFunctions.cxx
+++ b/connectivity/source/drivers/file/FDateFunctions.cxx
@@ -32,7 +32,7 @@ ORowSetValue OOp_DayOfWeek::operate(const ORowSetValue& lhs) const
return lhs;
sal_Int32 nRet = 0;
- css::util::Date aD = lhs;
+ css::util::Date aD = lhs.getDate();
Date aDate(aD.Day, aD.Month, aD.Year);
DayOfWeek eDayOfWeek = aDate.GetDayOfWeek();
switch (eDayOfWeek)
@@ -69,7 +69,7 @@ ORowSetValue OOp_DayOfMonth::operate(const ORowSetValue& lhs) const
if (lhs.isNull())
return lhs;
- css::util::Date aD = lhs;
+ css::util::Date aD = lhs.getDate();
return static_cast<sal_Int16>(aD.Day);
}
@@ -78,7 +78,7 @@ ORowSetValue OOp_DayOfYear::operate(const ORowSetValue& lhs) const
if (lhs.isNull())
return lhs;
- css::util::Date aD = lhs;
+ css::util::Date aD = lhs.getDate();
Date aDate(aD.Day, aD.Month, aD.Year);
return static_cast<sal_Int16>(aDate.GetDayOfYear());
}
@@ -88,7 +88,7 @@ ORowSetValue OOp_Month::operate(const ORowSetValue& lhs) const
if (lhs.isNull())
return lhs;
- css::util::Date aD = lhs;
+ css::util::Date aD = lhs.getDate();
return static_cast<sal_Int16>(aD.Month);
}
@@ -98,7 +98,7 @@ ORowSetValue OOp_DayName::operate(const ORowSetValue& lhs) const
return lhs;
OUString sRet;
- css::util::Date aD = lhs;
+ css::util::Date aD = lhs.getDate();
Date aDate(aD.Day, aD.Month, aD.Year);
DayOfWeek eDayOfWeek = aDate.GetDayOfWeek();
switch (eDayOfWeek)
@@ -136,7 +136,7 @@ ORowSetValue OOp_MonthName::operate(const ORowSetValue& lhs) const
return lhs;
OUString sRet;
- css::util::Date aD = lhs;
+ css::util::Date aD = lhs.getDate();
switch (aD.Month)
{
case 1:
@@ -185,7 +185,7 @@ ORowSetValue OOp_Quarter::operate(const ORowSetValue& lhs) const
return lhs;
sal_Int32 nRet = 1;
- css::util::Date aD = lhs;
+ css::util::Date aD = lhs.getDate();
if (aD.Month >= 4 && aD.Month < 7)
nRet = 2;
else if (aD.Month >= 7 && aD.Month < 10)
@@ -202,12 +202,12 @@ ORowSetValue OOp_Week::operate(const std::vector<ORowSetValue>& lhs) const
size_t nSize = lhs.size();
- css::util::Date aD = lhs[nSize - 1];
+ css::util::Date aD = lhs[nSize - 1].getDate();
Date aDate(aD.Day, aD.Month, aD.Year);
sal_Int16 nStartDay = SUNDAY;
if (nSize == 2 && !lhs[0].isNull())
- nStartDay = lhs[0];
+ nStartDay = lhs[0].getInt16();
return static_cast<sal_Int16>(aDate.GetWeekOfYear(static_cast<DayOfWeek>(nStartDay)));
}
@@ -217,7 +217,7 @@ ORowSetValue OOp_Year::operate(const ORowSetValue& lhs) const
if (lhs.isNull())
return lhs;
- css::util::Date aD = lhs;
+ css::util::Date aD = lhs.getDate();
return aD.Year;
}
@@ -226,7 +226,7 @@ ORowSetValue OOp_Hour::operate(const ORowSetValue& lhs) const
if (lhs.isNull())
return lhs;
- css::util::Time aT = lhs;
+ css::util::Time aT = lhs.getTime();
return static_cast<sal_Int16>(aT.Hours);
}
@@ -235,7 +235,7 @@ ORowSetValue OOp_Minute::operate(const ORowSetValue& lhs) const
if (lhs.isNull())
return lhs;
- css::util::Time aT = lhs;
+ css::util::Time aT = lhs.getTime();
return static_cast<sal_Int16>(aT.Minutes);
}
@@ -244,7 +244,7 @@ ORowSetValue OOp_Second::operate(const ORowSetValue& lhs) const
if (lhs.isNull())
return lhs;
- css::util::Time aT = lhs;
+ css::util::Time aT = lhs.getTime();
return static_cast<sal_Int16>(aT.Seconds);
}
diff --git a/connectivity/source/drivers/file/FDriver.cxx b/connectivity/source/drivers/file/FDriver.cxx
index 16cf60e02cb4..b24c4e67a532 100644
--- a/connectivity/source/drivers/file/FDriver.cxx
+++ b/connectivity/source/drivers/file/FDriver.cxx
@@ -20,11 +20,13 @@
#include <file/FDriver.hxx>
#include <file/FConnection.hxx>
#include <file/fcode.hxx>
+#include <comphelper/servicehelper.hxx>
#include <comphelper/types.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <connectivity/dbexception.hxx>
#include <strings.hrc>
#include <resource/sharedresources.hxx>
+#include <utility>
using namespace connectivity::file;
@@ -35,9 +37,9 @@ using namespace com::sun::star::sdbc;
using namespace com::sun::star::sdbcx;
using namespace com::sun::star::container;
-OFileDriver::OFileDriver(const css::uno::Reference< css::uno::XComponentContext >& _rxContext)
+OFileDriver::OFileDriver(css::uno::Reference< css::uno::XComponentContext > _xContext)
: ODriver_BASE(m_aMutex)
- ,m_xContext(_rxContext)
+ ,m_xContext(std::move(_xContext))
{
}
@@ -81,12 +83,11 @@ Reference< XConnection > SAL_CALL OFileDriver::connect( const OUString& url, con
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(ODriver_BASE::rBHelper.bDisposed);
- OConnection* pCon = new OConnection(this);
- Reference< XConnection > xCon = pCon;
+ rtl::Reference<OConnection> pCon = new OConnection(this);
pCon->construct(url,info);
m_xConnections.push_back(WeakReferenceHelper(*pCon));
- return xCon;
+ return pCon;
}
sal_Bool SAL_CALL OFileDriver::acceptsURL( const OUString& url )
@@ -98,55 +99,54 @@ Sequence< DriverPropertyInfo > SAL_CALL OFileDriver::getPropertyInfo( const OUSt
{
if ( acceptsURL(url) )
{
- std::vector< DriverPropertyInfo > aDriverInfo;
- Sequence< OUString > aBoolean(2);
- aBoolean[0] = "0";
- aBoolean[1] = "1";
+ Sequence< OUString > aBoolean { "0", "1" };
- aDriverInfo.push_back(DriverPropertyInfo(
+ return
+ {
+ {
"CharSet"
,"CharSet of the database."
,false
- ,OUString()
- ,Sequence< OUString >())
- );
- aDriverInfo.push_back(DriverPropertyInfo(
+ ,{}
+ ,{}
+ },
+ {
"Extension"
,"Extension of the file format."
,false
,".*"
- ,Sequence< OUString >())
- );
- aDriverInfo.push_back(DriverPropertyInfo(
+ ,{}
+ },
+ {
"ShowDeleted"
,"Display inactive records."
,false
,"0"
- ,aBoolean)
- );
- aDriverInfo.push_back(DriverPropertyInfo(
+ ,aBoolean
+ },
+ {
"EnableSQL92Check"
,"Use SQL92 naming constraints."
,false
,"0"
- ,aBoolean)
- );
- aDriverInfo.push_back(DriverPropertyInfo(
+ ,aBoolean
+ },
+ {
"UseRelativePath"
,"Handle the connection url as relative path."
,false
,"0"
- ,aBoolean)
- );
- aDriverInfo.push_back(DriverPropertyInfo(
+ ,aBoolean
+ },
+ {
"URL"
,"The URL of the database document which is used to create an absolute path."
,false
- ,OUString()
- ,Sequence< OUString >())
- );
- return Sequence< DriverPropertyInfo >(aDriverInfo.data(),aDriverInfo.size());
+ ,{}
+ ,{}
+ }
+ };
} // if ( acceptsURL(url) )
{
::connectivity::SharedResources aResources;
@@ -173,25 +173,15 @@ Reference< XTablesSupplier > SAL_CALL OFileDriver::getDataDefinitionByConnection
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(ODriver_BASE::rBHelper.bDisposed);
- Reference< XTablesSupplier > xTab;
- Reference< css::lang::XUnoTunnel> xTunnel(connection,UNO_QUERY);
- if(xTunnel.is())
+ if (OConnection* pSearchConnection = comphelper::getFromUnoTunnel<OConnection>(connection))
{
- OConnection* pSearchConnection = reinterpret_cast< OConnection* >( xTunnel->getSomething(OConnection::getUnoTunnelId()) );
- OConnection* pConnection = nullptr;
for (auto const& elem : m_xConnections)
{
- if (static_cast<OConnection*>( Reference< XConnection >::query(elem.get().get()).get() ) == pSearchConnection)
- {
- pConnection = pSearchConnection;
- break;
- }
+ if (static_cast<OConnection*>( Reference< XConnection >::query(elem.get()).get() ) == pSearchConnection)
+ return pSearchConnection->createCatalog();
}
-
- if(pConnection)
- xTab = pConnection->createCatalog();
}
- return xTab;
+ return {};
}
diff --git a/connectivity/source/drivers/file/FNoException.cxx b/connectivity/source/drivers/file/FNoException.cxx
index 7c26081da12e..920bb38859f1 100644
--- a/connectivity/source/drivers/file/FNoException.cxx
+++ b/connectivity/source/drivers/file/FNoException.cxx
@@ -85,7 +85,7 @@ void OPreparedStatement::scanParameter(OSQLParseNode* pParseNode,std::vector< OS
std::unique_ptr<OKeyValue> OResultSet::GetOrderbyKeyValue(OValueRefRow const & _rRow)
{
- sal_uInt32 nBookmarkValue = std::abs(static_cast<sal_Int32>((*_rRow)[0]->getValue()));
+ sal_uInt32 nBookmarkValue = std::abs((*_rRow)[0]->getValue().getInt32());
std::unique_ptr<OKeyValue> pKeyValue = OKeyValue::createKeyValue(nBookmarkValue);
diff --git a/connectivity/source/drivers/file/FNumericFunctions.cxx b/connectivity/source/drivers/file/FNumericFunctions.cxx
index a6784a55c140..7c7fdc75425f 100644
--- a/connectivity/source/drivers/file/FNumericFunctions.cxx
+++ b/connectivity/source/drivers/file/FNumericFunctions.cxx
@@ -19,20 +19,19 @@
#include <cmath>
+#include <basegfx/numeric/ftools.hxx>
#include <file/FNumericFunctions.hxx>
#include <rtl/math.hxx>
using namespace connectivity;
using namespace connectivity::file;
-const double fPi = 3.14159265358979323846;
-
ORowSetValue OOp_Abs::operate(const ORowSetValue& lhs) const
{
if ( lhs.isNull() )
return lhs;
- double nVal(lhs);
+ double nVal = lhs.getDouble();
if ( nVal < 0 )
nVal *= -1.0;
return fabs(nVal);
@@ -44,7 +43,7 @@ ORowSetValue OOp_Sign::operate(const ORowSetValue& lhs) const
return lhs;
sal_Int32 nRet = 0;
- double nVal(lhs);
+ double nVal = lhs.getDouble();
if ( nVal < 0 )
nRet = -1;
else if ( nVal > 0 )
@@ -58,7 +57,7 @@ ORowSetValue OOp_Mod::operate(const ORowSetValue& lhs,const ORowSetValue& rhs) c
if ( lhs.isNull() || rhs.isNull() )
return ORowSetValue();
- return fmod(static_cast<double>(lhs),static_cast<double>(rhs));
+ return fmod(lhs.getDouble(), rhs.getDouble());
}
ORowSetValue OOp_Floor::operate(const ORowSetValue& lhs) const
@@ -66,7 +65,7 @@ ORowSetValue OOp_Floor::operate(const ORowSetValue& lhs) const
if ( lhs.isNull() )
return lhs;
- return floor(static_cast<double>(lhs));
+ return floor(lhs.getDouble());
}
ORowSetValue OOp_Ceiling::operate(const ORowSetValue& lhs) const
@@ -74,7 +73,7 @@ ORowSetValue OOp_Ceiling::operate(const ORowSetValue& lhs) const
if ( lhs.isNull() )
return lhs;
- double nVal(lhs);
+ double nVal = lhs.getDouble();
return ceil(nVal);
}
@@ -84,11 +83,11 @@ ORowSetValue OOp_Round::operate(const std::vector<ORowSetValue>& lhs) const
return ORowSetValue();
size_t nSize = lhs.size();
- double nVal = lhs[nSize-1];
+ double nVal = lhs[nSize-1].getDouble();
sal_Int32 nDec = 0;
if ( nSize == 2 && !lhs[0].isNull() )
- nDec = lhs[0];
+ nDec = lhs[0].getDouble();
return ::rtl::math::round(nVal,nDec);
}
@@ -97,16 +96,16 @@ ORowSetValue OOp_Exp::operate(const ORowSetValue& lhs) const
if ( lhs.isNull() )
return lhs;
- double nVal(lhs);
+ double nVal = lhs.getDouble();
return exp(nVal);
}
ORowSetValue OOp_Ln::operate(const ORowSetValue& lhs) const
{
- if ( lhs.isNull() || static_cast<double>(lhs) < 0.0 )
+ if ( lhs.isNull() || lhs.getDouble() < 0.0 )
return lhs;
- double nVal(lhs);
+ double nVal = lhs.getDouble();
nVal = log(nVal);
if ( std::isnan(nVal) )
return ORowSetValue();
@@ -118,11 +117,11 @@ ORowSetValue OOp_Log::operate(const std::vector<ORowSetValue>& lhs) const
if ( lhs.empty() || lhs.size() > 2 )
return ORowSetValue();
size_t nSize = lhs.size();
- double nVal = log( static_cast<double>(lhs[nSize-1]) );
+ double nVal = log( lhs[nSize-1].getDouble() );
if ( nSize == 2 && !lhs[0].isNull() )
- nVal /= log(static_cast<double>(lhs[0]));
+ nVal /= log(lhs[0].getDouble());
if ( std::isnan(nVal) )
return ORowSetValue();
@@ -131,10 +130,10 @@ ORowSetValue OOp_Log::operate(const std::vector<ORowSetValue>& lhs) const
ORowSetValue OOp_Log10::operate(const ORowSetValue& lhs) const
{
- if ( lhs.isNull() || static_cast<double>(lhs) < 0.0 )
+ if ( lhs.isNull() || lhs.getDouble() < 0.0 )
return lhs;
- double nVal = log(static_cast<double>(lhs));
+ double nVal = log(lhs.getDouble());
if ( std::isnan(nVal) )
return ORowSetValue();
nVal /= log(10.0);
@@ -146,7 +145,7 @@ ORowSetValue OOp_Pow::operate(const ORowSetValue& lhs,const ORowSetValue& rhs) c
if ( lhs.isNull() || rhs.isNull() )
return lhs;
- return pow(static_cast<double>(lhs),static_cast<double>(rhs));
+ return pow(lhs.getDouble(), rhs.getDouble());
}
ORowSetValue OOp_Sqrt::operate(const ORowSetValue& lhs) const
@@ -154,7 +153,7 @@ ORowSetValue OOp_Sqrt::operate(const ORowSetValue& lhs) const
if ( lhs.isNull() )
return lhs;
- double nVal = sqrt(static_cast<double>(lhs));
+ double nVal = sqrt(lhs.getDouble());
if ( std::isnan(nVal) )
return ORowSetValue();
return nVal;
@@ -162,7 +161,7 @@ ORowSetValue OOp_Sqrt::operate(const ORowSetValue& lhs) const
ORowSetValue OOp_Pi::operate(const std::vector<ORowSetValue>& /*lhs*/) const
{
- return fPi;
+ return M_PI;
}
ORowSetValue OOp_Cos::operate(const ORowSetValue& lhs) const
@@ -170,7 +169,7 @@ ORowSetValue OOp_Cos::operate(const ORowSetValue& lhs) const
if ( lhs.isNull() )
return lhs;
- return cos(static_cast<double>(lhs));
+ return cos(lhs.getDouble());
}
ORowSetValue OOp_Sin::operate(const ORowSetValue& lhs) const
@@ -178,7 +177,7 @@ ORowSetValue OOp_Sin::operate(const ORowSetValue& lhs) const
if ( lhs.isNull() )
return lhs;
- return sin(static_cast<double>(lhs));
+ return sin(lhs.getDouble());
}
ORowSetValue OOp_Tan::operate(const ORowSetValue& lhs) const
@@ -186,7 +185,7 @@ ORowSetValue OOp_Tan::operate(const ORowSetValue& lhs) const
if ( lhs.isNull() )
return lhs;
- return tan(static_cast<double>(lhs));
+ return tan(lhs.getDouble());
}
ORowSetValue OOp_ACos::operate(const ORowSetValue& lhs) const
@@ -194,7 +193,7 @@ ORowSetValue OOp_ACos::operate(const ORowSetValue& lhs) const
if ( lhs.isNull() )
return lhs;
- return acos(static_cast<double>(lhs));
+ return acos(lhs.getDouble());
}
ORowSetValue OOp_ASin::operate(const ORowSetValue& lhs) const
@@ -202,7 +201,7 @@ ORowSetValue OOp_ASin::operate(const ORowSetValue& lhs) const
if ( lhs.isNull() )
return lhs;
- return asin(static_cast<double>(lhs));
+ return asin(lhs.getDouble());
}
ORowSetValue OOp_ATan::operate(const ORowSetValue& lhs) const
@@ -210,7 +209,7 @@ ORowSetValue OOp_ATan::operate(const ORowSetValue& lhs) const
if ( lhs.isNull() )
return lhs;
- return atan(static_cast<double>(lhs));
+ return atan(lhs.getDouble());
}
ORowSetValue OOp_ATan2::operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const
@@ -218,7 +217,7 @@ ORowSetValue OOp_ATan2::operate(const ORowSetValue& lhs,const ORowSetValue& rhs)
if ( lhs.isNull() || rhs.isNull() )
return lhs;
- return atan2(static_cast<double>(lhs),static_cast<double>(rhs));
+ return atan2(lhs.getDouble(), rhs.getDouble());
}
ORowSetValue OOp_Degrees::operate(const ORowSetValue& lhs) const
@@ -226,8 +225,8 @@ ORowSetValue OOp_Degrees::operate(const ORowSetValue& lhs) const
if ( lhs.isNull() )
return lhs;
- double nLhs = lhs;
- return nLhs*180*(1.0/fPi);
+ double nLhs = lhs.getDouble();
+ return basegfx::rad2deg(nLhs);
}
ORowSetValue OOp_Radians::operate(const ORowSetValue& lhs) const
@@ -235,8 +234,8 @@ ORowSetValue OOp_Radians::operate(const ORowSetValue& lhs) const
if ( lhs.isNull() )
return lhs;
- double nLhs = lhs;
- return nLhs*fPi*(1.0/180.0);
+ double nLhs = lhs.getDouble();
+ return basegfx::deg2rad(nLhs);
}
diff --git a/connectivity/source/drivers/file/FPreparedStatement.cxx b/connectivity/source/drivers/file/FPreparedStatement.cxx
index fc5b81923cb4..f2a8571b61e5 100644
--- a/connectivity/source/drivers/file/FPreparedStatement.cxx
+++ b/connectivity/source/drivers/file/FPreparedStatement.cxx
@@ -18,6 +18,7 @@
*/
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <file/FPreparedStatement.hxx>
#include <com/sun/star/sdbc/DataType.hpp>
@@ -100,7 +101,7 @@ rtl::Reference<OResultSet> OPreparedStatement::makeResultSet()
closeResultSet();
rtl::Reference<OResultSet> xResultSet(createResultSet());
- m_xResultSet = xResultSet.get();
+ m_xResultSet = uno::Reference<uno::XWeak>(xResultSet);
initializeResultSet(xResultSet.get());
initResultSet(xResultSet.get());
return xResultSet;
@@ -133,7 +134,7 @@ Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData( )
if(!m_xMetaData.is())
m_xMetaData = new OResultSetMetaData(m_aSQLIterator.getSelectColumns(),m_aSQLIterator.getTables().begin()->first,m_pTable.get());
- return m_xMetaData.get();
+ return m_xMetaData;
}
@@ -189,7 +190,7 @@ Reference< XConnection > SAL_CALL OPreparedStatement::getConnection( )
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
- return Reference< XConnection >(m_pConnection.get());
+ return m_pConnection;
}
@@ -198,7 +199,7 @@ Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( )
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
- return makeResultSet().get();
+ return makeResultSet();
}
@@ -363,7 +364,7 @@ void SAL_CALL OPreparedStatement::clearParameters( )
m_aParameterRow->push_back(new ORowSetValueDecorator(sal_Int32(0)) );
}
-OResultSet* OPreparedStatement::createResultSet()
+rtl::Reference<OResultSet> OPreparedStatement::createResultSet()
{
return new OResultSet(this,m_aSQLIterator);
}
@@ -379,12 +380,12 @@ void OPreparedStatement::initResultSet(OResultSet *pResultSet)
pResultSet->setMetaData(getMetaData());
}
-void SAL_CALL OPreparedStatement::acquire() throw()
+void SAL_CALL OPreparedStatement::acquire() noexcept
{
OStatement_BASE2::acquire();
}
-void SAL_CALL OPreparedStatement::release() throw()
+void SAL_CALL OPreparedStatement::release() noexcept
{
OStatement_BASE2::release();
}
@@ -392,7 +393,7 @@ void SAL_CALL OPreparedStatement::release() throw()
void OPreparedStatement::checkAndResizeParameters(sal_Int32 parameterIndex)
{
::connectivity::checkDisposed(OStatement_BASE::rBHelper.bDisposed);
- if ( m_aAssignValues.is() && (parameterIndex < 1 || parameterIndex >= static_cast<sal_Int32>(m_aParameterIndexes.size())) )
+ if ( m_aAssignValues.is() && (parameterIndex < 1 || o3tl::make_unsigned(parameterIndex) >= m_aParameterIndexes.size()) )
throwInvalidIndexException(*this);
else if ( static_cast<sal_Int32>(m_aParameterRow->size()) <= parameterIndex )
{
diff --git a/connectivity/source/drivers/file/FResultSet.cxx b/connectivity/source/drivers/file/FResultSet.cxx
index 5cf5d1ae862d..5612c68feedf 100644
--- a/connectivity/source/drivers/file/FResultSet.cxx
+++ b/connectivity/source/drivers/file/FResultSet.cxx
@@ -29,6 +29,7 @@
#include <cppuhelper/typeprovider.hxx>
#include <connectivity/dbtools.hxx>
#include <cppuhelper/propshlp.hxx>
+#include <o3tl/safeint.hxx>
#include <sal/log.hxx>
#include <iterator>
#include <com/sun/star/sdbc/ResultSetType.hpp>
@@ -41,7 +42,7 @@
#include <comphelper/types.hxx>
#include <resource/sharedresources.hxx>
#include <strings.hrc>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
using namespace ::comphelper;
using namespace connectivity;
@@ -57,7 +58,7 @@ using namespace com::sun::star::container;
namespace
{
- void lcl_throwError(const char* pErrorId, const css::uno::Reference< css::uno::XInterface>& _xContext)
+ void lcl_throwError(TranslateId pErrorId, const css::uno::Reference< css::uno::XInterface>& _xContext)
{
::connectivity::SharedResources aResources;
const OUString sMessage = aResources.getResourceString(pErrorId);
@@ -133,9 +134,8 @@ void OResultSet::disposing()
m_xColumns = nullptr;
m_xColsIdx.clear();
- Reference<XComponent> xComp = m_pTable.get();
- if ( xComp.is() )
- xComp->removeEventListener(this);
+ if ( m_pTable.is() )
+ m_pTable->removeEventListener(this);
m_pTable.clear();
m_pFileSet = nullptr;
@@ -218,43 +218,43 @@ Reference< css::io::XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_
sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex )
{
- return bool(getValue(columnIndex));
+ return getValue(columnIndex).getBool();
}
sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 columnIndex )
{
- return getValue(columnIndex);
+ return getValue(columnIndex).getInt8();
}
Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex )
{
- return getValue(columnIndex);
+ return getValue(columnIndex).getSequence();
}
css::util::Date SAL_CALL OResultSet::getDate( sal_Int32 columnIndex )
{
- return getValue(columnIndex);
+ return getValue(columnIndex).getDate();
}
double SAL_CALL OResultSet::getDouble( sal_Int32 columnIndex )
{
- return getValue(columnIndex);
+ return getValue(columnIndex).getDouble();
}
float SAL_CALL OResultSet::getFloat( sal_Int32 columnIndex )
{
- return getValue(columnIndex);
+ return getValue(columnIndex).getFloat();
}
sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 columnIndex )
{
- return getValue(columnIndex);
+ return getValue(columnIndex).getInt32();
}
@@ -265,13 +265,13 @@ sal_Int32 SAL_CALL OResultSet::getRow( )
OSL_ENSURE((m_bShowDeleted || !m_aRow->isDeleted()),"getRow called for deleted row");
- return m_aSkipDeletedSet.getMappedPosition((*m_aRow)[0]->getValue());
+ return m_aSkipDeletedSet.getMappedPosition((*m_aRow)[0]->getValue().getInt32());
}
sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 columnIndex )
{
- return getValue(columnIndex);
+ return getValue(columnIndex).getLong();
}
@@ -317,22 +317,22 @@ Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const Reference< css:
sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex )
{
- return getValue(columnIndex);
+ return getValue(columnIndex).getInt16();
}
OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex )
{
- return getValue(columnIndex);
+ return getValue(columnIndex).getString();
}
css::util::Time SAL_CALL OResultSet::getTime( sal_Int32 columnIndex )
{
- return getValue(columnIndex);
+ return getValue(columnIndex).getTime();
}
css::util::DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 columnIndex )
{
- return getValue(columnIndex);
+ return getValue(columnIndex).getDateTime();
}
@@ -519,12 +519,12 @@ void SAL_CALL OResultSet::insertRow( )
m_bRowInserted = m_pTable->InsertRow(*m_aInsertRow, m_xColsIdx);
if(m_bRowInserted && m_pFileSet.is())
{
- sal_Int32 nPos = (*m_aInsertRow)[0]->getValue();
+ sal_Int32 nPos = (*m_aInsertRow)[0]->getValue().getInt32();
m_pFileSet->push_back(nPos);
*(*m_aInsertRow)[0] = sal_Int32(m_pFileSet->size());
clearInsertRow();
- m_aSkipDeletedSet.insertNewPosition((*m_aRow)[0]->getValue());
+ m_aSkipDeletedSet.insertNewPosition((*m_aRow)[0]->getValue().getInt32());
}
}
@@ -537,7 +537,7 @@ void SAL_CALL OResultSet::updateRow( )
lcl_throwError(STR_TABLE_READONLY,*this);
m_bRowUpdated = m_pTable->UpdateRow(*m_aInsertRow, m_aRow,m_xColsIdx);
- *(*m_aInsertRow)[0] = static_cast<sal_Int32>((*m_aRow)[0]->getValue());
+ *(*m_aInsertRow)[0] = (*m_aRow)[0]->getValue().getInt32();
clearInsertRow();
}
@@ -554,7 +554,7 @@ void SAL_CALL OResultSet::deleteRow()
if(m_aRow->isDeleted())
lcl_throwError(STR_ROW_ALREADY_DELETED,*this);
- sal_Int32 nPos = static_cast<sal_Int32>((*m_aRow)[0]->getValue());
+ sal_Int32 nPos = (*m_aRow)[0]->getValue().getInt32();
m_bRowDeleted = m_pTable->DeleteRow(*m_xColumns);
if(m_bRowDeleted && m_pFileSet.is())
{
@@ -838,7 +838,7 @@ again:
}
else if (m_pFileSet.is())
{
- sal_uInt32 nBookmarkValue = std::abs(static_cast<sal_Int32>((*m_aEvaluateRow)[0]->getValue()));
+ sal_uInt32 nBookmarkValue = std::abs((*m_aEvaluateRow)[0]->getValue().getInt32());
m_pFileSet->push_back(nBookmarkValue);
}
}
@@ -922,7 +922,7 @@ bool OResultSet::Move(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOff
// The FileCursor is outside of the valid range, if:
// a.) m_nRowPos < 1
// b.) a KeySet exists and m_nRowPos > m_pFileSet->size()
- if (m_nRowPos < 0 || (m_pFileSet->isFrozen() && eCursorPosition != IResultSetHelper::BOOKMARK && m_nRowPos >= static_cast<sal_Int32>(m_pFileSet->size()) )) // && m_pFileSet->IsFrozen()
+ if (m_nRowPos < 0 || (m_pFileSet->isFrozen() && eCursorPosition != IResultSetHelper::BOOKMARK && o3tl::make_unsigned(m_nRowPos) >= m_pFileSet->size() )) // && m_pFileSet->IsFrozen()
{
goto Error;
}
@@ -1137,14 +1137,14 @@ void OResultSet::sortRows()
++i;
}
- m_pSortIndex.reset(new OSortIndex(eKeyType,m_aOrderbyAscending));
+ m_pSortIndex.reset(new OSortIndex(std::move(eKeyType), std::vector(m_aOrderbyAscending)));
while ( ExecuteRow( IResultSetHelper::NEXT, 1, false ) )
{
(*m_aSelectRow)[0]->setValue( (*m_aRow)[0]->getValue() );
if ( m_pSQLAnalyzer->hasFunctions() )
m_pSQLAnalyzer->setSelectionEvaluationResult( m_aSelectRow, m_aColMapping );
- const sal_Int32 nBookmark = (*m_aRow->begin())->getValue();
+ const sal_Int32 nBookmark = (*m_aRow->begin())->getValue().getInt32();
ExecuteRow( IResultSetHelper::BOOKMARK, nBookmark, true, false );
}
@@ -1381,22 +1381,6 @@ void OResultSet::OpenImpl()
m_nFilePos = 0;
}
-Sequence< sal_Int8 > OResultSet::getUnoTunnelId()
-{
- static ::cppu::OImplementationId implId;
-
- return implId.getImplementationId();
-}
-
-// css::lang::XUnoTunnel
-
-sal_Int64 OResultSet::getSomething( const Sequence< sal_Int8 > & rId )
-{
- return isUnoTunnelId<OResultSet>(rId)
- ? reinterpret_cast< sal_Int64 >( this )
- : 0;
-}
-
void OResultSet::setBoundedColumns(const OValueRefRow& _rRow,
const OValueRefRow& _rSelectRow,
const ::rtl::Reference<connectivity::OSQLColumns>& _rxColumns,
@@ -1514,12 +1498,12 @@ void OResultSet::setBoundedColumns(const OValueRefRow& _rRow,
}
}
-void SAL_CALL OResultSet::acquire() throw()
+void SAL_CALL OResultSet::acquire() noexcept
{
OResultSet_BASE::acquire();
}
-void SAL_CALL OResultSet::release() throw()
+void SAL_CALL OResultSet::release() noexcept
{
OResultSet_BASE::release();
}
@@ -1531,8 +1515,7 @@ Reference< css::beans::XPropertySetInfo > SAL_CALL OResultSet::getPropertySetInf
void OResultSet::doTableSpecials(const OSQLTable& _xTable)
{
- Reference<css::lang::XUnoTunnel> xTunnel(_xTable, UNO_QUERY_THROW);
- m_pTable = reinterpret_cast< OFileTable* >(xTunnel->getSomething(OFileTable::getUnoTunnelId()));
+ m_pTable = dynamic_cast<OFileTable*>(_xTable.get());
assert(m_pTable.is());
}
@@ -1575,7 +1558,7 @@ bool OResultSet::move(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nO
sal_Int32 OResultSet::getDriverPos() const
{
- return (*m_aRow)[0]->getValue();
+ return (*m_aRow)[0]->getValue().getInt32();
}
bool OResultSet::isRowDeleted() const
@@ -1585,7 +1568,7 @@ bool OResultSet::isRowDeleted() const
void SAL_CALL OResultSet::disposing( const EventObject& Source )
{
- Reference<XPropertySet> xProp = m_pTable.get();
+ Reference<XPropertySet> xProp = m_pTable;
if(m_pTable.is() && Source.Source == xProp)
{
m_pTable.clear();
diff --git a/connectivity/source/drivers/file/FResultSetMetaData.cxx b/connectivity/source/drivers/file/FResultSetMetaData.cxx
index f68a06532bb7..44898d88242b 100644
--- a/connectivity/source/drivers/file/FResultSetMetaData.cxx
+++ b/connectivity/source/drivers/file/FResultSetMetaData.cxx
@@ -22,6 +22,8 @@
#include <comphelper/extract.hxx>
#include <connectivity/dbexception.hxx>
#include <comphelper/types.hxx>
+#include <o3tl/safeint.hxx>
+#include <utility>
using namespace ::comphelper;
@@ -33,12 +35,11 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::container;
-using namespace ::com::sun::star::lang;
-OResultSetMetaData::OResultSetMetaData(const ::rtl::Reference<connectivity::OSQLColumns>& _rxColumns,const OUString& _aTableName,OFileTable* _pTable)
- :m_aTableName(_aTableName)
- ,m_xColumns(_rxColumns)
+OResultSetMetaData::OResultSetMetaData(::rtl::Reference<connectivity::OSQLColumns> _xColumns, OUString _aTableName, OFileTable* _pTable)
+ :m_aTableName(std::move(_aTableName))
+ ,m_xColumns(std::move(_xColumns))
,m_pTable(_pTable)
{
}
@@ -51,7 +52,7 @@ OResultSetMetaData::~OResultSetMetaData()
void OResultSetMetaData::checkColumnIndex(sal_Int32 column)
{
- if(column <= 0 || column > static_cast<sal_Int32>(m_xColumns->size()))
+ if(column <= 0 || o3tl::make_unsigned(column) > m_xColumns->size())
throwInvalidIndexException(*this);
}
diff --git a/connectivity/source/drivers/file/FStatement.cxx b/connectivity/source/drivers/file/FStatement.cxx
index 08c4f7fdd844..4520abfeff1d 100644
--- a/connectivity/source/drivers/file/FStatement.cxx
+++ b/connectivity/source/drivers/file/FStatement.cxx
@@ -32,11 +32,13 @@
#include <com/sun/star/sdbc/FetchDirection.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
#include <comphelper/sequence.hxx>
+#include <comphelper/servicehelper.hxx>
#include <cppuhelper/typeprovider.hxx>
#include <comphelper/types.hxx>
#include <connectivity/dbexception.hxx>
#include <strings.hrc>
#include <algorithm>
+#include <cstddef>
namespace connectivity::file
{
@@ -128,12 +130,12 @@ void OStatement_BASE2::disposing()
OStatement_Base::disposing();
}
-void SAL_CALL OStatement_Base::acquire() throw()
+void SAL_CALL OStatement_Base::acquire() noexcept
{
OStatement_BASE::acquire();
}
-void SAL_CALL OStatement_BASE2::release() throw()
+void SAL_CALL OStatement_BASE2::release() noexcept
{
OStatement_BASE::release();
}
@@ -192,7 +194,7 @@ Any SAL_CALL OStatement_Base::getWarnings( )
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
- return makeAny(m_aLastWarning);
+ return Any(m_aLastWarning);
}
void SAL_CALL OStatement_Base::clearWarnings( )
@@ -216,19 +218,19 @@ void SAL_CALL OStatement_Base::clearWarnings( )
return *getArrayHelper();
}
-OResultSet* OStatement::createResultSet()
+rtl::Reference<OResultSet> OStatement::createResultSet()
{
return new OResultSet(this,m_aSQLIterator);
}
IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbc.driver.file.Statement","com.sun.star.sdbc.Statement");
-void SAL_CALL OStatement::acquire() throw()
+void SAL_CALL OStatement::acquire() noexcept
{
OStatement_BASE2::acquire();
}
-void SAL_CALL OStatement::release() throw()
+void SAL_CALL OStatement::release() noexcept
{
OStatement_BASE2::release();
}
@@ -251,9 +253,9 @@ Reference< XResultSet > SAL_CALL OStatement::executeQuery( const OUString& sql )
construct(sql);
Reference< XResultSet > xRS;
- OResultSet* pResult = createResultSet();
+ rtl::Reference<OResultSet> pResult = createResultSet();
xRS = pResult;
- initializeResultSet(pResult);
+ initializeResultSet(pResult.get());
m_xResultSet = xRS;
pResult->OpenImpl();
@@ -263,7 +265,7 @@ Reference< XResultSet > SAL_CALL OStatement::executeQuery( const OUString& sql )
Reference< XConnection > SAL_CALL OStatement::getConnection( )
{
- return Reference< XConnection >(m_pConnection.get());
+ return m_pConnection;
}
sal_Int32 SAL_CALL OStatement::executeUpdate( const OUString& sql )
@@ -302,9 +304,9 @@ Any SAL_CALL OStatement::queryInterface( const Type & rType )
return aRet.hasValue() ? aRet : OStatement_BASE2::queryInterface( rType);
}
-void OStatement_Base::anylizeSQL()
+void OStatement_Base::analyzeSQL()
{
- OSL_ENSURE(m_pSQLAnalyzer,"OResultSet::anylizeSQL: Analyzer isn't set!");
+ OSL_ENSURE(m_pSQLAnalyzer,"OResultSet::analyzeSQL: Analyzer isn't set!");
// start analysing the statement
m_pSQLAnalyzer->setOrigColumns(m_xColNames);
m_pSQLAnalyzer->start(m_pParseTree);
@@ -394,16 +396,19 @@ void OStatement_Base::construct(const OUString& sql)
case OSQLStatementType::Unknown:
m_pConnection->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,*this);
break;
+ case OSQLStatementType::Select:
+ if(SQL_ISRULE(m_aSQLIterator.getParseTree(), union_statement))
+ {
+ m_pConnection->throwGenericSQLException(STR_QUERY_TOO_COMPLEX, *this);
+ }
+ assert(SQL_ISRULE(m_aSQLIterator.getParseTree(), select_statement));
+ break;
default:
break;
}
// at this moment we support only one table per select statement
- Reference< css::lang::XUnoTunnel> xTunnel(rTabs.begin()->second,UNO_QUERY);
- if(xTunnel.is())
- {
- m_pTable = reinterpret_cast<OFileTable*>(xTunnel->getSomething(OFileTable::getUnoTunnelId()));
- }
+ m_pTable = dynamic_cast<OFileTable*>(rTabs.begin()->second.get());
OSL_ENSURE(m_pTable.is(),"No table!");
if ( m_pTable.is() )
m_xColNames = m_pTable->getColumns();
@@ -428,7 +433,7 @@ void OStatement_Base::construct(const OUString& sql)
m_pSQLAnalyzer.reset( new OSQLAnalyzer(m_pConnection.get()) );
- anylizeSQL();
+ analyzeSQL();
}
void OStatement_Base::createColumnMapping()
@@ -436,7 +441,7 @@ void OStatement_Base::createColumnMapping()
// initialize the column index map (mapping select columns to table columns)
::rtl::Reference<connectivity::OSQLColumns> xColumns = m_aSQLIterator.getSelectColumns();
m_aColMapping.resize(xColumns->size() + 1);
- for (sal_Int32 i=0; i<static_cast<sal_Int32>(m_aColMapping.size()); ++i)
+ for (std::size_t i=0; i<m_aColMapping.size(); ++i)
m_aColMapping[i] = i;
Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY);
@@ -449,10 +454,10 @@ void OStatement_Base::initializeResultSet(OResultSet* _pResult)
GetAssignValues();
_pResult->setSqlAnalyzer(m_pSQLAnalyzer.get());
- _pResult->setOrderByColumns(m_aOrderbyColumnNumber);
- _pResult->setOrderByAscending(m_aOrderbyAscending);
+ _pResult->setOrderByColumns(std::vector(m_aOrderbyColumnNumber));
+ _pResult->setOrderByAscending(std::vector(m_aOrderbyAscending));
_pResult->setBindingRow(m_aRow);
- _pResult->setColumnMapping(m_aColMapping);
+ _pResult->setColumnMapping(std::vector(m_aColMapping));
_pResult->setEvaluationRow(m_aEvaluateRow);
_pResult->setAssignValues(m_aAssignValues);
_pResult->setSelectRow(m_aSelectRow);
@@ -495,10 +500,7 @@ void OStatement_Base::GetAssignValues()
if (pOptColumnCommalist->count() == 0)
{
const Sequence< OUString>& aNames = m_xColNames->getElementNames();
- const OUString* pBegin = aNames.getConstArray();
- const OUString* pEnd = pBegin + aNames.getLength();
- for (; pBegin != pEnd; ++pBegin)
- aColumnNameList.push_back(*pBegin);
+ aColumnNameList.insert(aColumnNameList.end(), aNames.begin(), aNames.end());
}
else
{
diff --git a/connectivity/source/drivers/file/FStringFunctions.cxx b/connectivity/source/drivers/file/FStringFunctions.cxx
index 8bac436e07be..d02c7cce1737 100644
--- a/connectivity/source/drivers/file/FStringFunctions.cxx
+++ b/connectivity/source/drivers/file/FStringFunctions.cxx
@@ -18,6 +18,8 @@
*/
#include <file/FStringFunctions.hxx>
+
+#include <comphelper/string.hxx>
#include <rtl/ustrbuf.hxx>
using namespace connectivity;
@@ -61,14 +63,14 @@ ORowSetValue OOp_Char::operate(const std::vector<ORowSetValue>& lhs) const
if (lhs.empty())
return ORowSetValue();
- OUStringBuffer sRet;
+ OUStringBuffer sRet(static_cast<sal_Int32>(lhs.size()));
std::vector<ORowSetValue>::const_reverse_iterator aIter = lhs.rbegin();
std::vector<ORowSetValue>::const_reverse_iterator aEnd = lhs.rend();
for (; aIter != aEnd; ++aIter)
{
if (!aIter->isNull())
{
- char c = static_cast<char>(static_cast<sal_Int32>(*aIter));
+ char c = static_cast<char>(aIter->getInt32());
sRet.appendAscii(&c, 1);
}
@@ -90,7 +92,7 @@ ORowSetValue OOp_Concat::operate(const std::vector<ORowSetValue>& lhs) const
if (aIter->isNull())
return ORowSetValue();
- sRet.append(aIter->operator OUString());
+ sRet.append(aIter->getString());
}
return sRet.makeStringAndClear();
@@ -108,7 +110,7 @@ ORowSetValue OOp_Locate::operate(const std::vector<ORowSetValue>& lhs) const
else if (lhs.size() != 3)
return ORowSetValue();
- return lhs[1].getString().indexOf(lhs[2].getString(), lhs[0]) + 1;
+ return lhs[1].getString().indexOf(lhs[2].getString(), lhs[0].getInt32()) + 1;
}
ORowSetValue OOp_SubString::operate(const std::vector<ORowSetValue>& lhs) const
@@ -117,13 +119,13 @@ ORowSetValue OOp_SubString::operate(const std::vector<ORowSetValue>& lhs) const
[](const ORowSetValue& rValue) { return rValue.isNull(); }))
return ORowSetValue();
- if (lhs.size() == 2 && static_cast<sal_Int32>(lhs[0]) >= sal_Int32(0))
- return lhs[1].getString().copy(static_cast<sal_Int32>(lhs[0]) - 1);
+ if (lhs.size() == 2 && lhs[0].getInt32() >= sal_Int32(0))
+ return lhs[1].getString().copy(lhs[0].getInt32() - 1);
- else if (lhs.size() != 3 || static_cast<sal_Int32>(lhs[1]) < sal_Int32(0))
+ else if (lhs.size() != 3 || lhs[1].getInt32() < sal_Int32(0))
return ORowSetValue();
- return lhs[2].getString().copy(static_cast<sal_Int32>(lhs[1]) - 1, lhs[0]);
+ return lhs[2].getString().copy(lhs[1].getInt32() - 1, lhs[0].getInt32());
}
ORowSetValue OOp_LTrim::operate(const ORowSetValue& lhs) const
@@ -131,7 +133,7 @@ ORowSetValue OOp_LTrim::operate(const ORowSetValue& lhs) const
if (lhs.isNull())
return lhs;
- OUString sRet = lhs;
+ OUString sRet = lhs.getString();
OUString sNew = sRet.trim();
return sRet.copy(sRet.indexOf(sNew));
}
@@ -141,7 +143,7 @@ ORowSetValue OOp_RTrim::operate(const ORowSetValue& lhs) const
if (lhs.isNull())
return lhs;
- OUString sRet = lhs;
+ OUString sRet = lhs.getString();
OUString sNew = sRet.trim();
return sRet.copy(0, sRet.lastIndexOf(sNew[sNew.getLength() - 1]) + 1);
}
@@ -151,13 +153,9 @@ ORowSetValue OOp_Space::operate(const ORowSetValue& lhs) const
if (lhs.isNull())
return lhs;
- const char c = ' ';
- OUStringBuffer sRet;
- sal_Int32 nCount = lhs;
- for (sal_Int32 i = 0; i < nCount; ++i)
- {
- sRet.appendAscii(&c, 1);
- }
+ sal_Int32 nCount = std::max(lhs.getInt32(), sal_Int32(0));
+ OUStringBuffer sRet(nCount);
+ comphelper::string::padToLength(sRet, nCount, ' ');
return sRet.makeStringAndClear();
}
@@ -166,17 +164,10 @@ ORowSetValue OOp_Replace::operate(const std::vector<ORowSetValue>& lhs) const
if (lhs.size() != 3)
return ORowSetValue();
- OUString sStr = lhs[2];
- OUString sFrom = lhs[1];
- OUString sTo = lhs[0];
- sal_Int32 nIndexOf = sStr.indexOf(sFrom);
- while (nIndexOf != -1)
- {
- sStr = sStr.replaceAt(nIndexOf, sFrom.getLength(), sTo);
- nIndexOf = sStr.indexOf(sFrom, nIndexOf + sTo.getLength());
- }
-
- return sStr;
+ OUString sStr = lhs[2].getString();
+ OUString sFrom = lhs[1].getString();
+ OUString sTo = lhs[0].getString();
+ return sStr.replaceAll(sFrom, sTo);
}
ORowSetValue OOp_Repeat::operate(const ORowSetValue& lhs, const ORowSetValue& rhs) const
@@ -184,11 +175,12 @@ ORowSetValue OOp_Repeat::operate(const ORowSetValue& lhs, const ORowSetValue& rh
if (lhs.isNull() || rhs.isNull())
return lhs;
- OUStringBuffer sRet;
- sal_Int32 nCount = rhs;
+ const OUString s = lhs.getString();
+ const sal_Int32 nCount = std::max(rhs.getInt32(), sal_Int32(0));
+ OUStringBuffer sRet(s.getLength() * nCount);
for (sal_Int32 i = 0; i < nCount; ++i)
{
- sRet.append(lhs.operator OUString());
+ sRet.append(s);
}
return sRet.makeStringAndClear();
}
@@ -198,12 +190,12 @@ ORowSetValue OOp_Insert::operate(const std::vector<ORowSetValue>& lhs) const
if (lhs.size() != 4)
return ORowSetValue();
- OUString sStr = lhs[3];
+ OUString sStr = lhs[3].getString();
- sal_Int32 nStart = static_cast<sal_Int32>(lhs[2]);
+ sal_Int32 nStart = lhs[2].getInt32();
if (nStart < 1)
nStart = 1;
- return sStr.replaceAt(nStart - 1, static_cast<sal_Int32>(lhs[1]), lhs[0]);
+ return sStr.replaceAt(nStart - 1, lhs[1].getInt32(), lhs[0].getString());
}
ORowSetValue OOp_Left::operate(const ORowSetValue& lhs, const ORowSetValue& rhs) const
@@ -211,8 +203,8 @@ ORowSetValue OOp_Left::operate(const ORowSetValue& lhs, const ORowSetValue& rhs)
if (lhs.isNull() || rhs.isNull())
return lhs;
- OUString sRet = lhs;
- sal_Int32 nCount = rhs;
+ OUString sRet = lhs.getString();
+ sal_Int32 nCount = rhs.getInt32();
if (nCount < 0)
return ORowSetValue();
return sRet.copy(0, nCount);
@@ -223,8 +215,8 @@ ORowSetValue OOp_Right::operate(const ORowSetValue& lhs, const ORowSetValue& rhs
if (lhs.isNull() || rhs.isNull())
return lhs;
- sal_Int32 nCount = rhs;
- OUString sRet = lhs;
+ sal_Int32 nCount = rhs.getInt32();
+ OUString sRet = lhs.getString();
if (nCount < 0 || nCount >= sRet.getLength())
return ORowSetValue();
diff --git a/connectivity/source/drivers/file/FTable.cxx b/connectivity/source/drivers/file/FTable.cxx
index b47bfb811a1f..06dc187fa20e 100644
--- a/connectivity/source/drivers/file/FTable.cxx
+++ b/connectivity/source/drivers/file/FTable.cxx
@@ -23,7 +23,6 @@
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/sdbc/XResultSet.hpp>
#include <comphelper/servicehelper.hxx>
-#include <cppuhelper/typeprovider.hxx>
#include <unotools/ucbstreamhelper.hxx>
using namespace connectivity;
@@ -87,7 +86,7 @@ void OFileTable::refreshColumns()
if(m_xColumns)
m_xColumns->reFill(aVector);
else
- m_xColumns = new OColumns(this,m_aMutex,aVector);
+ m_xColumns.reset(new OColumns(this,m_aMutex,aVector));
}
void OFileTable::refreshKeys()
@@ -119,29 +118,10 @@ void SAL_CALL OFileTable::disposing()
FileClose();
}
-Sequence< sal_Int8 > OFileTable::getUnoTunnelId()
-{
- static ::cppu::OImplementationId s_Id;
-
- return s_Id.getImplementationId();
-}
-
-// css::lang::XUnoTunnel
-
-sal_Int64 OFileTable::getSomething( const Sequence< sal_Int8 > & rId )
-{
- return isUnoTunnelId<OFileTable>(rId)
- ? reinterpret_cast< sal_Int64 >( this )
- : OTable_TYPEDEF::getSomething(rId);
-}
-
void OFileTable::FileClose()
{
::osl::MutexGuard aGuard(m_aMutex);
- if (m_pFileStream && m_pFileStream->IsWritable())
- m_pFileStream->Flush();
-
m_pFileStream.reset();
m_pBuffer.reset();
}
diff --git a/connectivity/source/drivers/file/FTables.cxx b/connectivity/source/drivers/file/FTables.cxx
index c063f4a890e6..eda988d9bb44 100644
--- a/connectivity/source/drivers/file/FTables.cxx
+++ b/connectivity/source/drivers/file/FTables.cxx
@@ -23,10 +23,8 @@
using namespace connectivity;
using namespace connectivity::file;
using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::sdbc;
-using namespace ::com::sun::star::container;
sdbcx::ObjectType OTables::createObject(const OUString& /*_rName*/)
{
diff --git a/connectivity/source/drivers/file/fanalyzer.cxx b/connectivity/source/drivers/file/fanalyzer.cxx
index a0d1305f6f89..0a749cc3b22d 100644
--- a/connectivity/source/drivers/file/fanalyzer.cxx
+++ b/connectivity/source/drivers/file/fanalyzer.cxx
@@ -28,7 +28,6 @@ using namespace ::connectivity;
using namespace ::connectivity::file;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
-using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::container;
OSQLAnalyzer::OSQLAnalyzer(OConnection* _pConnection)
diff --git a/connectivity/source/drivers/file/fcode.cxx b/connectivity/source/drivers/file/fcode.cxx
index 36cba4a73485..ec56032c8491 100644
--- a/connectivity/source/drivers/file/fcode.cxx
+++ b/connectivity/source/drivers/file/fcode.cxx
@@ -20,11 +20,10 @@
#include <file/fcode.hxx>
#include <osl/diagnose.h>
#include <sal/log.hxx>
-#include <connectivity/sqlparse.hxx>
+#include <connectivity/sqlnode.hxx>
#include <sqlbison.hxx>
#include <com/sun/star/sdb/SQLFilterOperator.hpp>
-using namespace ::comphelper;
using namespace connectivity;
using namespace connectivity::file;
using namespace ::com::sun::star::sdbc;
@@ -63,32 +62,14 @@ void OOperandValue::setValue(const ORowSetValue& _rVal)
m_aValue = _rVal;
}
-OOperandParam::OOperandParam(OSQLParseNode const * pNode, sal_Int32 _nPos)
+OOperandParam::OOperandParam(sal_Int32 _nPos)
: OOperandRow(static_cast<sal_uInt16>(_nPos), DataType::VARCHAR) // Standard-Type
{
- OSL_ENSURE(SQL_ISRULE(pNode,parameter),"Argument is not a parameter");
- OSL_ENSURE(pNode->count() > 0,"Error in Parse Tree");
- OSQLParseNode *pMark = pNode->getChild(0);
-
- OUString aParameterName;
- if (SQL_ISPUNCTUATION(pMark, "?"))
- aParameterName = "?";
- else if (SQL_ISPUNCTUATION(pMark, ":"))
- aParameterName = pNode->getChild(1)->getTokenValue();
- else
- {
- SAL_WARN( "connectivity.drivers","Error in Parse Tree");
- }
-
- // set up Parameter-Column with default type, can be specified more precisely later using Describe-Parameter
-
- // save Identity (not especially necessary here, just for the sake of symmetry)
-
- // todo
- // OColumn* pColumn = new OFILEColumn(aParameterName,eDBType,255,0,SQL_FLAGS_NULLALLOWED);
- // rParamColumns->AddColumn(pColumn);
-
- // the value will be set just before the evaluation
+ //TODO: Actually do something here (the current state of OOperandParam appears to be "the
+ // remains of the very beginnings of a never finished implementation of support for parameters
+ // in this code", as Lionel put it in the comments at <https://gerrit.libreoffice.org/c/core/+/
+ // 116839/1#message-7b2bbf3543f559a0b67dc35cd940e2ab8829c274> "-Werror,-Wunused-but-set-variable
+ // (Clang 13 trunk)").
}
@@ -249,7 +230,7 @@ bool OOp_COMPARE::operate(const OOperand* pLeft, const OOperand* pRight) const
case DataType::VARCHAR:
case DataType::LONGVARCHAR:
{
- OUString sLH = aLH, sRH = aRH;
+ OUString sLH = aLH.getString(), sRH = aRH.getString();
sal_Int32 nRes = sLH.compareToIgnoreAsciiCase(sRH);
switch(aPredicateType)
{
@@ -274,7 +255,7 @@ bool OOp_COMPARE::operate(const OOperand* pLeft, const OOperand* pRight) const
case DataType::DATE:
case DataType::TIME:
{
- double n = aLH ,m = aRH;
+ double n = aLH.getDouble(), m = aRH.getDouble();
switch (aPredicateType)
{
@@ -303,7 +284,7 @@ void ONumOperator::Exec(OCodeStack& rCodeStack)
OOperand *pLeft = rCodeStack.top();
rCodeStack.pop();
- rCodeStack.push(new OOperandResultNUM(operate(pLeft->getValue(), pRight->getValue())));
+ rCodeStack.push(new OOperandResultNUM(operate(pLeft->getValue().getDouble(), pRight->getValue().getDouble())));
if( typeid(OOperandResult) == typeid(*pLeft))
delete pLeft;
if( typeid(OOperandResult) == typeid(*pRight))
diff --git a/connectivity/source/drivers/file/fcomp.cxx b/connectivity/source/drivers/file/fcomp.cxx
index 982d0266b949..45c9022340a9 100644
--- a/connectivity/source/drivers/file/fcomp.cxx
+++ b/connectivity/source/drivers/file/fcomp.cxx
@@ -22,9 +22,6 @@
#include <connectivity/sqlparse.hxx>
#include <file/fanalyzer.hxx>
#include <com/sun/star/sdbc/XColumnLocate.hpp>
-#include <com/sun/star/util/DateTime.hpp>
-#include <com/sun/star/util/Date.hpp>
-#include <com/sun/star/util/Time.hpp>
#include <connectivity/dbexception.hxx>
#include <connectivity/dbconversion.hxx>
#include <com/sun/star/sdb/SQLFilterOperator.hpp>
@@ -32,7 +29,7 @@
#include <file/FDateFunctions.hxx>
#include <file/FNumericFunctions.hxx>
#include <file/FConnection.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <sqlbison.hxx>
#include <strings.hrc>
@@ -353,29 +350,29 @@ void OPredicateCompiler::execute_BETWEEN(OSQLParseNode const * pPredicateNode)
break;
case DataType::DECIMAL:
case DataType::NUMERIC:
- pOb1->setValue(static_cast<double>(pOb1->getValue()));
- pOb2->setValue(static_cast<double>(pOb2->getValue()));
+ pOb1->setValue(pOb1->getValue().getDouble());
+ pOb2->setValue(pOb2->getValue().getDouble());
break;
case DataType::FLOAT:
- pOb1->setValue(static_cast<float>(pOb1->getValue()));
- pOb2->setValue(static_cast<float>(pOb2->getValue()));
+ pOb1->setValue(pOb1->getValue().getFloat());
+ pOb2->setValue(pOb2->getValue().getFloat());
break;
case DataType::DOUBLE:
case DataType::REAL:
- pOb1->setValue(static_cast<double>(pOb1->getValue()));
- pOb2->setValue(static_cast<double>(pOb2->getValue()));
+ pOb1->setValue(pOb1->getValue().getDouble());
+ pOb2->setValue(pOb2->getValue().getDouble());
break;
case DataType::DATE:
- pOb1->setValue(static_cast<util::Date>(pOb1->getValue()));
- pOb2->setValue(static_cast<util::Date>(pOb2->getValue()));
+ pOb1->setValue(pOb1->getValue().getDate());
+ pOb2->setValue(pOb2->getValue().getDate());
break;
case DataType::TIME:
- pOb1->setValue(static_cast<util::Time>(pOb1->getValue()));
- pOb2->setValue(static_cast<util::Time>(pOb2->getValue()));
+ pOb1->setValue(pOb1->getValue().getTime());
+ pOb2->setValue(pOb2->getValue().getTime());
break;
case DataType::TIMESTAMP:
- pOb1->setValue(static_cast<util::DateTime>(pOb1->getValue()));
- pOb2->setValue(static_cast<util::DateTime>(pOb2->getValue()));
+ pOb1->setValue(pOb1->getValue().getDateTime());
+ pOb2->setValue(pOb2->getValue().getDateTime());
break;
}
}
@@ -457,7 +454,7 @@ OOperand* OPredicateCompiler::execute_Operand(OSQLParseNode const * pPredicateNo
}
else if (SQL_ISRULE(pPredicateNode,parameter))
{
- pOperand = new OOperandParam(pPredicateNode, ++m_nParamCounter);
+ pOperand = new OOperandParam(++m_nParamCounter);
}
else if (pPredicateNode->getNodeType() == SQLNodeType::String ||
pPredicateNode->getNodeType() == SQLNodeType::IntNum ||
@@ -533,8 +530,6 @@ OOperand* OPredicateCompiler::execute_Operand(OSQLParseNode const * pPredicateNo
bool OPredicateInterpreter::evaluate(OCodeList& rCodeList)
{
- static bool bResult;
-
if (!(rCodeList[0]))
return true; // no Predicate
@@ -553,7 +548,7 @@ bool OPredicateInterpreter::evaluate(OCodeList& rCodeList)
DBG_ASSERT(m_aStack.empty(), "Stack error");
DBG_ASSERT(pOperand, "Stack error");
- bResult = pOperand->isValid();
+ const bool bResult = pOperand->isValid();
if (typeid(OOperandResult) == typeid(*pOperand))
delete pOperand;
return bResult;