Language

The Free and Open Productivity Suite
Released: Apache OpenOffice 4.1.15
 Overview   Namespace   Class   Index   Help 
PUBLIC MEMBERS:  CLASSESSTRUCTSUNIONSENUMSTYPEDEFSMETHODSSTATIC METHODSDATASTATIC DATA
PRIVATE MEMBERS:  CLASSESSTRUCTSUNIONSENUMSTYPEDEFSMETHODSSTATIC METHODSDATASTATIC DATA

:: rtl ::

class OStringBuffer


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 OStringBuffer().append("a").append(4).append("c")
                          .toString()

The principal operations on a OStringBuffer 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
strbuf.hxx

Public Members

Methods


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

OStringBuffer( const OStringBuffer & value );
Allocates a new string buffer that contains the same sequence of characters as the string buffer argument.

OStringBuffer( sal_Int32 length );
Constructs a string buffer with no characters in it and an initial capacity specified by the <code>length</code> argument.

OStringBuffer( OString value );
Constructs a string buffer so that it represents the same sequence of characters as the string argument.
OStringBuffer &
operator=( const OStringBuffer & value );
Assign to this a copy of value.

~OStringBuffer( );
Release the string data.
OString
makeStringAndClear( );
Fill the string data in the new string and clear the buffer.
sal_Int32
getLength( );
Returns the length (character count) of this string buffer.
sal_Int32
getCapacity( );
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_Char
charAt( sal_Int32 index );
Returns the character at a specific index in this string buffer.

operator const sal_Char *( ) const;
Return a null terminated character array.
const sal_Char *
getStr( ) const;
Return a null terminated character array.
OStringBuffer &
setCharAt( sal_Int32 index, sal_Char ch );
The character at the specified index of this string buffer is set to <code>ch</code>.
OStringBuffer &
append( const OString & str );
Appends the string to this string buffer.
OStringBuffer &
append( const sal_Char * str );
Appends the string representation of the <code>char</code> array argument to this string buffer.
OStringBuffer &
append( const sal_Char * str, sal_Int32 len );
Appends the string representation of the <code>char</code> array argument to this string buffer.
OStringBuffer &
append( sal_Bool b );
Appends the string representation of the <code>sal_Bool</code> argument to the string buffer.
OStringBuffer &
append( sal_Char c );
Appends the string representation of the <code>char</code> argument to this string buffer.
OStringBuffer &
append( sal_Int32 i, sal_Int16 radix = 10 );
Appends the string representation of the <code>sal_Int32</code> argument to this string buffer.
OStringBuffer &
append( sal_Int64 l, sal_Int16 radix = 10 );
Appends the string representation of the <code>long</code> argument to this string buffer.
OStringBuffer &
append( float f );
Appends the string representation of the <code>float</code> argument to this string buffer.
OStringBuffer &
append( double d );
Appends the string representation of the <code>double</code> argument to this string buffer.
OStringBuffer &
insert( sal_Int32 offset, const OString & str );
Inserts the string into this string buffer.
OStringBuffer &
insert( sal_Int32 offset, const sal_Char * str );
Inserts the string representation of the <code>char</code> array argument into this string buffer.
OStringBuffer &
insert( sal_Int32 offset, const sal_Char * str, sal_Int32 len );
Inserts the string representation of the <code>char</code> array argument into this string buffer.
OStringBuffer &
insert( sal_Int32 offset, sal_Bool b );
Inserts the string representation of the <code>sal_Bool</code> argument into this string buffer.
OStringBuffer &
insert( sal_Int32 offset, sal_Char c );
Inserts the string representation of the <code>char</code> argument into this string buffer.
OStringBuffer &
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.
OStringBuffer &
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.
OStringBuffer
insert( sal_Int32 offset, float f );
Inserts the string representation of the <code>float</code> argument into this string buffer.
OStringBuffer &
insert( sal_Int32 offset, double d );
Inserts the string representation of the <code>double</code> argument into this string buffer.

Private Members

Data

rtl_String * 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.