Kaydet (Commit) 0866023f authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Get rid of std::auto_ptr in stable URE interface

...the deprecation-warning noise is getting ever louder, and eventually auto_ptr
will just disappear.  Just surrender and use good-old plain pointer and deletion
in dtor---it's probably the best to do in this stable interface.

The change is backwards compatible.  For one, in all relevant standard libraries
(libstdc++, even in debug mode; libc++; msvcrt) sizeof(auto_ptr<T>) equals
sizeof(T*).  And for another, the removed UnoUrlDescriptor ctor was only called
from within cppuhelper and had deliberately been left out of
cppuhelper/source/gcc3.map (so isn't exported at least on Linux)---marking it
SAL_DLLPRIVATE had probably just been forgotten when retrofitting cppuhelper
with CPPUHELPER_DLLPUBLIC annotations.

Change-Id: Ic8bce29d93938f2b2e0a264baee85132668e1294
üst 779581fe
...@@ -199,6 +199,7 @@ OPropertySetHelper2::OPropertySetHelper2( ...@@ -199,6 +199,7 @@ OPropertySetHelper2::OPropertySetHelper2(
*/ */
OPropertySetHelper::~OPropertySetHelper() OPropertySetHelper::~OPropertySetHelper()
{ {
delete m_pReserved;
} }
OPropertySetHelper2::~OPropertySetHelper2() OPropertySetHelper2::~OPropertySetHelper2()
{ {
...@@ -631,8 +632,6 @@ void OPropertySetHelper::fire ...@@ -631,8 +632,6 @@ void OPropertySetHelper::fire
sal_Bool bVetoable sal_Bool bVetoable
) )
{ {
OSL_ENSURE( m_pReserved.get(), "No OPropertySetHelper::Impl" );
if (! m_pReserved->m_bFireEvents) if (! m_pReserved->m_bFireEvents)
return; return;
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <sal/types.h> #include <sal/types.h>
#include <map> #include <map>
#include <memory>
using cppu::UnoUrl; using cppu::UnoUrl;
using cppu::UnoUrlDescriptor; using cppu::UnoUrlDescriptor;
...@@ -137,49 +138,47 @@ inline UnoUrlDescriptor::Impl::Impl(rtl::OUString const & rDescriptor) ...@@ -137,49 +138,47 @@ inline UnoUrlDescriptor::Impl::Impl(rtl::OUString const & rDescriptor)
} }
UnoUrlDescriptor::UnoUrlDescriptor(rtl::OUString const & rDescriptor): UnoUrlDescriptor::UnoUrlDescriptor(rtl::OUString const & rDescriptor):
m_xImpl(new Impl(rDescriptor)) m_pImpl(new Impl(rDescriptor))
{} {}
SAL_WNODEPRECATED_DECLARATIONS_PUSH
UnoUrlDescriptor::UnoUrlDescriptor(std::auto_ptr< Impl > & rImpl):
m_xImpl(rImpl)
{}
SAL_WNODEPRECATED_DECLARATIONS_POP
UnoUrlDescriptor::UnoUrlDescriptor(UnoUrlDescriptor const & rOther): UnoUrlDescriptor::UnoUrlDescriptor(UnoUrlDescriptor const & rOther):
m_xImpl(rOther.m_xImpl->clone()) m_pImpl(rOther.m_pImpl->clone())
{} {}
UnoUrlDescriptor::~UnoUrlDescriptor() UnoUrlDescriptor::~UnoUrlDescriptor()
{} {
delete m_pImpl;
}
UnoUrlDescriptor & UnoUrlDescriptor::operator =(UnoUrlDescriptor const & rOther) UnoUrlDescriptor & UnoUrlDescriptor::operator =(UnoUrlDescriptor const & rOther)
{ {
m_xImpl.reset(rOther.m_xImpl->clone()); std::unique_ptr<Impl> newImpl(rOther.m_pImpl->clone());
delete m_pImpl;
m_pImpl = newImpl.release();
return *this; return *this;
} }
rtl::OUString const & UnoUrlDescriptor::getDescriptor() const rtl::OUString const & UnoUrlDescriptor::getDescriptor() const
{ {
return m_xImpl->m_aDescriptor; return m_pImpl->m_aDescriptor;
} }
rtl::OUString const & UnoUrlDescriptor::getName() const rtl::OUString const & UnoUrlDescriptor::getName() const
{ {
return m_xImpl->m_aName; return m_pImpl->m_aName;
} }
bool UnoUrlDescriptor::hasParameter(rtl::OUString const & rKey) const bool UnoUrlDescriptor::hasParameter(rtl::OUString const & rKey) const
{ {
return m_xImpl->m_aParameters.find(rKey.toAsciiLowerCase()) return m_pImpl->m_aParameters.find(rKey.toAsciiLowerCase())
!= m_xImpl->m_aParameters.end(); != m_pImpl->m_aParameters.end();
} }
rtl::OUString UnoUrlDescriptor::getParameter(rtl::OUString const & rKey) const rtl::OUString UnoUrlDescriptor::getParameter(rtl::OUString const & rKey) const
{ {
Impl::Parameters::const_iterator Impl::Parameters::const_iterator
aIt(m_xImpl->m_aParameters.find(rKey.toAsciiLowerCase())); aIt(m_pImpl->m_aParameters.find(rKey.toAsciiLowerCase()));
return aIt == m_xImpl->m_aParameters.end() ? rtl::OUString() : aIt->second; return aIt == m_pImpl->m_aParameters.end() ? rtl::OUString() : aIt->second;
} }
class UnoUrl::Impl class UnoUrl::Impl
...@@ -196,15 +195,13 @@ public: ...@@ -196,15 +195,13 @@ public:
static inline Impl * create(rtl::OUString const & rUrl); static inline Impl * create(rtl::OUString const & rUrl);
private: private:
SAL_WNODEPRECATED_DECLARATIONS_PUSH Impl(rtl::OUString const & rConnectionDescriptor,
Impl(std::auto_ptr< UnoUrlDescriptor::Impl > & rConnection, rtl::OUString const & rProtocolDescriptor,
std::auto_ptr< UnoUrlDescriptor::Impl > & rProtocol, rtl::OUString const & rObjectName):
rtl::OUString const & rObjectName): m_aConnection(rConnectionDescriptor),
m_aConnection(rConnection), m_aProtocol(rProtocolDescriptor),
m_aProtocol(rProtocol),
m_aObjectName(rObjectName) m_aObjectName(rObjectName)
{} {}
SAL_WNODEPRECATED_DECLARATIONS_POP
}; };
inline UnoUrl::Impl * UnoUrl::Impl::create(rtl::OUString const & rUrl) inline UnoUrl::Impl * UnoUrl::Impl::create(rtl::OUString const & rUrl)
...@@ -217,19 +214,13 @@ inline UnoUrl::Impl * UnoUrl::Impl::create(rtl::OUString const & rUrl) ...@@ -217,19 +214,13 @@ inline UnoUrl::Impl * UnoUrl::Impl::create(rtl::OUString const & rUrl)
if (j < 0) if (j < 0)
throw rtl::MalformedUriException( throw rtl::MalformedUriException(
rtl::OUString("UNO URL has too few semicolons")); rtl::OUString("UNO URL has too few semicolons"));
SAL_WNODEPRECATED_DECLARATIONS_PUSH rtl::OUString aConnection(rUrl.copy(i, j - i));
std::auto_ptr< UnoUrlDescriptor::Impl >
xConnection(new UnoUrlDescriptor::Impl(rUrl.copy(i, j - i)));
SAL_WNODEPRECATED_DECLARATIONS_POP
i = j + 1; i = j + 1;
j = rUrl.indexOf(0x3B, i); // ';' j = rUrl.indexOf(0x3B, i); // ';'
if (j < 0) if (j < 0)
throw rtl::MalformedUriException( throw rtl::MalformedUriException(
rtl::OUString("UNO URL has too few semicolons")); rtl::OUString("UNO URL has too few semicolons"));
SAL_WNODEPRECATED_DECLARATIONS_PUSH rtl::OUString aProtocol(rUrl.copy(i, j - i));
std::auto_ptr< UnoUrlDescriptor::Impl >
xProtocol(new UnoUrlDescriptor::Impl(rUrl.copy(i, j - i)));
SAL_WNODEPRECATED_DECLARATIONS_POP
i = j + 1; i = j + 1;
if (i == rUrl.getLength()) if (i == rUrl.getLength())
throw rtl::MalformedUriException( throw rtl::MalformedUriException(
...@@ -247,37 +238,41 @@ inline UnoUrl::Impl * UnoUrl::Impl::create(rtl::OUString const & rUrl) ...@@ -247,37 +238,41 @@ inline UnoUrl::Impl * UnoUrl::Impl::create(rtl::OUString const & rUrl)
throw rtl::MalformedUriException( throw rtl::MalformedUriException(
rtl::OUString("UNO URL contains invalid ObjectName")); rtl::OUString("UNO URL contains invalid ObjectName"));
} }
return new Impl(xConnection, xProtocol, rUrl.copy(i)); return new Impl(aConnection, aProtocol, rUrl.copy(i));
} }
UnoUrl::UnoUrl(rtl::OUString const & rUrl): m_xImpl(Impl::create(rUrl)) UnoUrl::UnoUrl(rtl::OUString const & rUrl): m_pImpl(Impl::create(rUrl))
{} {}
UnoUrl::UnoUrl(UnoUrl const & rOther): m_xImpl(rOther.m_xImpl->clone()) UnoUrl::UnoUrl(UnoUrl const & rOther): m_pImpl(rOther.m_pImpl->clone())
{} {}
UnoUrl::~UnoUrl() UnoUrl::~UnoUrl()
{} {
delete m_pImpl;
}
UnoUrl & UnoUrl::operator =(UnoUrl const & rOther) UnoUrl & UnoUrl::operator =(UnoUrl const & rOther)
{ {
m_xImpl.reset(rOther.m_xImpl->clone()); std::unique_ptr<Impl> newImpl(rOther.m_pImpl->clone());
delete m_pImpl;
m_pImpl = newImpl.release();
return *this; return *this;
} }
UnoUrlDescriptor const & UnoUrl::getConnection() const UnoUrlDescriptor const & UnoUrl::getConnection() const
{ {
return m_xImpl->m_aConnection; return m_pImpl->m_aConnection;
} }
UnoUrlDescriptor const & UnoUrl::getProtocol() const UnoUrlDescriptor const & UnoUrl::getProtocol() const
{ {
return m_xImpl->m_aProtocol; return m_pImpl->m_aProtocol;
} }
rtl::OUString const & UnoUrl::getObjectName() const rtl::OUString const & UnoUrl::getObjectName() const
{ {
return m_xImpl->m_aObjectName; return m_pImpl->m_aObjectName;
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include <com/sun/star/beans/XMultiPropertySet.hpp> #include <com/sun/star/beans/XMultiPropertySet.hpp>
#include <com/sun/star/beans/XFastPropertySet.hpp> #include <com/sun/star/beans/XFastPropertySet.hpp>
#include <memory>
#include <cppuhelper/cppuhelperdllapi.h> #include <cppuhelper/cppuhelperdllapi.h>
...@@ -649,7 +648,7 @@ protected: ...@@ -649,7 +648,7 @@ protected:
/** reserved for future use. finally, the future has arrived... /** reserved for future use. finally, the future has arrived...
*/ */
const std::auto_ptr<Impl> m_pReserved; Impl * const m_pReserved;
private: private:
OPropertySetHelper( const OPropertySetHelper & ); OPropertySetHelper( const OPropertySetHelper & );
......
...@@ -20,7 +20,8 @@ ...@@ -20,7 +20,8 @@
#ifndef INCLUDED_CPPUHELPER_UNOURL_HXX #ifndef INCLUDED_CPPUHELPER_UNOURL_HXX
#define INCLUDED_CPPUHELPER_UNOURL_HXX #define INCLUDED_CPPUHELPER_UNOURL_HXX
#include <memory> #include <sal/config.h>
#include <cppuhelper/cppuhelperdllapi.h> #include <cppuhelper/cppuhelperdllapi.h>
namespace rtl { class OUString; } namespace rtl { class OUString; }
...@@ -49,10 +50,6 @@ public: ...@@ -49,10 +50,6 @@ public:
*/ */
explicit UnoUrlDescriptor(rtl::OUString const & rDescriptor); explicit UnoUrlDescriptor(rtl::OUString const & rDescriptor);
/// @cond INTERNAL
explicit UnoUrlDescriptor(std::auto_ptr< Impl > & rImpl);
/// @endcond
UnoUrlDescriptor(UnoUrlDescriptor const & rOther); UnoUrlDescriptor(UnoUrlDescriptor const & rOther);
~UnoUrlDescriptor(); ~UnoUrlDescriptor();
...@@ -98,7 +95,7 @@ public: ...@@ -98,7 +95,7 @@ public:
rtl::OUString getParameter(rtl::OUString const & rKey) const; rtl::OUString getParameter(rtl::OUString const & rKey) const;
private: private:
std::auto_ptr< Impl > m_xImpl; Impl * m_pImpl;
}; };
/** Parse UNO URLs into their components. /** Parse UNO URLs into their components.
...@@ -175,7 +172,7 @@ public: ...@@ -175,7 +172,7 @@ public:
private: private:
class Impl; class Impl;
std::auto_ptr< Impl > m_xImpl; Impl * m_pImpl;
}; };
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment