diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-12-19 16:10:51 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-12-21 08:26:15 +0100 |
commit | d425658bd9fd8e315e4931afb544bc845da0360e (patch) | |
tree | a35679686a7df2a504b9088ba6807b60c52067fc /connectivity/source/commontools | |
parent | 526387b96e9bc2c04b0dc26744bf6b88ea7c0521 (diff) |
pass OSQLParseNode around by unique_ptr
Change-Id: I8ffb9e04614472c3645d24bebdc88f91059d12ad
Reviewed-on: https://gerrit.libreoffice.org/65436
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'connectivity/source/commontools')
-rw-r--r-- | connectivity/source/commontools/ParameterSubstitution.cxx | 5 | ||||
-rw-r--r-- | connectivity/source/commontools/predicateinput.cxx | 22 |
2 files changed, 12 insertions, 15 deletions
diff --git a/connectivity/source/commontools/ParameterSubstitution.cxx b/connectivity/source/commontools/ParameterSubstitution.cxx index dfec360b23e5..a8efa6c6a694 100644 --- a/connectivity/source/commontools/ParameterSubstitution.cxx +++ b/connectivity/source/commontools/ParameterSubstitution.cxx @@ -83,12 +83,11 @@ namespace connectivity OSQLParser aParser( m_xContext ); OUString sErrorMessage; OUString sNewSql; - OSQLParseNode* pNode = aParser.parseTree(sErrorMessage,_sText); + std::unique_ptr<OSQLParseNode> pNode = aParser.parseTree(sErrorMessage,_sText); if(pNode) { // special handling for parameters - OSQLParseNode::substituteParameterNames(pNode); + OSQLParseNode::substituteParameterNames(pNode.get()); pNode->parseNodeToStr( sNewSql, xConnection ); - delete pNode; sRet = sNewSql; } } diff --git a/connectivity/source/commontools/predicateinput.cxx b/connectivity/source/commontools/predicateinput.cxx index fbc9c0bbb40e..b7a08ef57309 100644 --- a/connectivity/source/commontools/predicateinput.cxx +++ b/connectivity/source/commontools/predicateinput.cxx @@ -123,9 +123,9 @@ namespace dbtools } - OSQLParseNode* OPredicateInputController::implPredicateTree(OUString& _rErrorMessage, const OUString& _rStatement, const Reference< XPropertySet > & _rxField) const + std::unique_ptr<OSQLParseNode> OPredicateInputController::implPredicateTree(OUString& _rErrorMessage, const OUString& _rStatement, const Reference< XPropertySet > & _rxField) const { - OSQLParseNode* pReturn = const_cast< OSQLParser& >( m_aParser ).predicateTree( _rErrorMessage, _rStatement, m_xFormatter, _rxField ); + std::unique_ptr<OSQLParseNode> pReturn = const_cast< OSQLParser& >( m_aParser ).predicateTree( _rErrorMessage, _rStatement, m_xFormatter, _rxField ); if ( !pReturn ) { // is it a text field ? sal_Int32 nType = DataType::OTHER; @@ -242,7 +242,7 @@ namespace dbtools // parse the string OUString sError; OUString sTransformedText( _rPredicateValue ); - OSQLParseNode* pParseNode = implPredicateTree( sError, sTransformedText, _rxField ); + std::unique_ptr<OSQLParseNode> pParseNode = implPredicateTree( sError, sTransformedText, _rxField ); if ( _pErrorMessage ) *_pErrorMessage = sError; if ( pParseNode ) @@ -258,7 +258,6 @@ namespace dbtools rParseContext.getPreferredLocale(), static_cast<sal_Char>(nDecSeparator), &rParseContext ); _rPredicateValue = sTransformedText; - delete pParseNode; bSuccess = true; } @@ -279,9 +278,9 @@ namespace dbtools // (dbaccess/source/ui/dlg/paramdialog.cxx). I do not fully understand this ..... OUString sError; - OSQLParseNode* pParseNode = implPredicateTree( sError, _rPredicateValue, _rxField ); + std::unique_ptr<OSQLParseNode> pParseNode = implPredicateTree( sError, _rPredicateValue, _rxField ); - implParseNode(pParseNode, true) >>= sReturn; + implParseNode(std::move(pParseNode), true) >>= sReturn; } return sReturn; @@ -325,10 +324,10 @@ namespace dbtools pColumn->setFunction(true); pColumn->setRealName(sField); - OSQLParseNode* pParseNode = implPredicateTree( sError, _rPredicateValue, xColumn ); + std::unique_ptr<OSQLParseNode> pParseNode = implPredicateTree( sError, _rPredicateValue, xColumn ); if(pParseNode) { - implParseNode(pParseNode, true) >>= sReturn; + implParseNode(std::move(pParseNode), true) >>= sReturn; } return sReturn; } @@ -344,22 +343,21 @@ namespace dbtools // (dbaccess/source/ui/dlg/paramdialog.cxx). I do not fully understand this ..... OUString sError; - OSQLParseNode* pParseNode = implPredicateTree( sError, _rPredicateValue, _rxField ); + std::unique_ptr<OSQLParseNode> pParseNode = implPredicateTree( sError, _rPredicateValue, _rxField ); - return implParseNode(pParseNode, false); + return implParseNode(std::move(pParseNode), false); } return Any(); } - Any OPredicateInputController::implParseNode(OSQLParseNode* pParseNode, bool _bForStatementUse) const + Any OPredicateInputController::implParseNode(std::unique_ptr<OSQLParseNode> pParseNode, bool _bForStatementUse) const { if ( ! pParseNode ) return Any(); else { OUString sReturn; - std::shared_ptr<OSQLParseNode> xTakeOwnership(pParseNode); OSQLParseNode* pOdbcSpec = pParseNode->getByRule( OSQLParseNode::odbc_fct_spec ); if ( pOdbcSpec ) { |