diff options
Diffstat (limited to 'include/rtl/ustring.hxx')
-rw-r--r-- | include/rtl/ustring.hxx | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx index f3006847de1e..48aca3243383 100644 --- a/include/rtl/ustring.hxx +++ b/include/rtl/ustring.hxx @@ -2300,6 +2300,46 @@ public: return OUString( pNew, SAL_NO_ACQUIRE ); } +#if defined LIBO_INTERNAL_ONLY + /** + Returns a std::u16string_view that is a view of a substring of this string. + + The substring begins at the specified beginIndex. If + beginIndex is negative or be greater than the length of + this string, behaviour is undefined. + + @param beginIndex the beginning index, inclusive. + @return the specified substring. + */ + SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex ) const + { + assert(beginIndex >= 0); + assert(beginIndex <= getLength()); + return subView(beginIndex, getLength() - beginIndex); + } + + /** + Returns a std::u16string_view that is a view of a substring of this string. + + The substring begins at the specified beginIndex and contains count + characters. If either beginIndex or count are negative, + or beginIndex + count are greater than the length of this string + then behaviour is undefined. + + @param beginIndex the beginning index, inclusive. + @param count the number of characters. + @return the specified substring. + */ + SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex, sal_Int32 count ) const + { + assert(beginIndex >= 0); + assert(count >= 0); + assert(beginIndex <= getLength()); + assert(count <= getLength() - beginIndex); + return std::u16string_view(*this).substr(beginIndex, count); + } +#endif + #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" /** Concatenates the specified string to the end of this string. |