My Project
UDK 3.2.7 C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
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 (int length)
 Constructs a string buffer with no characters in it and an initial capacity specified by the length argument.
 OUStringBuffer (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 internal::ConstCharArrayDetector< T, internal::Dummy >::Type=internal::Dummy())
OUStringBufferoperator= (const OUStringBuffer &value)
 Assign to this a copy of value.
 ~OUStringBuffer ()
 Release the string data.
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.
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.
OUStringBuffersetCharAt (sal_Int32 index, sal_Unicode ch)
 The character at the specified index of this string buffer is set to ch.
const sal_UnicodegetStr () const
 Return a null terminated unicode character array.
sal_Unicodeoperator[] (sal_Int32 index)
 Access to individual characters.
const OUString toString () const
 Return a OUString instance reflecting the current content of this OUStringBuffer.
OUStringBufferappend (const OUString &str)
 Appends the string to this string buffer.
OUStringBufferappend (const sal_Unicode *str)
 Appends the string representation of the char array argument to this string buffer.
OUStringBufferappend (const sal_Unicode *str, sal_Int32 len)
 Appends the string representation of the char array argument to this string buffer.
template<typename T >
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.
OUStringBufferappendAscii (const sal_Char *str)
 Appends a 8-Bit ASCII character string to this string buffer.
OUStringBufferappendAscii (const sal_Char *str, sal_Int32 len)
 Appends a 8-Bit ASCII character string to this string buffer.
OUStringBufferappend (sal_Bool b)
 Appends the string representation of the sal_Bool argument to the string buffer.
OUStringBufferappend (char c)
 Appends the string representation of the ASCII char argument to this string buffer.
OUStringBufferappend (sal_Unicode c)
 Appends the string representation of the char argument to this string buffer.
OUStringBufferappend (sal_Int32 i, sal_Int16 radix=10)
 Appends the string representation of the sal_Int32 argument to this string buffer.
OUStringBufferappend (sal_Int64 l, sal_Int16 radix=10)
 Appends the string representation of the long argument to this string buffer.
OUStringBufferappend (float f)
 Appends the string representation of the float argument to this string buffer.
OUStringBufferappend (double d)
 Appends the string representation of the double argument to this string buffer.
OUStringBufferappendUtf32 (sal_uInt32 c)
 Appends a single UTF-32 character to this string buffer.
OUStringBufferinsert (sal_Int32 offset, const OUString &str)
 Inserts the string into this string buffer.
OUStringBufferinsert (sal_Int32 offset, const sal_Unicode *str)
 Inserts the string representation of the char array argument into this string buffer.
OUStringBufferinsert (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 >
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.
OUStringBufferinsert (sal_Int32 offset, sal_Bool b)
 Inserts the string representation of the sal_Bool argument into this string buffer.
OUStringBufferinsert (sal_Int32 offset, char c)
 Inserts the string representation of the char argument into this string buffer.
OUStringBufferinsert (sal_Int32 offset, sal_Unicode c)
 Inserts the string representation of the char argument into this string buffer.
OUStringBufferinsert (sal_Int32 offset, sal_Int32 i, sal_Int16 radix=10)
 Inserts the string representation of the second sal_Int32 argument into this string buffer.
OUStringBufferinsert (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.
OUStringBufferinsert (sal_Int32 offset, double d)
 Inserts the string representation of the double argument into this string buffer.
OUStringBufferinsertUtf32 (sal_Int32 offset, sal_uInt32 c)
 Inserts a single UTF-32 character into this string buffer.
OUStringBufferremove (sal_Int32 start, sal_Int32 len)
 Removes the characters in a substring of this sequence.
void accessInternals (rtl_uString ***pInternalData, sal_Int32 **pInternalCapacity)
 Allows access to the internal data of this OUStringBuffer, for effective manipulation.

Detailed Description

A string buffer implements a mutable sequence of characters.

String buffers are safe for use by multiple threads. The methods are synchronized where necessary so that all the operations on any particular instance behave as if they occur in some serial order.

String buffers are used by the compiler to implement the binary string concatenation operator +. For example, the code:

    x = "a" + 4 + "c"

is compiled to the equivalent of:

    x = new OUStringBuffer().append("a").append(4).append("c")
                          .makeStringAndClear()

The principal operations on a OUStringBuffer are the append and insert methods, which are overloaded so as to accept data of any type. Each effectively converts a given datum to a string and then appends or inserts the characters of that string to the string buffer. The append method always adds these characters at the end of the buffer; the insert method adds the characters at a specified point.

For example, if z refers to a string buffer object whose current contents are "<code>start</code>", then the method call z.append("le") would cause the string buffer to contain "<code>startle</code>", whereas z.insert(4, "le") would alter the string buffer to contain "<code>starlet</code>".

Every string buffer has a capacity. As long as the length of the character sequence contained in the string buffer does not exceed the capacity, it is not necessary to allocate a new internal buffer array. If the internal buffer overflows, it is automatically made larger.

Constructor & Destructor Documentation

rtl::OUStringBuffer::OUStringBuffer ( )
inline

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

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
valuea OUStringBuffer.
rtl::OUStringBuffer::OUStringBuffer ( int  length)
inlineexplicit

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

Parameters
lengththe initial capacity.
rtl::OUStringBuffer::OUStringBuffer ( 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
valuethe initial contents of the buffer.
template<typename T >
rtl::OUStringBuffer::OUStringBuffer ( T &  literal,
typename internal::ConstCharArrayDetector< T, internal::Dummy >::Type  = internal::Dummy() 
)
inline
rtl::OUStringBuffer::~OUStringBuffer ( )
inline

Release the string data.

Member Function Documentation

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
pInternalDataThis output parameter receives a pointer to the internal data (rtl_uString pointer). pInternalData itself must not be null.
pInternalCapacityThis output parameter receives a pointer to the internal capacity. pInternalCapacity itself must not be null.
OUStringBuffer& rtl::OUStringBuffer::append ( const OUString str)
inline

Appends the string to this string buffer.

The characters of the String 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
stra string.
Returns
this string buffer.
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
strthe characters to be appended.
Returns
this string buffer.
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
strthe characters to be appended; must be non-null, and must point to at least len characters
lenthe number of characters to append; must be non-negative
Returns
this string buffer.
template<typename T >
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
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
ba sal_Bool.
Returns
this string buffer.
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
can ASCII char.
Returns
this string buffer.
Since
LibreOffice 3.5
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
ca char.
Returns
this string buffer.
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
ian sal_Int32.
Returns
this string buffer.
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
la long.
Returns
this string buffer.
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
fa float.
Returns
this string buffer.
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
da double.
Returns
this string buffer.
OUStringBuffer& rtl::OUStringBuffer::appendAscii ( const sal_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
strthe 8-Bit ASCII characters to be appended.
Returns
this string buffer.
OUStringBuffer& rtl::OUStringBuffer::appendAscii ( const sal_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. The ASCII string must be NULL-terminated.

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
strthe 8-Bit ASCII characters to be appended; must be non-null, and must point to at least len characters
lenthe number of characters to append; must be non-negative
Returns
this string buffer.
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
ca well-formed UTF-32 code unit (that is, a value in the range 00x10FFFF, but excluding 0xD8000xDFFF)
Returns
this string buffer
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
indexthe index of the desired character.
Returns
the character at the specified index of this string buffer.
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
minimumCapacitythe minimum desired capacity.
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.
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.
const sal_Unicode* rtl::OUStringBuffer::getStr ( ) const
inline

Return a null terminated unicode character array.

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
offsetthe offset.
stra string.
Returns
this string buffer.
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
offsetthe offset.
stra character array.
Returns
this string buffer.
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
offsetthe offset.
stra character array.
lenthe number of characters to append.
Returns
this string buffer.
template<typename T >
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
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
offsetthe offset.
ba sal_Bool.
Returns
this string buffer.
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
offsetthe offset.
ca char.
Returns
this string buffer.
Since
LibreOffice 3.6
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
offsetthe offset.
ca char.
Returns
this string buffer.
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
offsetthe offset.
ian sal_Int32.
radixthe radix.
Returns
this string buffer.
Exceptions
StringIndexOutOfBoundsExceptionif the offset is invalid.
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
offsetthe offset.
la long.
radixthe radix.
Returns
this string buffer.
Exceptions
StringIndexOutOfBoundsExceptionif the offset is invalid.
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
offsetthe offset.
fa float.
Returns
this string buffer.
Exceptions
StringIndexOutOfBoundsExceptionif the offset is invalid.
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
offsetthe offset.
da double.
Returns
this string buffer.
Exceptions
StringIndexOutOfBoundsExceptionif the offset is invalid.
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
offsetthe offset into this string buffer (from zero to the length of this string buffer, inclusive)
ca well-formed UTF-32 code unit (that is, a value in the range 00x10FFFF, but excluding 0xD8000xDFFF)
Returns
this string buffer
OUString rtl::OUStringBuffer::makeStringAndClear ( )
inline

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

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

Returns
the string previously contained in the buffer.
OUStringBuffer& rtl::OUStringBuffer::operator= ( const OUStringBuffer value)
inline

Assign to this a copy of value.

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

Access to individual characters.

Parameters
indexmust be non-negative and less than length.
Returns
a reference to the character at the given index.
Since
LibreOffice 3.5
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
startThe beginning index, inclusive
lenThe substring length
Returns
this string buffer.
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
indexthe index of the character to modify.
chthe new character.
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
newLengththe new length of the buffer.
const OUString rtl::OUStringBuffer::toString ( ) const
inline

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


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