OString/OUString: move constructors and operator=

Change-Id: Icdc5f7137cca8360f116d5d4c7b0bf4a4c526e1d
Reviewed-on: https://gerrit.libreoffice.org/20712
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
This commit is contained in:
Noel Grandin
2015-12-15 11:23:14 +02:00
committed by Noel Grandin
parent 15614c847d
commit c9f6e12e7e
3 changed files with 65 additions and 1 deletions

View File

@@ -114,6 +114,21 @@ public:
rtl_string_acquire( pData );
}
#if defined LIBO_INTERNAL_ONLY
/**
Move constructor.
@param str a OString.
@since LibreOffice 5.2
*/
OString( OString && str )
{
pData = str.pData;
str.pData = nullptr;
rtl_string_new( &str.pData );
}
#endif
/**
New string from OString data.
@@ -281,6 +296,23 @@ public:
return *this;
}
#if defined LIBO_INTERNAL_ONLY
/**
Move assign a new string.
@param str a OString.
@since LibreOffice 5.2
*/
OString & operator=( OString && str )
{
rtl_string_release( pData );
pData = str.pData;
str.pData = nullptr;
rtl_string_new( &str.pData );
return *this;
}
#endif
/**
@overload
This function accepts an ASCII string literal as its argument.

View File

@@ -130,6 +130,21 @@ public:
rtl_uString_acquire( pData );
}
#if defined LIBO_INTERNAL_ONLY
/**
Move constructor.
@param str a OUString.
@since LibreOffice 5.2
*/
OUString( OUString && str )
{
pData = str.pData;
str.pData = nullptr;
rtl_uString_new( &str.pData );
}
#endif
/**
New string from OUString data.
@@ -386,6 +401,23 @@ public:
return *this;
}
#if defined LIBO_INTERNAL_ONLY
/**
Move assign a new string.
@param str a OString.
@since LibreOffice 5.2
*/
OUString & operator=( OUString && str )
{
rtl_uString_release( pData );
pData = str.pData;
str.pData = nullptr;
rtl_uString_new( &str.pData );
return *this;
}
#endif
/**
Assign a new string from an 8-Bit string literal that is expected to contain only
characters in the ASCII set (i.e. first 128 characters). This operator

View File

@@ -33,7 +33,7 @@
/* ======================================================================= */
/*
* refCount is opaqueincludes 2 bit-fields;
* refCount is opaque and includes 2 bit-fields;
* MSB: 'interned' - is stored in the intern hash
* MSB-1: 'static' - is a const / static string,
* do no ref counting