cid#1371226 Missing move assignment operator

Change-Id: I915b24d8f546f156b85ad18ad0418903fa3ce1ba
This commit is contained in:
Noel Grandin
2016-08-25 14:44:08 +02:00
parent 6380dde50f
commit 2b8c88b475
2 changed files with 24 additions and 0 deletions

View File

@@ -27,9 +27,11 @@ public:
SharedString( rtl_uString* pData, rtl_uString* pDataIgnoreCase );
explicit SharedString( const OUString& rStr );
SharedString( const SharedString& r );
SharedString( SharedString&& r );
~SharedString();
SharedString& operator= ( const SharedString& r );
SharedString& operator= ( SharedString&& r );
bool operator== ( const SharedString& r ) const;
bool operator!= ( const SharedString& r ) const;

View File

@@ -44,6 +44,12 @@ SharedString::SharedString( const SharedString& r ) : mpData(r.mpData), mpDataIg
rtl_uString_acquire(mpDataIgnoreCase);
}
SharedString::SharedString( SharedString&& r ) : mpData(r.mpData), mpDataIgnoreCase(r.mpDataIgnoreCase)
{
r.mpData = nullptr;
r.mpDataIgnoreCase = nullptr;
}
SharedString::~SharedString()
{
if (mpData)
@@ -70,6 +76,22 @@ SharedString& SharedString::operator= ( const SharedString& r )
return *this;
}
SharedString& SharedString::operator= ( SharedString&& r )
{
if (mpData)
rtl_uString_release(mpData);
if (mpDataIgnoreCase)
rtl_uString_release(mpDataIgnoreCase);
mpData = r.mpData;
mpDataIgnoreCase = r.mpDataIgnoreCase;
r.mpData = nullptr;
r.mpDataIgnoreCase = nullptr;
return *this;
}
bool SharedString::operator== ( const SharedString& r ) const
{
// Only compare case sensitive strings.