LibreOffice: rtl::OUStringBuffer Class Reference

LibreOffice LibreOffice 26.8 SDK C/C++ API Reference

Loading...
Searching...
No Matches
rtl::OUStringBuffer Class Reference

A string buffer implements a mutable sequence of characters. More...

`#include <ustrbuf.hxx>`

## Public Member Functions
| OUStringBuffer ()
| Constructs a string buffer with no characters in it and an initial capacity of 16 characters.
| OUStringBuffer (const OUStringBuffer &value)
| Allocates a new string buffer that contains the same sequence of characters as the string buffer argument.
| OUStringBuffer (sal_Int32 length)
| Constructs a string buffer with no characters in it and an initial capacity specified by the `length` argument.
| OUStringBuffer (const OUString &value)
| Constructs a string buffer so that it represents the same sequence of characters as the string argument.
template<typename T>
| OUStringBuffer (T &literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
OUStringBuffer & | operator= (const OUStringBuffer &value)
| Assign to this a copy of value.
OUStringBuffer & | operator= (OUString const &string)
| Assign from a string.
template<typename T>
libreoffice_internal::ConstCharArrayDetector< T, OUStringBuffer & >::Type | operator= (T &literal)
| Assign from a string literal.
| ~OUStringBuffer ()
| Release the string data.
SAL_WARN_UNUSED_RESULT OUString | makeStringAndClear ()
| Fill the string data in the new string and clear the buffer.
sal_Int32 | getLength () const
| Returns the length (character count) of this string buffer.
bool | isEmpty () const
| Checks if a string buffer is empty.
sal_Int32 | getCapacity () const
| Returns the current capacity of the String buffer.
void | ensureCapacity (sal_Int32 minimumCapacity)
| Ensures that the capacity of the buffer is at least equal to the specified minimum.
void | setLength (sal_Int32 newLength)
| Sets the length of this String buffer.
sal_Unicode | charAt (sal_Int32 index) const
| Returns the character at a specific index in this string buffer.
OUStringBuffer & | setCharAt (sal_Int32 index, sal_Unicode ch)
| The character at the specified index of this string buffer is set to `ch`.
const sal_Unicode * | getStr () const SAL_RETURNS_NONNULL
| Return a null terminated unicode character array.
sal_Unicode & | operator[] (sal_Int32 index)
| Access to individual characters.
const sal_Unicode & | operator[] (sal_Int32 index) const
| Access to individual characters.
OUString | toString () const
| Return an OUString instance reflecting the current content of this OUStringBuffer.
OUStringBuffer & | append (const OUString &str)
| Appends the string to this string buffer.
OUStringBuffer & | append (const OUStringBuffer &str)
| Appends the content of a stringbuffer to this string buffer.
OUStringBuffer & | append (const sal_Unicode *str)
| Appends the string representation of the `char` array argument to this string buffer.
OUStringBuffer & | append (const sal_Unicode *str, sal_Int32 len)
| Appends the string representation of the `char` array argument to this string buffer.
template<typename T>
libreoffice_internal::ConstCharArrayDetector< T, OUStringBuffer & >::Type | append (T &literal)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument.
OUStringBuffer & | appendAscii (const char *str)
| Appends a 8-Bit ASCII character string to this string buffer.
OUStringBuffer & | appendAscii (const char *str, sal_Int32 len)
| Appends a 8-Bit ASCII character string to this string buffer.
OUStringBuffer & | append (bool b)
| Appends the string representation of the `bool` argument to the string buffer.
OUStringBuffer & | append (rtl_uString *str)
OUStringBuffer & | append (sal_Bool b)
| Appends the string representation of the `sal_Bool` argument to the string buffer.
OUStringBuffer & | append (char c)
| Appends the string representation of the ASCII `char` argument to this string buffer.
OUStringBuffer & | append (sal_Unicode c)
| Appends the string representation of the `char` argument to this string buffer.
OUStringBuffer & | append (sal_Int32 i, sal_Int16 radix=10)
| Appends the string representation of the `sal_Int32` argument to this string buffer.
OUStringBuffer & | append (sal_Int64 l, sal_Int16 radix=10)
| Appends the string representation of the `long` argument to this string buffer.
OUStringBuffer & | append (float f)
| Appends the string representation of the `float` argument to this string buffer.
OUStringBuffer & | append (double d)
| Appends the string representation of the `double` argument to this string buffer.
OUStringBuffer & | appendUtf32 (sal_uInt32 c)
| Appends a single UTF-32 character to this string buffer.
sal_Unicode * | appendUninitialized (sal_Int32 length) SAL_RETURNS_NONNULL
| Unsafe way to make space for a fixed amount of characters to be appended into this OUStringBuffer.
OUStringBuffer & | insert (sal_Int32 offset, const OUString &str)
| Inserts the string into this string buffer.
OUStringBuffer & | insert (sal_Int32 offset, const sal_Unicode *str)
| Inserts the string representation of the `char` array argument into this string buffer.
OUStringBuffer & | insert (sal_Int32 offset, const sal_Unicode *str, sal_Int32 len)
| Inserts the string representation of the `char` array argument into this string buffer.
template<typename T>
libreoffice_internal::ConstCharArrayDetector< T, OUStringBuffer & >::Type | insert (sal_Int32 offset, T &literal)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument.
OUStringBuffer & | insert (sal_Int32 offset, sal_Bool b)
| Inserts the string representation of the `sal_Bool` argument into this string buffer.
OUStringBuffer & | insert (sal_Int32 offset, bool b)
| Inserts the string representation of the `bool` argument into this string buffer.
OUStringBuffer & | insert (sal_Int32 offset, char c)
| Inserts the string representation of the `char` argument into this string buffer.
OUStringBuffer & | insert (sal_Int32 offset, sal_Unicode c)
| Inserts the string representation of the `char` argument into this string buffer.
OUStringBuffer & | insert (sal_Int32 offset, sal_Int32 i, sal_Int16 radix=10)
| Inserts the string representation of the second `sal_Int32` argument into this string buffer.
OUStringBuffer & | insert (sal_Int32 offset, sal_Int64 l, sal_Int16 radix=10)
| Inserts the string representation of the `long` argument into this string buffer.
OUStringBuffer & | insert (sal_Int32 offset, float f)
| Inserts the string representation of the `float` argument into this string buffer.
OUStringBuffer & | insert (sal_Int32 offset, double d)
| Inserts the string representation of the `double` argument into this string buffer.
OUStringBuffer & | insertUtf32 (sal_Int32 offset, sal_uInt32 c)
| Inserts a single UTF-32 character into this string buffer.
OUStringBuffer & | remove (sal_Int32 start, sal_Int32 len)
| Removes the characters in a substring of this sequence.
OUStringBuffer & | truncate (sal_Int32 start=0)
| Removes the tail of a string buffer start at the indicate position.
OUStringBuffer & | replace (sal_Unicode oldChar, sal_Unicode newChar)
| Replace all occurrences of oldChar in this string buffer with newChar.
void | accessInternals (rtl_uString ***pInternalData, sal_Int32 **pInternalCapacity)
| Allows access to the internal data of this OUStringBuffer, for effective manipulation.
sal_Int32 | indexOf (sal_Unicode ch, sal_Int32 fromIndex=0) const
| Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.
sal_Int32 | lastIndexOf (sal_Unicode ch) const
| Returns the index within this string of the last occurrence of the specified character, searching backward starting at the end.
sal_Int32 | lastIndexOf (sal_Unicode ch, sal_Int32 fromIndex) const
| Returns the index within this string of the last occurrence of the specified character, searching backward starting before the specified index.
sal_Int32 | indexOf (const OUString &str, sal_Int32 fromIndex=0) const
| Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
template<typename T>
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type | indexOf (T &literal, sal_Int32 fromIndex=0) const
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument.
sal_Int32 | lastIndexOf (const OUString &str) const
| Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the end.
sal_Int32 | lastIndexOf (const OUString &str, sal_Int32 fromIndex) const
| Returns the index within this string of the last occurrence of the specified substring, searching backward starting before the specified index.
template<typename T>
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type | lastIndexOf (T &literal) const
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument.
sal_Int32 | stripStart (sal_Unicode c=' ')
| Strip the given character from the start of the buffer.
sal_Int32 | stripEnd (sal_Unicode c=' ')
| Strip the given character from the end of the buffer.
sal_Int32 | strip (sal_Unicode c=' ')
| Strip the given character from the both end of the buffer.
OUStringBuffer | copy (sal_Int32 beginIndex) const
| Returns a new string buffer that is a substring of this string.
OUStringBuffer | copy (sal_Int32 beginIndex, sal_Int32 count) const
| Returns a new string buffer that is a substring of this string.

## Friends
class | OUString

## Detailed Description

A string buffer implements a mutable sequence of characters.

## Constructor & Destructor Documentation

## ◆ OUStringBuffer() [1/5]

rtl::OUStringBuffer::OUStringBuffer | ( |  | ) |
| inline

Constructs a string buffer with no characters in it and an initial capacity of 16 characters.

## ◆ OUStringBuffer() [2/5]

rtl::OUStringBuffer::OUStringBuffer | ( | const OUStringBuffer & | value | ) |
| inline

Allocates a new string buffer that contains the same sequence of characters as the string buffer argument.

Parameters

  value | a `OUStringBuffer`.

## ◆ OUStringBuffer() [3/5]

rtl::OUStringBuffer::OUStringBuffer | ( | sal_Int32 | length | ) |
| inlineexplicit

Constructs a string buffer with no characters in it and an initial capacity specified by the `length` argument.

Parameters

  length | the initial capacity.

## ◆ OUStringBuffer() [4/5]

rtl::OUStringBuffer::OUStringBuffer | ( | const OUString & | value | ) |
| inline

Constructs a string buffer so that it represents the same sequence of characters as the string argument.

The initial capacity of the string buffer is `16` plus the length of the string argument.

Parameters

  value | the initial contents of the buffer.

## ◆ OUStringBuffer() [5/5]

template<typename T>

rtl::OUStringBuffer::OUStringBuffer | ( | T & | literal,
|  | typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type | = libreoffice_internal::Dummy() )
| inline

## ◆ ~OUStringBuffer()

rtl::OUStringBuffer::~OUStringBuffer | ( |  | ) |
| inline

Release the string data.

## Member Function Documentation

## ◆ accessInternals()

void rtl::OUStringBuffer::accessInternals | ( | rtl_uString *** | pInternalData,
|  | sal_Int32 ** | pInternalCapacity )
| inline

Allows access to the internal data of this OUStringBuffer, for effective manipulation.

This method should be used with care. After you have called this method, you may use the returned pInternalData or pInternalCapacity only as long as you make no other method call on this OUStringBuffer.

Parameters

  pInternalData | This output parameter receives a pointer to the internal data (rtl_uString pointer). pInternalData itself must not be null.
  pInternalCapacity | This output parameter receives a pointer to the internal capacity. pInternalCapacity itself must not be null.

## ◆ append() [1/14]

OUStringBuffer & rtl::OUStringBuffer::append | ( | bool | b | ) |
| inline

Appends the string representation of the `bool` argument to the string buffer.

The argument is converted to a string as if by the method `String.valueOf`, and the characters of that string are then appended to this string buffer.

Parameters

  b | a `bool`.

Returns
  this string buffer.

Since
  LibreOffice 4.1

## ◆ append() [2/14]

OUStringBuffer & rtl::OUStringBuffer::append | ( | char | c | ) |
| inline

Appends the string representation of the ASCII `char` argument to this string buffer.

The argument is appended to the contents of this string buffer. The length of this string buffer increases by `1`.

Parameters

  c | an ASCII `char`.

Returns
  this string buffer.

Since
  LibreOffice 3.5

## ◆ append() [3/14]

OUStringBuffer & rtl::OUStringBuffer::append | ( | const OUString & | str | ) |
| inline

Appends the string to this string buffer.

The characters of the `OUString` argument are appended, in order, to the contents of this string buffer, increasing the length of this string buffer by the length of the argument.

Parameters

  str | a string.

Returns
  this string buffer.

## ◆ append() [4/14]

OUStringBuffer & rtl::OUStringBuffer::append | ( | const OUStringBuffer & | str | ) |
| inline

Appends the content of a stringbuffer to this string buffer.

The characters of the `OUStringBuffer` argument are appended, in order, to the contents of this string buffer, increasing the length of this string buffer by the length of the argument.

Parameters

  str | a string.

Returns
  this string buffer.

Since
  LibreOffice 4.0

## ◆ append() [5/14]

OUStringBuffer & rtl::OUStringBuffer::append | ( | const sal_Unicode * | str | ) |
| inline

Appends the string representation of the `char` array argument to this string buffer.

The characters of the array argument are appended, in order, to the contents of this string buffer. The length of this string buffer increases by the length of the argument.

Parameters

  str | the characters to be appended.

Returns
  this string buffer.

## ◆ append() [6/14]

OUStringBuffer & rtl::OUStringBuffer::append | ( | const sal_Unicode * | str,
|  | sal_Int32 | len )
| inline

Appends the string representation of the `char` array argument to this string buffer.

Characters of the character array `str` are appended, in order, to the contents of this string buffer. The length of this string buffer increases by the value of `len`.

Parameters

  str | the characters to be appended; must be non-null, and must point to at least len characters
  len | the number of characters to append; must be non-negative

Returns
  this string buffer.

## ◆ append() [7/14]

OUStringBuffer & rtl::OUStringBuffer::append | ( | double | d | ) |
| inline

Appends the string representation of the `double` argument to this string buffer.

The argument is converted to a string as if by the method `String.valueOf`, and the characters of that string are then appended to this string buffer.

Parameters

  d | a `double`.

Returns
  this string buffer.

## ◆ append() [8/14]

OUStringBuffer & rtl::OUStringBuffer::append | ( | float | f | ) |
| inline

Appends the string representation of the `float` argument to this string buffer.

The argument is converted to a string as if by the method `String.valueOf`, and the characters of that string are then appended to this string buffer.

Parameters

  f | a `float`.

Returns
  this string buffer.

## ◆ append() [9/14]

OUStringBuffer & rtl::OUStringBuffer::append | ( | rtl_uString * | str | ) |
| inline

## ◆ append() [10/14]

OUStringBuffer & rtl::OUStringBuffer::append | ( | sal_Bool | b | ) |
| inline

Appends the string representation of the `sal_Bool` argument to the string buffer.

The argument is converted to a string as if by the method `String.valueOf`, and the characters of that string are then appended to this string buffer.

Parameters

  b | a `sal_Bool`.

Returns
  this string buffer.

## ◆ append() [11/14]

OUStringBuffer & rtl::OUStringBuffer::append | ( | sal_Int32 | i,
|  | sal_Int16 | radix = 10 )
| inline

Appends the string representation of the `sal_Int32` argument to this string buffer.

The argument is converted to a string as if by the method `String.valueOf`, and the characters of that string are then appended to this string buffer.

Parameters

  i | an `sal_Int32`.
  radix | the radix

Returns
  this string buffer.

## ◆ append() [12/14]

OUStringBuffer & rtl::OUStringBuffer::append | ( | sal_Int64 | l,
|  | sal_Int16 | radix = 10 )
| inline

Appends the string representation of the `long` argument to this string buffer.

The argument is converted to a string as if by the method `String.valueOf`, and the characters of that string are then appended to this string buffer.

Parameters

  l | a `long`.
  radix | the radix

Returns
  this string buffer.

## ◆ append() [13/14]

OUStringBuffer & rtl::OUStringBuffer::append | ( | sal_Unicode | c | ) |
| inline

Appends the string representation of the `char` argument to this string buffer.

The argument is appended to the contents of this string buffer. The length of this string buffer increases by `1`.

Parameters

  c | a `char`.

Returns
  this string buffer.

## ◆ append() [14/14]

template<typename T>

libreoffice_internal::ConstCharArrayDetector< T, OUStringBuffer & >::Type rtl::OUStringBuffer::append | ( | T & | literal | ) |
| inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument.

Since
  LibreOffice 3.6

## ◆ appendAscii() [1/2]

OUStringBuffer & rtl::OUStringBuffer::appendAscii | ( | const char * | str | ) |
| inline

Appends a 8-Bit ASCII character string to this string buffer.

Since this method is optimized for performance. the ASCII character values are not converted in any way. The caller has to make sure that all ASCII characters are in the allowed range between 0 and 127. The ASCII string must be NULL-terminated.

The characters of the array argument are appended, in order, to the contents of this string buffer. The length of this string buffer increases by the length of the argument.

Parameters

  str | the 8-Bit ASCII characters to be appended.

Returns
  this string buffer.

## ◆ appendAscii() [2/2]

OUStringBuffer & rtl::OUStringBuffer::appendAscii | ( | const char * | str,
|  | sal_Int32 | len )
| inline

Appends a 8-Bit ASCII character string to this string buffer.

Since this method is optimized for performance. the ASCII character values are not converted in any way. The caller has to make sure that all ASCII characters are in the allowed range between 0 and 127.

Characters of the character array `str` are appended, in order, to the contents of this string buffer. The length of this string buffer increases by the value of `len`.

Parameters

  str | the 8-Bit ASCII characters to be appended; must be non-null, and must point to at least len characters
  len | the number of characters to append; must be non-negative

Returns
  this string buffer.

## ◆ appendUninitialized()

sal_Unicode * rtl::OUStringBuffer::appendUninitialized | ( | sal_Int32 | length | ) |
| inline

Unsafe way to make space for a fixed amount of characters to be appended into this OUStringBuffer.

A call to this function must immediately be followed by code that completely fills the uninitialized block pointed to by the return value.

Parameters

  length | the length of the uninitialized block of sal_Unicode entities; must be non-negative

Returns
  a pointer to the start of the uninitialized block; only valid until this OUStringBuffer's capacity changes

Since
  LibreOffice 4.4

## ◆ appendUtf32()

OUStringBuffer & rtl::OUStringBuffer::appendUtf32 | ( | sal_uInt32 | c | ) |
| inline

Appends a single UTF-32 character to this string buffer.

The single UTF-32 character will be represented within the string buffer as either one or two UTF-16 code units.

Parameters

  c | a well-formed UTF-32 code unit (that is, a value in the range `0`–`0x10FFFF`, but excluding `0xD800`–`0xDFFF`)

Returns
  this string buffer

## ◆ charAt()

sal_Unicode rtl::OUStringBuffer::charAt | ( | sal_Int32 | index | ) | const
| inline

Returns the character at a specific index in this string buffer.

The first character of a string buffer is at index `0`, the next at index `1`, and so on, for array indexing.

The index argument must be greater than or equal to `0`, and less than the length of this string buffer.

Parameters

  index | the index of the desired character.

Returns
  the character at the specified index of this string buffer.

## ◆ copy() [1/2]

OUStringBuffer rtl::OUStringBuffer::copy | ( | sal_Int32 | beginIndex | ) | const
| inline

Returns a new string buffer that is 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.

Parameters

  beginIndex | the beginning index, inclusive.

Returns
  the specified substring.

Since
  LibreOffice 4.1

## ◆ copy() [2/2]

OUStringBuffer rtl::OUStringBuffer::copy | ( | sal_Int32 | beginIndex,
|  | sal_Int32 | count ) const
| inline

Returns a new string buffer that is 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.

Parameters

  beginIndex | the beginning index, inclusive.
  count | the number of characters.

Returns
  the specified substring.

Since
  LibreOffice 4.1

## ◆ ensureCapacity()

void rtl::OUStringBuffer::ensureCapacity | ( | sal_Int32 | minimumCapacity | ) |
| inline

Ensures that the capacity of the buffer is at least equal to the specified minimum.

The new capacity will be at least as large as the maximum of the current length (so that no contents of the buffer is destroyed) and the given minimumCapacity. If the given minimumCapacity is negative, nothing is changed.

Parameters

  minimumCapacity | the minimum desired capacity.

## ◆ getCapacity()

sal_Int32 rtl::OUStringBuffer::getCapacity | ( |  | ) | const
| inline

Returns the current capacity of the String buffer.

The capacity is the amount of storage available for newly inserted characters. The real buffer size is 2 bytes longer, because all strings are 0 terminated.

Returns
  the current capacity of this string buffer.

## ◆ getLength()

sal_Int32 rtl::OUStringBuffer::getLength | ( |  | ) | const
| inline

Returns the length (character count) of this string buffer.

Returns
  the number of characters in this string buffer.

## ◆ getStr()

const sal_Unicode * rtl::OUStringBuffer::getStr | ( |  | ) | const
| inline

Return a null terminated unicode character array.

## ◆ indexOf() [1/3]

sal_Int32 rtl::OUStringBuffer::indexOf | ( | const OUString & | str,
|  | sal_Int32 | fromIndex = 0 ) const
| inline

Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.

If str doesn't include any character, always -1 is returned. This is also the case, if both strings are empty.

Since
  LibreOffice 4.0

Parameters

  str | the substring to search for.
  fromIndex | the index to start the search from.

Returns
  If the string argument occurs one or more times as a substring within this string at the starting index, then the index of the first character of the first such substring is returned. If it does not occur as a substring starting at fromIndex or beyond, -1 is returned.

## ◆ indexOf() [2/3]

sal_Int32 rtl::OUStringBuffer::indexOf | ( | sal_Unicode | ch,
|  | sal_Int32 | fromIndex = 0 ) const
| inline

Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.

Since
  LibreOffice 4.0

Parameters

  ch | character to be located.
  fromIndex | the index to start the search from. The index must be greater or equal than 0 and less or equal as the string length.

Returns
  the index of the first occurrence of the character in the character sequence represented by this string that is greater than or equal to fromIndex, or -1 if the character does not occur.

## ◆ indexOf() [3/3]

template<typename T>

libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type rtl::OUStringBuffer::indexOf | ( | T & | literal,
|  | sal_Int32 | fromIndex = 0 ) const
| inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument.

Since
  LibreOffice 4.0

## ◆ insert() [1/12]

OUStringBuffer & rtl::OUStringBuffer::insert | ( | sal_Int32 | offset,
|  | bool | b )
| inline

Inserts the string representation of the `bool` argument into this string buffer.

The second argument is converted to a string as if by the method `OUString::boolean`, and the characters of that string are then inserted into this string buffer at the indicated offset.

The offset argument must be greater than or equal to `0`, and less than or equal to the length of this string buffer.

Parameters

  offset | the offset.
  b | a `bool`.

Returns
  this string buffer.

Since
  LibreOffice 4.3

## ◆ insert() [2/12]

OUStringBuffer & rtl::OUStringBuffer::insert | ( | sal_Int32 | offset,
|  | char | c )
| inline

Inserts the string representation of the `char` argument into this string buffer.

The second argument is inserted into the contents of this string buffer at the position indicated by `offset`. The length of this string buffer increases by one.

The offset argument must be greater than or equal to `0`, and less than or equal to the length of this string buffer.

Parameters

  offset | the offset.
  c | a `char`.

Returns
  this string buffer.

Since
  LibreOffice 3.6

## ◆ insert() [3/12]

OUStringBuffer & rtl::OUStringBuffer::insert | ( | sal_Int32 | offset,
|  | const OUString & | str )
| inline

Inserts the string into this string buffer.

The characters of the `String` argument are inserted, in order, into this string buffer at the indicated offset. The length of this string buffer is increased by the length of the argument.

The offset argument must be greater than or equal to `0`, and less than or equal to the length of this string buffer.

Parameters

  offset | the offset.
  str | a string.

Returns
  this string buffer.

## ◆ insert() [4/12]

OUStringBuffer & rtl::OUStringBuffer::insert | ( | sal_Int32 | offset,
|  | const sal_Unicode * | str )
| inline

Inserts the string representation of the `char` array argument into this string buffer.

The characters of the array argument are inserted into the contents of this string buffer at the position indicated by `offset`. The length of this string buffer increases by the length of the argument.

The offset argument must be greater than or equal to `0`, and less than or equal to the length of this string buffer.

Parameters

  offset | the offset.
  str | a character array.

Returns
  this string buffer.

## ◆ insert() [5/12]

OUStringBuffer & rtl::OUStringBuffer::insert | ( | sal_Int32 | offset,
|  | const sal_Unicode * | str,
|  | sal_Int32 | len )
| inline

Inserts the string representation of the `char` array argument into this string buffer.

The characters of the array argument are inserted into the contents of this string buffer at the position indicated by `offset`. The length of this string buffer increases by the length of the argument.

The offset argument must be greater than or equal to `0`, and less than or equal to the length of this string buffer.

Parameters

  offset | the offset.
  str | a character array.
  len | the number of characters to append.

Returns
  this string buffer.

## ◆ insert() [6/12]

OUStringBuffer & rtl::OUStringBuffer::insert | ( | sal_Int32 | offset,
|  | double | d )
| inline

Inserts the string representation of the `double` argument into this string buffer.

The second argument is converted to a string as if by the method `String.valueOf`, and the characters of that string are then inserted into this string buffer at the indicated offset.

The offset argument must be greater than or equal to `0`, and less than or equal to the length of this string buffer.

Parameters

  offset | the offset.
  d | a `double`.

Returns
  this string buffer.

Exceptions

  StringIndexOutOfBoundsException | if the offset is invalid.

## ◆ insert() [7/12]

OUStringBuffer & rtl::OUStringBuffer::insert | ( | sal_Int32 | offset,
|  | float | f )
| inline

Inserts the string representation of the `float` argument into this string buffer.

The second argument is converted to a string as if by the method `String.valueOf`, and the characters of that string are then inserted into this string buffer at the indicated offset.

The offset argument must be greater than or equal to `0`, and less than or equal to the length of this string buffer.

Parameters

  offset | the offset.
  f | a `float`.

Returns
  this string buffer.

Exceptions

  StringIndexOutOfBoundsException | if the offset is invalid.

## ◆ insert() [8/12]

OUStringBuffer & rtl::OUStringBuffer::insert | ( | sal_Int32 | offset,
|  | sal_Bool | b )
| inline

Inserts the string representation of the `sal_Bool` argument into this string buffer.

The second argument is converted to a string as if by the method `String.valueOf`, and the characters of that string are then inserted into this string buffer at the indicated offset.

The offset argument must be greater than or equal to `0`, and less than or equal to the length of this string buffer.

Parameters

  offset | the offset.
  b | a `sal_Bool`.

Returns
  this string buffer.

## ◆ insert() [9/12]

OUStringBuffer & rtl::OUStringBuffer::insert | ( | sal_Int32 | offset,
|  | sal_Int32 | i,
|  | sal_Int16 | radix = 10 )
| inline

Inserts the string representation of the second `sal_Int32` argument into this string buffer.

The second argument is converted to a string as if by the method `String.valueOf`, and the characters of that string are then inserted into this string buffer at the indicated offset.

The offset argument must be greater than or equal to `0`, and less than or equal to the length of this string buffer.

Parameters

  offset | the offset.
  i | an `sal_Int32`.
  radix | the radix.

Returns
  this string buffer.

Exceptions

  StringIndexOutOfBoundsException | if the offset is invalid.

## ◆ insert() [10/12]

OUStringBuffer & rtl::OUStringBuffer::insert | ( | sal_Int32 | offset,
|  | sal_Int64 | l,
|  | sal_Int16 | radix = 10 )
| inline

Inserts the string representation of the `long` argument into this string buffer.

The second argument is converted to a string as if by the method `String.valueOf`, and the characters of that string are then inserted into this string buffer at the indicated offset.

The offset argument must be greater than or equal to `0`, and less than or equal to the length of this string buffer.

Parameters

  offset | the offset.
  l | a `long`.
  radix | the radix.

Returns
  this string buffer.

Exceptions

  StringIndexOutOfBoundsException | if the offset is invalid.

## ◆ insert() [11/12]

OUStringBuffer & rtl::OUStringBuffer::insert | ( | sal_Int32 | offset,
|  | sal_Unicode | c )
| inline

Inserts the string representation of the `char` argument into this string buffer.

The second argument is inserted into the contents of this string buffer at the position indicated by `offset`. The length of this string buffer increases by one.

The offset argument must be greater than or equal to `0`, and less than or equal to the length of this string buffer.

Parameters

  offset | the offset.
  c | a `char`.

Returns
  this string buffer.

## ◆ insert() [12/12]

template<typename T>

libreoffice_internal::ConstCharArrayDetector< T, OUStringBuffer & >::Type rtl::OUStringBuffer::insert | ( | sal_Int32 | offset,
|  | T & | literal )
| inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument.

Since
  LibreOffice 3.6

## ◆ insertUtf32()

OUStringBuffer & rtl::OUStringBuffer::insertUtf32 | ( | sal_Int32 | offset,
|  | sal_uInt32 | c )
| inline

Inserts a single UTF-32 character into this string buffer.

The single UTF-32 character will be represented within the string buffer as either one or two UTF-16 code units.

Parameters

  offset | the offset into this string buffer (from zero to the length of this string buffer, inclusive)
  c | a well-formed UTF-32 code unit (that is, a value in the range `0`–`0x10FFFF`, but excluding `0xD800`–`0xDFFF`)

Returns
  this string buffer

## ◆ isEmpty()

bool rtl::OUStringBuffer::isEmpty | ( |  | ) | const
| inline

Checks if a string buffer is empty.

Returns
  true if the string buffer is empty; false, otherwise.

Since
  LibreOffice 4.1

## ◆ lastIndexOf() [1/5]

sal_Int32 rtl::OUStringBuffer::lastIndexOf | ( | const OUString & | str | ) | const
| inline

Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the end.

The returned index indicates the starting index of the substring in this string. If str doesn't include any character, always -1 is returned. This is also the case, if both strings are empty.

Since
  LibreOffice 4.0

Parameters

  str | the substring to search for.

Returns
  If the string argument occurs one or more times as a substring within this string, then the index of the first character of the last such substring is returned. If it does not occur as a substring, -1 is returned.

## ◆ lastIndexOf() [2/5]

sal_Int32 rtl::OUStringBuffer::lastIndexOf | ( | const OUString & | str,
|  | sal_Int32 | fromIndex ) const
| inline

Returns the index within this string of the last occurrence of the specified substring, searching backward starting before the specified index.

The returned index indicates the starting index of the substring in this string. If str doesn't include any character, always -1 is returned. This is also the case, if both strings are empty.

Since
  LibreOffice 4.0

Parameters

  str | the substring to search for.
  fromIndex | the index before which to start the search.

Returns
  If the string argument occurs one or more times as a substring within this string before the starting index, then the index of the first character of the last such substring is returned. Otherwise, -1 is returned.

## ◆ lastIndexOf() [3/5]

sal_Int32 rtl::OUStringBuffer::lastIndexOf | ( | sal_Unicode | ch | ) | const
| inline

Returns the index within this string of the last occurrence of the specified character, searching backward starting at the end.

Since
  LibreOffice 4.0

Parameters

  ch | character to be located.

Returns
  the index of the last occurrence of the character in the character sequence represented by this string, or -1 if the character does not occur.

## ◆ lastIndexOf() [4/5]

sal_Int32 rtl::OUStringBuffer::lastIndexOf | ( | sal_Unicode | ch,
|  | sal_Int32 | fromIndex ) const
| inline

Returns the index within this string of the last occurrence of the specified character, searching backward starting before the specified index.

Since
  LibreOffice 4.0

Parameters

  ch | character to be located.
  fromIndex | the index before which to start the search.

Returns
  the index of the last occurrence of the character in the character sequence represented by this string that is less than fromIndex, or -1 if the character does not occur before that point.

## ◆ lastIndexOf() [5/5]

template<typename T>

libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type rtl::OUStringBuffer::lastIndexOf | ( | T & | literal | ) | const
| inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument.

Since
  LibreOffice 4.0

## ◆ makeStringAndClear()

SAL_WARN_UNUSED_RESULT OUString rtl::OUStringBuffer::makeStringAndClear | ( |  | ) |
| inline

Fill the string data in the new string and clear the buffer.

This method is more efficient than the constructor of the string. It does not copy the buffer.

Returns
  the string previously contained in the buffer.

## ◆ operator=() [1/3]

OUStringBuffer & rtl::OUStringBuffer::operator= | ( | const OUStringBuffer & | value | ) |
| inline

Assign to this a copy of value.

## ◆ operator=() [2/3]

OUStringBuffer & rtl::OUStringBuffer::operator= | ( | OUString const & | string | ) |
| inline

Assign from a string.

Since
  LibreOffice 5.3

## ◆ operator=() [3/3]

template<typename T>

libreoffice_internal::ConstCharArrayDetector< T, OUStringBuffer & >::Type rtl::OUStringBuffer::operator= | ( | T & | literal | ) |
| inline

Assign from a string literal.

Since
  LibreOffice 5.3

## ◆ operator[]() [1/2]

sal_Unicode & rtl::OUStringBuffer::operator[] | ( | sal_Int32 | index | ) |
| inline

Access to individual characters.

Parameters

  index | must be non-negative and less than length.

Returns
  a reference to the character at the given index.

Since
  LibreOffice 3.5

## ◆ operator[]() [2/2]

const sal_Unicode & rtl::OUStringBuffer::operator[] | ( | sal_Int32 | index | ) | const
| inline

Access to individual characters.

Parameters

  index | must be non-negative and less than length.

Returns
  a reference to the character at the given index.

Since
  LibreOffice 4.2

## ◆ remove()

OUStringBuffer & rtl::OUStringBuffer::remove | ( | sal_Int32 | start,
|  | sal_Int32 | len )
| inline

Removes the characters in a substring of this sequence.

The substring begins at the specified `start` and is `len` characters long.

start must be >= 0 && <= This->length

Parameters

  start | The beginning index, inclusive
  len | The substring length

Returns
  this string buffer.

## ◆ replace()

OUStringBuffer & rtl::OUStringBuffer::replace | ( | sal_Unicode | oldChar,
|  | sal_Unicode | newChar )
| inline

Replace all occurrences of oldChar in this string buffer with newChar.

Since
  LibreOffice 4.0

Parameters

  oldChar | the old character.
  newChar | the new character.

Returns
  this string buffer

## ◆ setCharAt()

OUStringBuffer & rtl::OUStringBuffer::setCharAt | ( | sal_Int32 | index,
|  | sal_Unicode | ch )
| inline

The character at the specified index of this string buffer is set to `ch`.

The index argument must be greater than or equal to `0`, and less than the length of this string buffer.

Parameters

  index | the index of the character to modify.
  ch | the new character.

## ◆ setLength()

void rtl::OUStringBuffer::setLength | ( | sal_Int32 | newLength | ) |
| inline

Sets the length of this String buffer.

If the `newLength` argument is less than the current length of the string buffer, the string buffer is truncated to contain exactly the number of characters given by the `newLength` argument.

If the `newLength` argument is greater than or equal to the current length, sufficient null characters (`'&#92;u0000'`) are appended to the string buffer so that length becomes the `newLength` argument.

The `newLength` argument must be greater than or equal to `0`.

Parameters

  newLength | the new length of the buffer.

## ◆ strip()

sal_Int32 rtl::OUStringBuffer::strip | ( | sal_Unicode | c = ' ' | ) |
| inline

Strip the given character from the both end of the buffer.

Since
  LibreOffice 4.0

Parameters

  c | the character to strip

Returns
  The number of characters stripped

## ◆ stripEnd()

sal_Int32 rtl::OUStringBuffer::stripEnd | ( | sal_Unicode | c = ' ' | ) |
| inline

Strip the given character from the end of the buffer.

Since
  LibreOffice 4.0

Parameters

  c | the character to strip

Returns
  The number of characters stripped

## ◆ stripStart()

sal_Int32 rtl::OUStringBuffer::stripStart | ( | sal_Unicode | c = ' ' | ) |
| inline

Strip the given character from the start of the buffer.

Since
  LibreOffice 4.0

Parameters

  c | the character to strip

Returns
  The number of characters stripped

## ◆ toString()

OUString rtl::OUStringBuffer::toString | ( |  | ) | const
| inline

Return an OUString instance reflecting the current content of this OUStringBuffer.

## ◆ truncate()

OUStringBuffer & rtl::OUStringBuffer::truncate | ( | sal_Int32 | start = 0 | ) |
| inline

Removes the tail of a string buffer start at the indicate position.

start must be >= 0 && <= This->length

Parameters

  start | The beginning index, inclusive. default to 0

Returns
  this string buffer.

Since
  LibreOffice 4.0

## Friends And Related Symbol Documentation

## ◆ OUString

friend class OUString
| friend

The documentation for this class was generated from the following file:

- rtl/ustrbuf.hxx