Kaydet (Commit) 112bdf84 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Removed dangerous rtl::O[U]String[Buffer]::operator sal_{char,Unicode} const *.

As a replacement, added appropriate operator [] functions.  All other uses can
use getStr().
üst 02f7ab6a
......@@ -287,12 +287,18 @@ public:
/**
Return a null terminated character array.
*/
operator const sal_Char *() const { return pData->buffer; }
const sal_Char* getStr() const { return pData->buffer; }
/**
Return a null terminated character array.
*/
const sal_Char* getStr() const { return pData->buffer; }
Access to individual characters.
@param index must be non-negative and less than length.
@return a reference to the character at the given index.
@since LibreOffice 3.5
*/
sal_Char & operator [](sal_Int32 index) { return pData->buffer[index]; }
/**
Return a OString instance reflecting the current content
......
......@@ -248,19 +248,6 @@ public:
return sal_True;
}
/**
Returns a pointer to the characters of this string.
<p>The returned pointer is not guaranteed to point to a null-terminated
byte string. Note that this string object may contain embedded null
characters, which will thus also be embedded in the returned byte
string.</p>
@return a pointer to a (not necessarily null-terminated) byte string
representing the characters of this string object.
*/
operator const sal_Char *() const SAL_THROW(()) { return pData->buffer; }
/**
Returns a pointer to the characters of this string.
......@@ -274,6 +261,17 @@ public:
*/
const sal_Char * getStr() const SAL_THROW(()) { return pData->buffer; }
/**
Access to individual characters.
@param index must be non-negative and less than length.
@return the character at the given index.
@since LibreOffice 3.5
*/
sal_Char operator [](sal_Int32 index) const { return getStr()[index]; }
/**
Compares two strings.
......
......@@ -267,12 +267,18 @@ public:
/**
Return a null terminated unicode character array.
*/
operator const sal_Unicode *() const { return pData->buffer; }
const sal_Unicode* getStr() const { return pData->buffer; }
/**
Return a null terminated unicode character array.
*/
const sal_Unicode* getStr() const { return pData->buffer; }
Access to individual characters.
@param index must be non-negative and less than length.
@return a reference to the character at the given index.
@since LibreOffice 3.5
*/
sal_Unicode & operator [](sal_Int32 index) { return pData->buffer[index]; }
/**
Return a OUString instance reflecting the current content
......
......@@ -300,16 +300,18 @@ public:
@return a pointer to the Unicode characters buffer from this object.
*/
operator const sal_Unicode *() const SAL_THROW(()) { return pData->buffer; }
const sal_Unicode * getStr() const SAL_THROW(()) { return pData->buffer; }
/**
Returns a pointer to the Unicode character buffer from this string.
Access to individual characters.
It isn't necessarily NULL terminated.
@param index must be non-negative and less than length.
@return a pointer to the Unicode characters buffer from this object.
@return the character at the given index.
@since LibreOffice 3.5
*/
const sal_Unicode * getStr() const SAL_THROW(()) { return pData->buffer; }
sal_Unicode operator [](sal_Int32 index) const { return getStr()[index]; }
/**
Compares two strings.
......
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