diff --git a/sal/inc/rtl/strbuf.hxx b/sal/inc/rtl/strbuf.hxx index 63ae448..e485e7d 100644 --- a/sal/inc/rtl/strbuf.hxx +++ b/sal/inc/rtl/strbuf.hxx @@ -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 the character at the given index. + + @since LibreOffice 3.5 + */ + sal_Char operator [](sal_Int32 index) const { return getStr()[index]; } /** Return a OString instance reflecting the current content diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx index 96ca406..22de6dd 100644 --- a/sal/inc/rtl/string.hxx +++ b/sal/inc/rtl/string.hxx @@ -251,19 +251,6 @@ public: /** Returns a pointer to the characters of this string. -

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.

- - @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. -

The returned pointer is guaranteed to point to a null-terminated byte string. But note that this string object may contain embedded null characters, which will thus also be embedded in the returned @@ -275,6 +262,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. The comparison is based on the numeric value of each character in diff --git a/sal/inc/rtl/ustrbuf.hxx b/sal/inc/rtl/ustrbuf.hxx index a356309..a995dcd 100644 --- a/sal/inc/rtl/ustrbuf.hxx +++ b/sal/inc/rtl/ustrbuf.hxx @@ -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 the character at the given index. + + @since LibreOffice 3.5 + */ + sal_Unicode operator [](sal_Int32 index) const { return getStr()[index]; } /** Return a OUString instance reflecting the current content diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx index ed268d9..e104f0d 100644 --- a/sal/inc/rtl/ustring.hxx +++ b/sal/inc/rtl/ustring.hxx @@ -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.