summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sal/inc/rtl/strbuf.hxx14
-rw-r--r--sal/inc/rtl/string.hxx24
-rw-r--r--sal/inc/rtl/ustrbuf.hxx14
-rw-r--r--sal/inc/rtl/ustring.hxx12
4 files changed, 38 insertions, 26 deletions
diff --git a/sal/inc/rtl/strbuf.hxx b/sal/inc/rtl/strbuf.hxx
index 63ae448478b1..962d3dfda8a0 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 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
diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx
index 96ca40682bbb..22de6dd5be5c 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.
- <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.
-
<p>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 a356309c30d8..47569e5800b3 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 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
diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx
index ed268d9633ae..e104f0d40760 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.