Language

The Free and Open Productivity Suite
Released: Apache OpenOffice 4.1.15

API

SDK

Tips ‘n’ Tricks

Miscellaneous


:: rtl ::

class OUStringBuffer


Base Classes
None.
Known Derived Classes
None.

virtual abstract interface template
NO NO NO NO
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")
                          .toString()

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 "start", then the method call z.append("le") would cause the string buffer to contain "startle", whereas z.insert(4, "le") would alter the string buffer to contain "starlet".

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.

File
ustrbuf.hxx

Public Members

Methods


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 <code>length</code> argument.

OUStringBuffer( OUString value );
Constructs a string buffer so that it represents the same sequence of characters as the string argument.
OUStringBuffer &
operator=( 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.

operator const sal_Unicode *( ) const;
Return a null terminated unicode character array.
const sal_Unicode *
getStr( ) const;
Return a null terminated unicode character array.
OUStringBuffer &
setCharAt( sal_Int32 index, sal_Unicode ch );
The character at the specified index of this string buffer is set to <code>ch</code>.
OUStringBuffer &
append( const OUString & str );
Appends the string to this string buffer.
OUStringBuffer &
append( const sal_Unicode * str );
Appends the string representation of the <code>char</code> array argument to this string buffer.
OUStringBuffer &
append( const sal_Unicode * str, sal_Int32 len );
Appends the string representation of the <code>char</code> array argument to this string buffer.
OUStringBuffer &
appendAscii( const sal_Char * str );
Appends a 8-Bit ASCII character string to this string buffer.
OUStringBuffer &
appendAscii( const sal_Char * str, sal_Int32 len );
Appends a 8-Bit ASCII character string to this string buffer.
OUStringBuffer &
append( sal_Bool b );
Appends the string representation of the <code>sal_Bool</code> argument to the string buffer.
OUStringBuffer &
append( sal_Unicode c );
Appends the string representation of the <code>char</code> argument to this string buffer.
OUStringBuffer &
append( sal_Int32 i, sal_Int16 radix = 10 );
Appends the string representation of the <code>sal_Int32</code> argument to this string buffer.
OUStringBuffer &
append( sal_Int64 l, sal_Int16 radix = 10 );
Appends the string representation of the <code>long</code> argument to this string buffer.
OUStringBuffer &
append( float f );
Appends the string representation of the <code>float</code> argument to this string buffer.
OUStringBuffer &
append( double d );
Appends the string representation of the <code>double</code> argument to this string buffer.
OUStringBuffer &
appendUtf32( sal_uInt32 c );
Appends a single UTF-32 character to this string buffer.
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 <code>char</code> array argument into this string buffer.
OUStringBuffer &
insert( sal_Int32 offset, const sal_Unicode * str, sal_Int32 len );
Inserts the string representation of the <code>char</code> array argument into this string buffer.
OUStringBuffer &
insert( sal_Int32 offset, sal_Bool b );
Inserts the string representation of the <code>sal_Bool</code> argument into this string buffer.
OUStringBuffer &
insert( sal_Int32 offset, sal_Unicode c );
Inserts the string representation of the <code>char</code> argument into this string buffer.
OUStringBuffer &
insert( sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 );
Inserts the string representation of the second <code>sal_Int32</code> argument into this string buffer.
OUStringBuffer &
insert( sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 );
Inserts the string representation of the <code>long</code> argument into this string buffer.
OUStringBuffer
insert( sal_Int32 offset, float f );
Inserts the string representation of the <code>float</code> argument into this string buffer.
OUStringBuffer &
insert( sal_Int32 offset, double d );
Inserts the string representation of the <code>double</code> argument into this string buffer.
OUStringBuffer &
insertUtf32( sal_Int32 offset, sal_uInt32 c );
Inserts a single UTF-32 character into this string buffer.
void
accessInternals( rtl_uString * * * pInternalData, sal_Int32 * * pInternalCapacity );
Allows access to the internal data of this OUStringBuffer, for effective manipulation.

Private Members

Data

rtl_uString * pData; A pointer to the data structur which contains the data.
sal_Int32 nCapacity; The len of the pData->buffer.

Top of Page

Apache Software Foundation

Copyright & License | Privacy | Contact Us | Donate | Thanks

Apache, OpenOffice, OpenOffice.org and the seagull logo are registered trademarks of The Apache Software Foundation. The Apache feather logo is a trademark of The Apache Software Foundation. Other names appearing on the site may be trademarks of their respective owners.