System::Text::StringBuilder Class Reference

Inherits System::Object.

Public Member Functions

 StringBuilder ()
 Constructor. More...
 
 StringBuilder (int capacity)
 
 StringBuilder (const String &str)
 
 StringBuilder (const String &value, int capacity)
 
 StringBuilder (const String &value, int startIndex, int length, int capacity)
 
 ~StringBuilder ()
 Destructor. More...
 
int get_Length () const
 
void set_Length (int len)
 
int get_Capacity () const
 
char_t operator[] (int index) const
 
char_t idx_get (int index) const
 
void idx_set (int index, char_t c)
 
StringBuilderAppend (char_t c)
 
StringBuilderAppend (char_t c, int count)
 
StringBuilderAppend (const ArrayPtr< char_t > &arr)
 
StringBuilderAppend (const ArrayPtr< char_t > &arr, int startIndex, int charCount)
 
StringBuilderAppend (const String &str)
 
StringBuilderAppend (const String &str, int startIndex, int charCount)
 
template<class T >
StringBuilderAppend (const SharedPtr< T > &obj)
 
StringBuilderAppend (const SharedPtr< StringBuilder > &builder)
 
StringBuilderAppend (float f)
 
StringBuilderAppend (double df)
 
StringBuilderAppend (int i)
 
template<typename T >
std::enable_if< std::is_arithmetic< T >::value, StringBuilder * >::type Append (T value)
 
template<class E >
std::enable_if< std::is_enum< E >::value, StringBuilder * >::type Append (E e)
 
template<class... TArgs>
StringBuilderAppendFormat (const String &format, const TArgs &... args)
 
template<class... TArgs>
StringBuilderAppendFormat (const SharedPtr< IFormatProvider > &fp, const String &format, const TArgs &... args)
 
StringBuilderAppendLine ()
 
StringBuilderAppendLine (const String &str)
 
StringBuilderInsert (int startIndex, const String &str)
 
StringBuilderInsert (int32_t index, const String &value, int32_t count)
 
StringBuilderInsert (int startIndex, char_t ch)
 
StringBuilderInsert (int index, const System::ArrayPtr< char_t > &chars, int startIndex, int charCount)
 
template<typename T >
std::enable_if< std::is_arithmetic< T >::value, StringBuilder * >::type Insert (int startIndex, T value)
 
StringBuilderReplace (const String &oldString, const String &newString)
 
StringBuilderReplace (const String &oldString, const String &newString, int position, int count)
 
StringBuilderReplace (char_t oldChar, char_t newChar)
 
StringBuilderReplace (char_t oldChar, char_t newChar, int startIndex, int count)
 
StringBuilderRemove (int startIndex, int length)
 
String ToString () ASPOSE_CONST override
 
String ToString (int startIndex, int length) const
 
void CopyTo (int sourceIndex, System::ArrayPtr< char_t > const &destination, int destinationIndex, int count)
 
- Public Member Functions inherited from System::Object
 Object ()
 Creates object. Initializes all internal data structures. More...
 
virtual ~Object ()
 Destroys object. Frees all internal data structures. More...
 
 Object (Object const &x)
 Copy constructor. Doesn't copy anything, really, just initializes new object and enables copy constructing subclasses. More...
 
Objectoperator= (Object const &x)
 Assignment operator. Doesn't copy anything, really, just initializes new object and enables copy constructing subclasses. More...
 
ObjectSharedRefAdded ()
 Increments shared reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
int SharedRefRemovedSafe ()
 Decrements and returns shared reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
int RemovedSharedRefs (int count)
 Decreases shared reference count by specified value. More...
 
Detail::SmartPtrCounter * WeakRefAdded ()
 Increments weak reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
void WeakRefRemoved ()
 Decrements weak reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
Detail::SmartPtrCounter * GetCounter ()
 Gets reference counter data structure associated with the object. More...
 
int SharedCount () const
 Gets current value of shared refernce counter. More...
 
void Lock ()
 Implements C# lock() statement locking. Call directly or use LockContext sentry object. More...
 
void Unlock ()
 Implements C# lock() statement unlocking. Call directly or use LockContext sentry object. More...
 
virtual bool Equals (ptr obj)
 Compares objects using C# Object.Equals semantics. More...
 
virtual int GetHashCode () const
 Analog of C# Object.GetHashCode() method. Enables hashing of custom objects. More...
 
virtual ptr MemberwiseClone () const
 Analog of C# Object.MemberwiseClone() method. Enables cloning custom types. More...
 
virtual const TypeInfoGetType () const
 Gets actual type of object. Analog of C# System.Object.GetType() call. More...
 
virtual bool Is (const TypeInfo &targetType) const
 Check if object represents an instance of type described by targetType. Analog of C# 'is' operator. More...
 
virtual void SetTemplateWeakPtr (unsigned int argument)
 Set n'th template argument a weak pointer (rather than shared). Allows switching pointers in containers to weak mode. More...
 
template<>
bool Equals (float const &objA, float const &objB)
 
template<>
bool Equals (double const &objA, double const &objB)
 
template<>
bool ReferenceEquals (String const &str, std::nullptr_t)
 
template<>
bool ReferenceEquals (String const &str1, String const &str2)
 

Additional Inherited Members

- Public Types inherited from System::Object
typedef SmartPtr< Objectptr
 Alias for smart pointer type. More...
 
typedef System::Details::SharedMembersType shared_members_type
 structure to keep list of shared pointers contained in object. More...
 
- Static Public Member Functions inherited from System::Object
static bool ReferenceEquals (ptr const &objA, ptr const &objB)
 Compares objects by reference. More...
 
template<typename T >
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, T const &objB)
 Compares objects by reference. More...
 
template<typename T >
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, std::nullptr_t)
 Reference-compares value type object with nullptr. More...
 
template<typename T1 , typename T2 >
static std::enable_if< IsSmartPtr< T1 >::value &&IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 Compares reference type objects in C# style. More...
 
template<typename T1 , typename T2 >
static std::enable_if<!IsSmartPtr< T1 >::value &&!IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 Compares value type objects in C# style. More...
 
static const TypeInfoType ()
 Impleemnts C# typeof(System.Object) construct. More...
 

Detailed Description

Buffer to accumulate string part by part. This type can be allocated either in stack as value type or in heap using System::MakeObject() function. Once the object is allocated, never mix up these two usecases: having SmartPtr pointers onto stack-allocated objects is strictly prohibited.

Constructor & Destructor Documentation

◆ StringBuilder() [1/5]

System::Text::StringBuilder::StringBuilder ( )

Constructor.

◆ StringBuilder() [2/5]

System::Text::StringBuilder::StringBuilder ( int  capacity)

Constructor.

Parameters
capacityInitial string capacity.

◆ StringBuilder() [3/5]

System::Text::StringBuilder::StringBuilder ( const String str)

Constructor.

Parameters
strInitial value.

◆ StringBuilder() [4/5]

System::Text::StringBuilder::StringBuilder ( const String value,
int  capacity 
)

Constructor.

Parameters
valueInitial value.
capacityInitial string capacity.

◆ StringBuilder() [5/5]

System::Text::StringBuilder::StringBuilder ( const String value,
int  startIndex,
int  length,
int  capacity 
)

Constructor.

Parameters
valueInitial value.
startIndexIndex of initial value slice beginning.
lengthInitial value slice length.
capacityInitial string capacity.

◆ ~StringBuilder()

System::Text::StringBuilder::~StringBuilder ( )

Destructor.

Member Function Documentation

◆ Append() [1/13]

StringBuilder* System::Text::StringBuilder::Append ( char_t  c)

Adds character to builder.

Parameters
cCharacter value.
Returns
This pointer.

◆ Append() [2/13]

StringBuilder* System::Text::StringBuilder::Append ( char_t  c,
int  count 
)

Adds characters to builder.

Parameters
cCharacter value.
countHow many times to repeat insertee character.
Returns
This pointer.

◆ Append() [3/13]

StringBuilder* System::Text::StringBuilder::Append ( const ArrayPtr< char_t > &  arr)

Adds characters array to builder.

Parameters
arrCharacters to add.
Returns
This pointer.

◆ Append() [4/13]

StringBuilder* System::Text::StringBuilder::Append ( const ArrayPtr< char_t > &  arr,
int  startIndex,
int  charCount 
)

Adds characters array slice to builder.

Parameters
arrCharacters to add.
startIndexSlice beginning index.
charCountSlice length.
Returns
This pointer.

◆ Append() [5/13]

StringBuilder* System::Text::StringBuilder::Append ( const String str)

Adds string to builder.

Parameters
strString to add.
Returns
This pointer.

◆ Append() [6/13]

StringBuilder* System::Text::StringBuilder::Append ( const String str,
int  startIndex,
int  charCount 
)

Adds string slice to builder.

Parameters
strString to add.
startIndexSlice beginning index.
charCountSlice length.
Returns
This pointer.

◆ Append() [7/13]

template<class T >
StringBuilder* System::Text::StringBuilder::Append ( const SharedPtr< T > &  obj)
inline

Adds object's string representation to builder.

Template Parameters
TObject type.
Parameters
objObject to serialize and add.
Returns
This pointer.

◆ Append() [8/13]

StringBuilder* System::Text::StringBuilder::Append ( const SharedPtr< StringBuilder > &  builder)

Adds builder's content to builder.

Parameters
builderBuilder to add content from.
Returns
This pointer.

◆ Append() [9/13]

StringBuilder* System::Text::StringBuilder::Append ( float  f)

Adds floating point value to builder.

Parameters
fValue to serialize and add.
Returns
This pointer.

◆ Append() [10/13]

StringBuilder* System::Text::StringBuilder::Append ( double  df)

Adds floating point value to builder.

Parameters
dfValue to serialize and add.
Returns
This pointer.

◆ Append() [11/13]

StringBuilder* System::Text::StringBuilder::Append ( int  i)

Adds integer value to builder.

Parameters
iValue to serialize and add.
Returns
This pointer.

◆ Append() [12/13]

template<typename T >
std::enable_if<std::is_arithmetic<T>::value, StringBuilder*>::type System::Text::StringBuilder::Append ( value)
inline

Adds arithmetic value to builder.

Template Parameters
TArithmetic type.
Parameters
valueValue to serialize and add.
Returns
This pointer.

◆ Append() [13/13]

template<class E >
std::enable_if< std::is_enum<E>::value, StringBuilder*>::type System::Text::StringBuilder::Append ( e)
inline

Adds enum value string representation to builder.

Template Parameters
EEnum type.
Parameters
eValue to serialize and add.
Returns
This pointer.

◆ AppendFormat() [1/2]

template<class... TArgs>
StringBuilder* System::Text::StringBuilder::AppendFormat ( const String format,
const TArgs &...  args 
)
inline

Appends formated string to builder.

Template Parameters
TArgsArguments type.
Parameters
formatFormat string.
argsArguments to insert into format string positions.
Returns
This pointer.

◆ AppendFormat() [2/2]

template<class... TArgs>
StringBuilder* System::Text::StringBuilder::AppendFormat ( const SharedPtr< IFormatProvider > &  fp,
const String format,
const TArgs &...  args 
)
inline

Appends formated string to builder.

Template Parameters
TArgsArguments type.
Parameters
fpFormat provider; ignored.
formatFormat string.
argsArguments to insert into format string positions.
Returns
This pointer.

◆ AppendLine() [1/2]

StringBuilder* System::Text::StringBuilder::AppendLine ( )

Appends new line character to builder.

Returns
This pointer.

◆ AppendLine() [2/2]

StringBuilder* System::Text::StringBuilder::AppendLine ( const String str)

Appends string followed by new line character to builder.

Parameters
strString to add.
Returns
This pointer.

◆ CopyTo()

void System::Text::StringBuilder::CopyTo ( int  sourceIndex,
System::ArrayPtr< char_t > const &  destination,
int  destinationIndex,
int  count 
)

Copies builder's data into existing array positions.

Parameters
sourceIndexIndex in builder to start copying from.
destinationDestination array.
destinationIndexIndex in destination array to start insertion at.
countNumber of characters to copy.

◆ get_Capacity()

int System::Text::StringBuilder::get_Capacity ( ) const

Gets current capacity of string builder.

Returns
Number of allocated characters.

◆ get_Length()

int System::Text::StringBuilder::get_Length ( ) const

Gets length of string currently in builder.

Returns
Number of characters currently stored in builder.

◆ idx_get()

char_t System::Text::StringBuilder::idx_get ( int  index) const

Gets character at specified position.

Parameters
indexPosition in builder.
Returns
Character at specified position.

◆ idx_set()

void System::Text::StringBuilder::idx_set ( int  index,
char_t  c 
)

Sets character at specified position.

Parameters
indexPosition in builder.
cCharacter to set.

◆ Insert() [1/5]

StringBuilder* System::Text::StringBuilder::Insert ( int  startIndex,
const String str 
)

Inserts string into builder's fixed position.

Parameters
startIndexPosition to insert characters into.
strString to insert.
Returns
This pointer.

◆ Insert() [2/5]

StringBuilder* System::Text::StringBuilder::Insert ( int32_t  index,
const String value,
int32_t  count 
)

Inserts repeated string into builder's fixed position.

Parameters
indexPosition to insert characters into.
valueString to insert.
countHow many times to repeat value string.
Returns
This pointer.

◆ Insert() [3/5]

StringBuilder* System::Text::StringBuilder::Insert ( int  startIndex,
char_t  ch 
)

Inserts character into builder's fixed position.

Parameters
startIndexPosition to insert characters into.
chCharacter to insert.
Returns
This pointer.

◆ Insert() [4/5]

StringBuilder* System::Text::StringBuilder::Insert ( int  index,
const System::ArrayPtr< char_t > &  chars,
int  startIndex,
int  charCount 
)

Inserts characters into builder's fixed position.

Parameters
indexPosition to insert characters into.
charsArray to insert slice from.
startIndexArray slice beginning index.
charCountArray slice length.
Returns
This pointer.

◆ Insert() [5/5]

template<typename T >
std::enable_if<std::is_arithmetic<T>::value, StringBuilder*>::type System::Text::StringBuilder::Insert ( int  startIndex,
value 
)
inline

Inserts value into builder's fixed position.

Template Parameters
Parametertype.
Parameters
startIndexPosition to insert characters into.
valueValue to format and insert.
Returns
This pointer.

◆ operator[]()

char_t System::Text::StringBuilder::operator[] ( int  index) const

Gets character at specified position.

Parameters
indexPosition in builder.
Returns
Character at specified position.

◆ Remove()

StringBuilder* System::Text::StringBuilder::Remove ( int  startIndex,
int  length 
)

Removes fragment from builder.

Parameters
startIndexDeletion range beginning index.
lengthNumber of characters to remove.
Returns
This pointer.

◆ Replace() [1/4]

StringBuilder* System::Text::StringBuilder::Replace ( const String oldString,
const String newString 
)

Replaces substring through the builder.

Parameters
oldStringString to replace.
newStringReplacement string.
Returns
This pointer.

◆ Replace() [2/4]

StringBuilder* System::Text::StringBuilder::Replace ( const String oldString,
const String newString,
int  position,
int  count 
)

Replaces substring through the builder's range.

Parameters
oldStringString to replace.
newStringReplacement string.
positionBuilder's replacement range beginning position.
countBuilder's replacement range length.
Returns
This pointer.

◆ Replace() [3/4]

StringBuilder* System::Text::StringBuilder::Replace ( char_t  oldChar,
char_t  newChar 
)

Replaces character through the builder.

Parameters
oldCharCharacter to replace.
newCharReplacement character.
Returns
This pointer.

◆ Replace() [4/4]

StringBuilder* System::Text::StringBuilder::Replace ( char_t  oldChar,
char_t  newChar,
int  startIndex,
int  count 
)

Replaces character through the builder's range.

Parameters
oldCharCharacter to replace.
newCharReplacement character.
startIndexBuilder's replacement range beginning position.
countBuilder's replacement range length.
Returns
This pointer.

◆ set_Length()

void System::Text::StringBuilder::set_Length ( int  len)

Trunkates or extends string builder to specified length.

Parameters
lenLength to set.

◆ ToString() [1/2]

String System::Text::StringBuilder::ToString ( )
overridevirtual

Gets string currently contained in builder.

Returns
String representation of builder's data.

Reimplemented from System::Object.

◆ ToString() [2/2]

String System::Text::StringBuilder::ToString ( int  startIndex,
int  length 
) const

Gets substring currently contained in builder.

Parameters
startIndexExtraction range beginning index.
lengthNumber of characters to extract.
Returns
String representation of builder's data subrange.