System::Text::StringBuilder Class Reference

Inherits System::Object.

Public Member Functions

ASPOSECPP_SHARED_API StringBuilder ()
 Constructor. More...
 
ASPOSECPP_SHARED_API StringBuilder (int capacity)
 
ASPOSECPP_SHARED_API StringBuilder (const String &str)
 
ASPOSECPP_SHARED_API StringBuilder (const String &value, int capacity)
 
ASPOSECPP_SHARED_API StringBuilder (const String &value, int startIndex, int length, int capacity)
 
ASPOSECPP_SHARED_API ~StringBuilder ()
 Destructor. More...
 
ASPOSECPP_SHARED_API int get_Length () const
 
ASPOSECPP_SHARED_API void set_Length (int len)
 
ASPOSECPP_SHARED_API int get_Capacity () const
 
ASPOSECPP_SHARED_API void set_Capacity (int capacity)
 
ASPOSECPP_SHARED_API char_t operator[] (int index) const
 
ASPOSECPP_SHARED_API char_t idx_get (int index) const
 
ASPOSECPP_SHARED_API void idx_set (int index, char_t c)
 
ASPOSECPP_SHARED_API StringBuilderAppend (char_t c)
 
ASPOSECPP_SHARED_API StringBuilderAppend (char_t c, int count)
 
ASPOSECPP_SHARED_API StringBuilderAppend (const ArrayPtr< char_t > &arr)
 
ASPOSECPP_SHARED_API StringBuilderAppend (const ArrayPtr< char_t > &arr, int startIndex, int charCount)
 
ASPOSECPP_SHARED_API StringBuilderAppend (const String &str)
 
ASPOSECPP_SHARED_API StringBuilderAppend (const String &str, int startIndex, int charCount)
 
template<class T >
StringBuilderAppend (const SharedPtr< T > &obj)
 
ASPOSECPP_SHARED_API StringBuilderAppend (const SharedPtr< StringBuilder > &builder)
 
ASPOSECPP_SHARED_API StringBuilderAppend (float f)
 
ASPOSECPP_SHARED_API StringBuilderAppend (double df)
 
ASPOSECPP_SHARED_API 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)
 
ASPOSECPP_SHARED_API StringBuilderAppendLine ()
 
ASPOSECPP_SHARED_API StringBuilderAppendLine (const String &str)
 
ASPOSECPP_SHARED_API StringBuilderClear ()
 
ASPOSECPP_SHARED_API StringBuilderInsert (int startIndex, const String &str)
 
ASPOSECPP_SHARED_API StringBuilderInsert (int32_t index, const String &value, int32_t count)
 
ASPOSECPP_SHARED_API StringBuilderInsert (int startIndex, char_t ch)
 
ASPOSECPP_SHARED_API 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)
 
ASPOSECPP_SHARED_API StringBuilderReplace (const String &oldString, const String &newString)
 
ASPOSECPP_SHARED_API StringBuilderReplace (const String &oldString, const String &newString, int position, int count)
 
ASPOSECPP_SHARED_API StringBuilderReplace (char_t oldChar, char_t newChar)
 
ASPOSECPP_SHARED_API StringBuilderReplace (char_t oldChar, char_t newChar, int startIndex, int count)
 
ASPOSECPP_SHARED_API StringBuilderRemove (int startIndex, int length)
 
ASPOSECPP_SHARED_API String ToString () const override
 
ASPOSECPP_SHARED_API String ToString (int startIndex, int length) const
 
ASPOSECPP_SHARED_API void CopyTo (int sourceIndex, System::ArrayPtr< char_t > const &destination, int destinationIndex, int count)
 
- Public Member Functions inherited from System::Object
ASPOSECPP_SHARED_API Object ()
 Creates object. Initializes all internal data structures. More...
 
virtual ASPOSECPP_SHARED_API ~Object ()
 Destroys object. Frees all internal data structures. More...
 
ASPOSECPP_SHARED_API 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 reference counter. More...
 
ASPOSECPP_SHARED_API void Lock ()
 Implements C# lock() statement locking. Call directly or use LockContext sentry object. More...
 
ASPOSECPP_SHARED_API void Unlock ()
 Implements C# lock() statement unlocking. Call directly or use LockContext sentry object. More...
 
virtual ASPOSECPP_SHARED_API bool Equals (ptr obj)
 Compares objects using C# Object.Equals semantics. More...
 
virtual ASPOSECPP_SHARED_API int32_t GetHashCode () const
 Analog of C# Object.GetHashCode() method. Enables hashing of custom objects. More...
 
virtual ASPOSECPP_SHARED_API ptr MemberwiseClone () const
 Analog of C# Object.MemberwiseClone() method. Enables cloning custom types. More...
 
virtual ASPOSECPP_SHARED_API const TypeInfoGetType () const
 Gets actual type of object. Analog of C# System.Object.GetType() call. More...
 
virtual ASPOSECPP_SHARED_API bool Is (const TypeInfo &targetType) const
 Check if object represents an instance of type described by targetType. Analog of C# 'is' operator. More...
 
virtual ASPOSECPP_SHARED_API void SetTemplateWeakPtr (uint32_t argument)
 Set n'th template argument a weak pointer (rather than shared). Allows switching pointers in containers to weak mode. More...
 
virtual ASPOSECPP_SHARED_API bool FastCast (const Details::FastRttiBase &helper, void **out_ptr) const
 For internal purposes only. 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...
 
- 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 ()
 Implements 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]

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

Constructor.

◆ StringBuilder() [2/5]

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

Constructor.

Parameters
capacityInitial string capacity.

◆ StringBuilder() [3/5]

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

Constructor.

Parameters
strInitial value.

◆ StringBuilder() [4/5]

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

Constructor.

Parameters
valueInitial value.
capacityInitial string capacity.

◆ StringBuilder() [5/5]

ASPOSECPP_SHARED_API 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()

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

Destructor.

Member Function Documentation

◆ Append() [1/13]

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

Adds character to builder.

Parameters
cCharacter value.
Returns
This pointer.

◆ Append() [2/13]

ASPOSECPP_SHARED_API 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]

ASPOSECPP_SHARED_API 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]

ASPOSECPP_SHARED_API 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]

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

Adds string to builder.

Parameters
strString to add.
Returns
This pointer.

◆ Append() [6/13]

ASPOSECPP_SHARED_API 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]

ASPOSECPP_SHARED_API 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]

ASPOSECPP_SHARED_API 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]

ASPOSECPP_SHARED_API 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]

ASPOSECPP_SHARED_API 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]

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

Appends new line character to builder.

Returns
This pointer.

◆ AppendLine() [2/2]

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

Appends string followed by new line character to builder.

Parameters
strString to add.
Returns
This pointer.

◆ Clear()

ASPOSECPP_SHARED_API StringBuilder* System::Text::StringBuilder::Clear ( )

Removes all characters from the builder.

Returns
This pointer.

◆ CopyTo()

ASPOSECPP_SHARED_API 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()

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

Gets current capacity of string builder.

Returns
Number of allocated characters.

◆ get_Length()

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

Gets length of string currently in builder.

Returns
Number of characters currently stored in builder.

◆ idx_get()

ASPOSECPP_SHARED_API 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()

ASPOSECPP_SHARED_API 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]

ASPOSECPP_SHARED_API 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]

ASPOSECPP_SHARED_API 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]

ASPOSECPP_SHARED_API 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]

ASPOSECPP_SHARED_API 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[]()

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

Gets character at specified position.

Parameters
indexPosition in builder.
Returns
Character at specified position.

◆ Remove()

ASPOSECPP_SHARED_API 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]

ASPOSECPP_SHARED_API 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]

ASPOSECPP_SHARED_API 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]

ASPOSECPP_SHARED_API 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]

ASPOSECPP_SHARED_API 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_Capacity()

ASPOSECPP_SHARED_API void System::Text::StringBuilder::set_Capacity ( int  capacity)

Sets current capacity of string builder.

Parameters
capacityMaximum number of characters that can be contained in the memory allocated by the current instance.

◆ set_Length()

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

Trunkates or extends string builder to specified length.

Parameters
lenLength to set.

◆ ToString() [1/2]

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

Gets string currently contained in builder.

Returns
String representation of builder's data.

Reimplemented from System::Object.

◆ ToString() [2/2]

ASPOSECPP_SHARED_API 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.