PrevNextUpHome BREW C++ Class Library & GUI Framework & XML Middleware : SophiaFramework 4.1
SFXAnsiString
Class that represents a string of AChar type.
#include <SFXAnsiString.h.hpp>
class SFXAnsiString;
SFMTYPEDEFCLASS(SFXAnsiString)

Collaboration diagram

 Collaboration diagram of SFXAnsiStringClass

Description

SFXAnsiString and SFXWideString

In the BREW environment, there are two kinds of character types: the char type that represents single byte character or multi-byte character, and the AECHAR type that represents 2 byte character.

SophiaFramewok defines these two kinds of types as AChar and WChar respectively.

And SophiaFramework provides two kinds of String classes: the SFXAnsiString class for the string of AChar characters and the SFXWideString class for the string of WChar characters.

How to Empty a String

There are two methods to empty a string:

In the former method, its heap is not released. By block allocation support, to allocate new memory is unnecessary when a string is newly created in this heap. Therefore its processing speed is very fast.

In the latter method, its heap is released. Though the released heap is free for other tasks, its processing speed slows down.

Which method to choose depends upon the trade-off between processing speed and memory usage.

Example 454. Method 1: Substitute an empty string or call the SFXAnsiString::SetLength function:

SFXAnsiString str = "The best C++ Programming Environment for BREW";

str = ";
// OR:
str.SetLength(0);

// the heap is not released

Example 455. Method 2: Call the Clear function:

SFXAnsiString str = "The best C++ Programming Environment for BREW";

str.Clear();

// the heap is released

When short strings are frequently processed, the method of calling the SFXAnsiString::SetLength function is more efficient.

SFXAnsiString str;

str = "BREW";
...
str.SetLength(0);
...
str = "C++";
...
str.SetLength(0);
...
str = "GUI";
...
str.SetLength(0);
...
str = "XML";
...

Attach Function and Detach Function

The SFXAnsiString::Attach function delegates the control privilege of AChar string to the SFXAnsiString object. Therefore, it is unnecessary to release the memory of AChar string. The SFXAnsiString::Detach function has the reverse functionality.

Though the data is copied by using the SFXAnsiString::Set function and the substitution operator(=), while using the SFXAnsiString::Attach function and the SFXAnsiString::Detach function, data will not be copied.

When there is not enough heap for copying a several hundreds KB string, or to avoid the performance deterioration, use these functions.

What is delegation?: In object oriented programming, delegation means that an object have another deputy object behave like itself.

Example 456. How to use the Attach function

SFXAnsiString str;
ACharPtr ptr;

// allocate the memory and cast to the AChar string(ptr)
ptr = static_cast<ACharPtr>(MemoryAllocate(10240)); 
...

// delegate the control privilege of AChar string(ptr) to the SFXAnsiString object(str)
str.Attach(ptr, 10240);
// hereafter, the AChar string(ptr) will be handled as the SFXAnsiString object(str)

・・・

// after used, the allocated memory will be released automatically

Example 457. How to use the Detach function

SFXAnsiString str;
ACharPtr ptr;
SInt32 length;

str = "The best application for BREW.";

...

// delegate the control privilege of SFXAnsiString object(str) to the AChar string(ptr)
ptr = str.Detach(&length);
// hereafter, the SFXAnsiString object(str) will be handled as AChar string(ptr)

...

// after used, it is necessary to release the memory of AChar string(ptr) 
MemoryFree(ptr);

AttachSFXBuffer Function and DetachSFXBuffer Function

These functions are used to delegate the control privilege between the SFXAnsiString and SFXBuffer objects.

Related information : Attach Function and Detach Function

Reference

SFXWideString | SFXBuffer

Member

Constructor/Destructor
SFXAnsiString( Void )
Constructor of SFXAnsiString class.
SFXAnsiString( SFXAnsiStringConstRef string )
Constructor of SFXAnsiString class.
SFXAnsiString( SFXWideStringConstRef string )
Constructor of SFXAnsiString class.
SFXAnsiString( ACharConstPtr string , SInt32 length = -1 )
Constructor of SFXAnsiString class.
SFXAnsiString( WCharConstPtr string , SInt32 length = -1 )
Constructor of SFXAnsiString class.
SFXAnsiString( AChar character )
Constructor of SFXAnsiString class.
SFXAnsiString( SFXBufferConstRef buffer )
Constructor of SFXAnsiString class.
SFXAnsiString( UInt16 threshold , UInt16 cluster )
Constructor of SFXAnsiString class.
~SFXAnsiString( Void )
Destructor of SFXAnsiString class.
Public Functions
SFCError Add( SFXAnsiStringConstRef string )
Add( AChar character )
Add( ACharConstPtr string , SInt32 length = -1 )
Add a string
SFXAnsiString AsLower( Void )
Convert the string into lower characters.
SInt32 AsSInt32( SInt32 substitute = 0 )
Convert the string into SInt32 type.
UInt32 AsUInt32( UInt32 substitute = 0 )
Convert the string into UInt32 type.
SFXAnsiString AsUpper( Void )
Convert the string into capital character.
SFCError Attach( ACharPtr string , SInt32 length = -1 )
Delegate the control privilege of the specified AChar string to the SFXAnsiString object.
SFCError AttachSFXBuffer( SFXBufferPtr buffer )
Delegate the control privilege of the specified SFXBuffer object to the SFXAnsiString object.
Void Clear( Void )
Clear the string.
SInt32 Compare( SFXAnsiStringConstRef string , Bool sensitive = true )
Compare( ACharConstPtr string , Bool sensitive = true )
Compare with a specified string by dictionary order.
SFXAnsiString Concat( SFXAnsiStringConstRef string )
Concat( AChar character )
Concat( ACharConstPtr string , SInt32 length = -1 )
Concatenate with a specified string.
SFCError Copy( SInt32 index , SFXAnsiStringConstRef string )
Copy( SInt32 index , ACharConstPtr string , SInt32 length = -1 )
Overwrite with a specified string.
ACharPtr Detach( SInt32Ptr length = null )
Delegate the control privilege of SFXAnsiString object to the specified AChar string.
SFCError DetachSFXBuffer( SFXBufferPtr buffer )
Delegate the control privilege of specified SFXAnsiString object to the SFXBuffer object.
static
SFXAnsiStringConstRef
EmptyInstance( Void )
Get an empty string.
Bool EndsWith( SFXAnsiStringConstRef string , Bool sensitive = true )
EndsWith( AChar character , Bool sensitive = true )
EndsWith( ACharConstPtr string , Bool sensitive = true )
Check whether the string ends with a specified string or not.
Bool Equals( SFXAnsiStringConstRef string , Bool sensitive = true )
Equals( ACharConstPtr string , Bool sensitive = true )
Check whether the string equals the specified string or not.
Void Fill( AChar character )
Fill the string with a specified character.
SInt32 FirstIndexOf( SFXAnsiStringConstRef string , SInt32 index = SINT32_MINIMUM , Bool sensitive = true )
FirstIndexOf( AChar character , SInt32 index = SINT32_MINIMUM , Bool sensitive = true )
FirstIndexOf( ACharConstPtr string , SInt32 index = SINT32_MINIMUM , Bool sensitive = true )
Get the first index of SFXAnsiString object to match with a specified data, searching from the beginning.
static
SFXAnsiString
Format( va_ref< SFXAnsiStringConst > format , ... )
Format( WCharConstPtr format , ... )
Format( ACharConstPtr format , ... )
Format( va_ref< SFXWideStringConst > format , ... )
Create a string by using the format.
static
SFXAnsiString
FormatV( SFXAnsiStringConstRef format , va_list argument )
FormatV( WCharConstPtr format , va_list argument )
FormatV( ACharConstPtr format , va_list argument )
FormatV( SFXWideStringConstRef format , va_list argument )
Create a string by using the format with a variable-length argument.
ACharPtr GetBuffer( Void )
Get the internal buffer of string.
ACharConstPtr GetBuffer( Void )
Get the internal buffer of string.
ACharConstPtr GetCString( Void )
Get the const pointer to the internal buffer of string. The buffer cannot be updated through this pointer.
AChar GetChar( SInt32 index )
Get the character at the specified index.
UInt16 GetCluster( Void )
Get the cluster size of internal buffer memory.
SInt32 GetLength( Void )
Get the length of string.
SInt32 GetLengthCString( Void )
Get the length of string until the first null character.
UInt16 GetThreshold( Void )
Get the minimum value of internal buffer.
SFXAnsiString Insert( SInt32 index , SFXAnsiStringConstRef string )
Insert( SInt32 index , AChar character )
Insert( SInt32 index , ACharConstPtr string , SInt32 length = -1 )
Insert a string or character at the specified index of SFXAnsiString object.
Bool IsAlpha( Void )
Check whether all the characters in the string are alphabetic or not.
Bool IsAlphaDigit( Void )
Check whether all the characters in the string are alphanumeric or not.
Bool IsAscii( Void )
Check whether all the characters in the string are Ascii or not.
Bool IsControl( Void )
Check whether all the characters in the string are control or not.
Bool IsDigit( Void )
Check whether all the characters in the string are digit or not.
Bool IsEmpty( Void )
Check whether the length of string is 0 or not.
Bool IsEmptyCString( Void )
Check whether the first character is a null or not.
Bool IsGraph( Void )
Check whether all the characters in the string are graph or not.
Bool IsHexDigit( Void )
Check whether all the characters in the string are Hex digit or not.
Bool IsLower( Void )
Check whether all the characters in the string are lower or not.
Bool IsPrint( Void )
Check whether all the characters in the string are printable or not.
Bool IsPunct( Void )
Check whether all the characters in the string are not space nor alphanumeric but printable or not.
Bool IsSpace( Void )
Check whether or not all the characters in the string are spaces or line-feed.
Bool IsUpper( Void )
Check whether all the characters in the string are capital or not.
Bool Isnull( Void )
Check whether all the characters in the string are null or not.
SInt32 LastIndexOf( SFXAnsiStringConstRef string , SInt32 index = SINT32_MAXIMUM , Bool sensitive = true )
LastIndexOf( AChar character , SInt32 index = SINT32_MAXIMUM , Bool sensitive = true )
LastIndexOf( ACharConstPtr string , SInt32 index = SINT32_MAXIMUM , Bool sensitive = true )
Get the last index of SFXAnsiString object to match with a specified data, searching from the end.
SFCError Mul( SInt32 repeat )
Repeat the string by the specified times.
SFXAnsiString Remove( SInt32 begin , SInt32 end )
Remove the characters within the specified range.
SFXAnsiString Replace( SFXAnsiStringConstRef fstring , SFXAnsiStringConstRef tstring , Bool sensitive = true )
Replace( AChar fcharacter , ACharConstPtr tstring , SInt32 tlength , Bool sensitive = true )
Replace( AChar fcharacter , ACharConstPtr tstring , Bool sensitive = true )
Replace( ACharConstPtr fstring , SInt32 flength , AChar tcharacter , Bool sensitive = true )
Replace( ACharConstPtr fstring , AChar tcharacter , Bool sensitive = true )
Replace( AChar fcharacter , AChar tcharacter , Bool sensitive = true )
Replace( AChar fcharacter , SFXAnsiStringConstRef tstring , Bool sensitive = true )
Replace( SFXAnsiStringConstRef fstring , AChar tcharacter , Bool sensitive = true )
Replace( ACharConstPtr fstring , SInt32 flength , ACharConstPtr tstring , SInt32 tlength , Bool sensitive = true )
Replace( ACharConstPtr fstring , ACharConstPtr tstring , Bool sensitive = true )
Replace( ACharConstPtr fstring , SInt32 flength , SFXAnsiStringConstRef tstring , Bool sensitive = true )
Replace( ACharConstPtr fstring , SFXAnsiStringConstRef tstring , Bool sensitive = true )
Replace( SFXAnsiStringConstRef fstring , ACharConstPtr tstring , SInt32 tlength , Bool sensitive = true )
Replace( SFXAnsiStringConstRef fstring , ACharConstPtr tstring , Bool sensitive = true )
Replace the string.
SFCError Set( SFXAnsiStringConstRef string )
Set( SFXBufferConstRef buffer )
Set( AChar character )
Set( WCharConstPtr string , SInt32 length = -1 )
Set( ACharConstPtr string , SInt32 length = -1 )
Set( SFXWideStringConstRef string )
Set the string.
SFCError SetChar( SInt32 index , AChar character )
Set a character at the specified index.
Void SetCluster( UInt16 size )
Set the cluster size of internal buffer memory.
SFCError SetLength( SInt32 length )
Set the length of string.
Void SetThreshold( UInt16 size )
Set the minimum size of internal buffer.
Bool StartsWith( SFXAnsiStringConstRef string , Bool sensitive = true )
StartsWith( AChar character , Bool sensitive = true )
StartsWith( ACharConstPtr string , Bool sensitive = true )
Check whether the string starts with a specified string or not.
SFCError Sub( SFXAnsiStringConstRef string )
Sub( AChar character )
Sub( ACharConstPtr string , SInt32 length = -1 )
Delete the specified string from the end of source string.
SFXAnsiString Substring( SInt32 begin , SInt32 end )
Get the sub-string from the source string.
Void ToLower( Void )
Convert the string into lower characters.
Void ToUpper( Void )
Convert the string into capital characters.
SFXAnsiString Trim( SFXAnsiStringConstRef string , Bool sensitive = true )
Trim( Void )
Trim( AChar character , Bool sensitive = true )
Trim( ACharConstPtr string , Bool sensitive = true )
Trim the blank characters or the specified string/character from the beginning and end of source string.
SFXAnsiString TrimLeft( SFXAnsiStringConstRef string , Bool sensitive = true )
TrimLeft( Void )
TrimLeft( AChar character , Bool sensitive = true )
TrimLeft( ACharConstPtr string , Bool sensitive = true )
Trim the blank characters or the specified string/character from the beginning of source string.
SFXAnsiString TrimRight( SFXAnsiStringConstRef string , Bool sensitive = true )
TrimRight( Void )
TrimRight( AChar character , Bool sensitive = true )
TrimRight( ACharConstPtr string , Bool sensitive = true )
Trim the blank characters or the specified string/character from the end of source string.
SFXAnsiString Truncate( Void )
Get the string until the first "null" character.
SFXAnsiStringRef operator*=( SInt32 repeat )
Repeat the string by the specified times.
SFXAnsiStringRef operator+=( SFXAnsiStringConstRef string )
operator+=( AChar character )
operator+=( ACharConstPtr string )
Add string.
SFXAnsiStringRef operator-=( SFXAnsiStringConstRef string )
operator-=( AChar character )
operator-=( ACharConstPtr string )
Delete the specified string from the end of source string.
SFXAnsiStringRef operator<<( SFXAnsiStringRef left , SFXAnsiStringConstRef right )
operator<<( SFXAnsiStringRef left , AChar right )
operator<<( SFXAnsiStringRef left , WCharConstPtr right )
operator<<( SFXAnsiStringRef left , ACharConstPtr right )
operator<<( SFXAnsiStringRef left , SFXWideStringConstRef right )
Append a string on the end of string.
SFXAnsiStringRef operator=( SFXAnsiStringConstRef string )
operator=( WCharConstPtr string )
operator=( ACharConstPtr string )
operator=( SFXWideStringConstRef string )
Substitute the string with a specified string.
ACharRef operator[]( SInt32 index )
Get the character at the specified index.
ACharConstRef operator[]( SInt32 index )
Get the character at the specified index.
Bool operator==( SFXAnsiStringConstRef left , SFXAnsiStringConstRef right )
operator==( WCharConstPtr left , SFXAnsiStringConstRef right )
operator==( ACharConstPtr left , SFXAnsiStringConstRef right )
operator==( SFXAnsiStringConstRef left , WCharConstPtr right )
operator==( SFXAnsiStringConstRef left , ACharConstPtr right )
operator==( SFXAnsiStringConstRef left , SFXWideStringConstRef right )
Check the "=" relation.
Bool operator>=( SFXAnsiStringConstRef left , SFXAnsiStringConstRef right )
operator>=( WCharConstPtr left , SFXAnsiStringConstRef right )
operator>=( ACharConstPtr left , SFXAnsiStringConstRef right )
operator>=( SFXAnsiStringConstRef left , WCharConstPtr right )
operator>=( SFXAnsiStringConstRef left , ACharConstPtr right )
operator>=( SFXAnsiStringConstRef left , SFXWideStringConstRef right )
Check the ">=" relation.
Bool operator>( SFXAnsiStringConstRef left , SFXAnsiStringConstRef right )
operator>( WCharConstPtr left , SFXAnsiStringConstRef right )
operator>( ACharConstPtr left , SFXAnsiStringConstRef right )
operator>( SFXAnsiStringConstRef left , WCharConstPtr right )
operator>( SFXAnsiStringConstRef left , ACharConstPtr right )
operator>( SFXAnsiStringConstRef left , SFXWideStringConstRef right )
Check the ">" relation.
Bool operator<=( SFXAnsiStringConstRef left , SFXAnsiStringConstRef right )
operator<=( WCharConstPtr left , SFXAnsiStringConstRef right )
operator<=( ACharConstPtr left , SFXAnsiStringConstRef right )
operator<=( SFXAnsiStringConstRef left , WCharConstPtr right )
operator<=( SFXAnsiStringConstRef left , ACharConstPtr right )
operator<=( SFXAnsiStringConstRef left , SFXWideStringConstRef right )
Check the "<=" relation.
Bool operator<( SFXAnsiStringConstRef left , SFXAnsiStringConstRef right )
operator<( WCharConstPtr left , SFXAnsiStringConstRef right )
operator<( ACharConstPtr left , SFXAnsiStringConstRef right )
operator<( SFXAnsiStringConstRef left , WCharConstPtr right )
operator<( SFXAnsiStringConstRef left , ACharConstPtr right )
operator<( SFXAnsiStringConstRef left , SFXWideStringConstRef right )
Check the "<" relation.
SFXAnsiString operator-( SFXAnsiStringConstRef left , SFXAnsiStringConstRef right )
operator-( AChar left , SFXAnsiStringConstRef right )
operator-( SFXAnsiStringConstRef left , AChar right )
operator-( WCharConstPtr left , SFXAnsiStringConstRef right )
operator-( ACharConstPtr left , SFXAnsiStringConstRef right )
operator-( SFXAnsiStringConstRef left , WCharConstPtr right )
operator-( SFXAnsiStringConstRef left , ACharConstPtr right )
operator-( SFXAnsiStringConstRef left , SFXWideStringConstRef right )
Delete the specified string from the end of left-hand string.
SFXAnsiString operator*( SFXAnsiStringConstRef left , SInt32 right )
Repeat the string by the specified times.
Bool operator!=( SFXAnsiStringConstRef left , SFXAnsiStringConstRef right )
operator!=( WCharConstPtr left , SFXAnsiStringConstRef right )
operator!=( ACharConstPtr left , SFXAnsiStringConstRef right )
operator!=( SFXAnsiStringConstRef left , WCharConstPtr right )
operator!=( SFXAnsiStringConstRef left , ACharConstPtr right )
operator!=( SFXAnsiStringConstRef left , SFXWideStringConstRef right )
Check the "!=" relation.
SFXAnsiString operator+( SFXAnsiStringConstRef left , SFXAnsiStringConstRef right )
operator+( AChar left , SFXAnsiStringConstRef right )
operator+( SFXAnsiStringConstRef left , AChar right )
operator+( WCharConstPtr left , SFXAnsiStringConstRef right )
operator+( ACharConstPtr left , SFXAnsiStringConstRef right )
operator+( SFXAnsiStringConstRef left , WCharConstPtr right )
operator+( SFXAnsiStringConstRef left , ACharConstPtr right )
operator+( SFXAnsiStringConstRef left , SFXWideStringConstRef right )
Add string.
Types
DefaultEnum
Constants that represent the threshold of internal heap size and the default value of cluster size.
Global Functions
Bool operator==( SFXAnsiStringConstRef left , SFXAnsiStringConstRef right )
operator==( WCharConstPtr left , SFXAnsiStringConstRef right )
operator==( ACharConstPtr left , SFXAnsiStringConstRef right )
operator==( SFXAnsiStringConstRef left , WCharConstPtr right )
operator==( SFXAnsiStringConstRef left , ACharConstPtr right )
operator==( SFXAnsiStringConstRef left , SFXWideStringConstRef right )
Check the "=" relation.
Bool operator>=( SFXAnsiStringConstRef left , SFXAnsiStringConstRef right )
operator>=( WCharConstPtr left , SFXAnsiStringConstRef right )
operator>=( ACharConstPtr left , SFXAnsiStringConstRef right )
operator>=( SFXAnsiStringConstRef left , WCharConstPtr right )
operator>=( SFXAnsiStringConstRef left , ACharConstPtr right )
operator>=( SFXAnsiStringConstRef left , SFXWideStringConstRef right )
Check the ">=" relation.
Bool operator>( SFXAnsiStringConstRef left , SFXAnsiStringConstRef right )
operator>( WCharConstPtr left , SFXAnsiStringConstRef right )
operator>( ACharConstPtr left , SFXAnsiStringConstRef right )
operator>( SFXAnsiStringConstRef left , WCharConstPtr right )
operator>( SFXAnsiStringConstRef left , ACharConstPtr right )
operator>( SFXAnsiStringConstRef left , SFXWideStringConstRef right )
Check the ">" relation.
Bool operator<=( SFXAnsiStringConstRef left , SFXAnsiStringConstRef right )
operator<=( WCharConstPtr left , SFXAnsiStringConstRef right )
operator<=( ACharConstPtr left , SFXAnsiStringConstRef right )
operator<=( SFXAnsiStringConstRef left , WCharConstPtr right )
operator<=( SFXAnsiStringConstRef left , ACharConstPtr right )
operator<=( SFXAnsiStringConstRef left , SFXWideStringConstRef right )
Check the "<=" relation.
Bool operator<( SFXAnsiStringConstRef left , SFXAnsiStringConstRef right )
operator<( WCharConstPtr left , SFXAnsiStringConstRef right )
operator<( ACharConstPtr left , SFXAnsiStringConstRef right )
operator<( SFXAnsiStringConstRef left , WCharConstPtr right )
operator<( SFXAnsiStringConstRef left , ACharConstPtr right )
operator<( SFXAnsiStringConstRef left , SFXWideStringConstRef right )
Check the "<" relation.
SFXAnsiString operator-( SFXAnsiStringConstRef left , SFXAnsiStringConstRef right )
operator-( AChar left , SFXAnsiStringConstRef right )
operator-( SFXAnsiStringConstRef left , AChar right )
operator-( WCharConstPtr left , SFXAnsiStringConstRef right )
operator-( ACharConstPtr left , SFXAnsiStringConstRef right )
operator-( SFXAnsiStringConstRef left , WCharConstPtr right )
operator-( SFXAnsiStringConstRef left , ACharConstPtr right )
operator-( SFXAnsiStringConstRef left , SFXWideStringConstRef right )
Delete the specified string from the end of left-hand string.
SFXAnsiString operator*( SFXAnsiStringConstRef left , SInt32 right )
Repeat the string by the specified times.
Bool operator!=( SFXAnsiStringConstRef left , SFXAnsiStringConstRef right )
operator!=( WCharConstPtr left , SFXAnsiStringConstRef right )
operator!=( ACharConstPtr left , SFXAnsiStringConstRef right )
operator!=( SFXAnsiStringConstRef left , WCharConstPtr right )
operator!=( SFXAnsiStringConstRef left , ACharConstPtr right )
operator!=( SFXAnsiStringConstRef left , SFXWideStringConstRef right )
Check the "!=" relation.
SFXAnsiString operator+( SFXAnsiStringConstRef left , SFXAnsiStringConstRef right )
operator+( AChar left , SFXAnsiStringConstRef right )
operator+( SFXAnsiStringConstRef left , AChar right )
operator+( WCharConstPtr left , SFXAnsiStringConstRef right )
operator+( ACharConstPtr left , SFXAnsiStringConstRef right )
operator+( SFXAnsiStringConstRef left , WCharConstPtr right )
operator+( SFXAnsiStringConstRef left , ACharConstPtr right )
operator+( SFXAnsiStringConstRef left , SFXWideStringConstRef right )
Add string.

SFXAnsiString::SFXAnsiString
Constructor of SFXAnsiString class.
[ public, explicit ]
SFXAnsiString(Void);
[ public ]
SFXAnsiString(
    SFXAnsiStringConstRef string   // source string for copying
);
[ public ]
SFXAnsiString(
    SFXWideStringConstRef string   // source string for copying
);
[ public ]
SFXAnsiString(
    ACharConstPtr string   // WChar pointer to Source string for copying
    SInt32 length = -1     // length of string
);
[ public ]
SFXAnsiString(
    WCharConstPtr string   // WChar pointer to Source string for copying
    SInt32 length = -1     // length of string
);
[ public, explicit ]
SFXAnsiString(
    AChar character   // AChar string
);
[ public, explicit ]
SFXAnsiString(
    SFXBufferConstRef buffer   // source buffer for copying
);
[ public, explicit ]
SFXAnsiString(
    UInt16 threshold   // the mininum value of buffer size
    UInt16 cluster     // cluster size
);

Description

When the SFXAnsiString class or the SFXWideString class is specified for the constructor of the SFXAnsiString class, the string is copied.

If the pointer of AChar or WChar is specified, it is interpreted and copied as a null-terminated string.

If the length is specified, binary string contains null can be processed, too.

When AChar is specified, only one character is made.

Reference

SFXAnsiString::Set | SFXAnsiString::operator=


SFXAnsiString::~SFXAnsiString
Destructor of SFXAnsiString class.
[ public ]
~SFXAnsiString(Void);

Description

The internal string buffer is released.


SFXAnsiString::Add
Add a string
[ public ]
SFCError Add(
    SFXAnsiStringConstRef string   // string to add
);
[ public ]
SFCError Add(
    ACharConstPtr string   // string to add
    SInt32 length = -1     // length of the string
);
[ public ]
SFCError Add(
    AChar character   // character to add
);

Return value

  • Success : SFERR_NO_ERROR
  • If insufficient : SFERR_NO_MEMORY
  • If failed : SFERR_FAILED

Description

The Add function influences the character string. If want to keep the source string, use the Concat() function.

Reference

SFXAnsiString::Concat | SFXAnsiString::Sub | SFXAnsiString::Mul | SFXAnsiString::operator<< | operator+ | SFXAnsiString::operator+=


SFXAnsiString::AsLower
Convert the string into lower characters.
[ public, const ]
SFXAnsiString AsLower(Void);

Description

The source string will not be modified by calling the AsLower() function.

Reference

SFXAnsiString::AsUpper | SFXAnsiString::ToLower


SFXAnsiString::AsSInt32
Convert the string into SInt32 type.
[ public, const ]
SInt32 AsSInt32(
    SInt32 substitute = 0   // the value when the conversion is failed
);

Description

If unable to convert, a specified value is returned to substitute.

Reference

SFXAnsiString::AsUInt32


SFXAnsiString::AsUInt32
Convert the string into UInt32 type.
[ public, const ]
UInt32 AsUInt32(
    UInt32 substitute = 0   // the value when the conversion is failed
);

Description

If unable to convert, a specified value is returned to substitute.

Reference

SFXAnsiString::AsSInt32


SFXAnsiString::AsUpper
Convert the string into capital character.
[ public, const ]
SFXAnsiString AsUpper(Void);

Description

The source string will not be modified by calling the AsUpper() function.

Reference

SFXAnsiString::AsLower | SFXAnsiString::ToUpper


SFXAnsiString::Attach
Delegate the control privilege of the specified AChar string to the SFXAnsiString object.
[ public ]
SFCError Attach(
    ACharPtr string      // string managed by SFXAnsiString
    SInt32 length = -1   // length of the string
);

Return value

  • Success : SFERR_NO_ERROR
  • If failed : SFERR_INVALID_PARAM

Description

The SFXAnsiString::Attach function is more efficient than the SFXAnsiString::Set function, since the AChar string is not copied and the problem on insufficient memory or performance deterioration can be avoided.

The memory the allocated to AChar string will be released automatically when the SFXAnsiString object is released. To release the memory allocated to the AChar string explicitly, it is necessary to call the SFXAnsiString::Detach function.

Example

SFXAnsiString str;
ACharPtr ptr;

// allocate the memory and cast to the AChar string(ptr)
ptr = static_cast<ACharPtr>(MemoryAllocate(10240));

...

// delegate the control privilege of AChar string(ptr) to the SFXAnsiString object(str)
str.Attach(ptr, 10240);
// hereafter, the AChar string(ptr) can be handled as the SFXAnsiString object(str)

・・・

// after used, the allocated memory will be released automatically

Reference

SFXAnsiString::Detach


SFXAnsiString::AttachSFXBuffer
Delegate the control privilege of the specified SFXBuffer object to the SFXAnsiString object.
[ public ]
SFCError AttachSFXBuffer(
    SFXBufferPtr buffer   // buffer to use
);

Return value

  • Success : SFERR_NO_ERROR
  • If the buffer parameter is null, or failed : SFERR_INVALID_PARAM

Description

The SFXAnsiString::AttachSFXBuffer function is more efficient than the SFXAnsiString::Set function, since the SFXBuffer object is not copied and the problem on insufficient memory or performance deterioration can be avoided.

The SFXBuffer object instance will be released automatically when the SFXAnsiString object is released. To release the SFXBuffer object explicitly, it is necessary to call the SFXAnsiString::DetachSFXBuffer function.

Example

SFXAnsiString str;
SFXBuffer buffer;

// allocate the memory for the SFXBuffer object(buffer)
buffer.SetSize(10240);

...

// delegate the control privilege of SFXBuffer object(buffer) to the SFXAnsiString object(str)
str.AttachSFXBuffer(&buffer);
// hereafter, the SFXBuffer object(buffer) can be handled as the SFXAnsiString object(str)

・・・

// after used, the allocated memory will be released automatically

Reference

SFXAnsiString::Attach | SFXAnsiString::Detach | SFXAnsiString::DetachSFXBuffer


SFXAnsiString::Clear
Clear the string.
[ public ]
Void Clear(Void);

Description

It releases the heap.


SFXAnsiString::Compare
Compare with a specified string by dictionary order.
[ public, const ]
SInt32 Compare(
    SFXAnsiStringConstRef string   // string to cpmpare with
    Bool sensitive = true          // case-sensitive or not
);
[ public, const ]
SInt32 Compare(
    ACharConstPtr string    // string to cpmpare with
    Bool sensitive = true   // case-sensitive or not
);

Return value

  • If the string is less than the specified string : Minus value
  • If the string equals the specified string : 0
  • If the string is greater than the specified string : Positive value

Reference

SFXAnsiString::Equals | operator== | operator!=


SFXAnsiString::Concat
Concatenate with a specified string.
[ public, const ]
SFXAnsiString Concat(
    SFXAnsiStringConstRef string   // string to concatenate with
);
[ public, const ]
SFXAnsiString Concat(
    ACharConstPtr string   // string to concatenate with
    SInt32 length = -1     // length of the string
);
[ public, const ]
SFXAnsiString Concat(
    AChar character   // character to concatenate with
);

Return value

Return the concatenated string.

Description

The SFXAnsiString::Concat function concatenates the end of source string with a specified string. The source string will not be modified.

Reference

SFXAnsiString::Add | operator+ | SFXAnsiString::operator+=


SFXAnsiString::Copy
Overwrite with a specified string.
[ public ]
SFCError Copy(
    SInt32 index                   // starting position to overwrite
    SFXAnsiStringConstRef string   // string to overwrite with
);
[ public ]
SFCError Copy(
    SInt32 index           // starting position to overwrite
    ACharConstPtr string   // string to overwrite with
    SInt32 length = -1     // length of the string
);

Return value

  • Success : SFERR_NO_ERROR
  • If exceeds the end of source string : SFERR_INVALID_PARAM

Description

If the string after overwriting exceeds the end of source string, the source string is restored and return SFERR_INVALID_PARAM.


SFXAnsiString::Detach
Delegate the control privilege of SFXAnsiString object to the specified AChar string.
[ public ]
ACharPtr Detach(
    SInt32Ptr length = null   // the pointer to the length of the string
);

Return value

Return the AChar string which the SFXAnsiString object has.

Description

The SFXAnsiString::Detach function is more efficient than the SFXAnsiString::GetChar function, since the SFXAnsiString object is not copied and the problem on insufficient memory or performance deterioration can be avoided.

Example

SFXAnsiString str;
ACharPtr ptr;
SInt32 length;

str = "The best application for BREW.";

...

// delegate the control privilege of the SFXAnsiString object(str) to the AChar string(ptr)
ptr = str.Detach(&length);
// hereafter, the SFXAnsiString object(str) will be handled as the AChar string(ptr)

...

// after used, it is necessary to release the memory of AChar string(ptr) 
MemoryFree(ptr);

Reference

SFXAnsiString::Attach


SFXAnsiString::DetachSFXBuffer
Delegate the control privilege of specified SFXAnsiString object to the SFXBuffer object.
[ public ]
SFCError DetachSFXBuffer(
    SFXBufferPtr buffer   // pointer to the SFXBuffer object that will be substituted by a string data
);

Return value

  • Success : SFERR_NO_ERROR
  • If the buffer parameter is null, or failed : SFERR_INVALID_PARAM

Description

The SFXAnsiString object is not copied and the problem on insufficient memory or performance deterioration can be avoided.

Example

SFXAnsiString str;
SFXBuffer buffer;

str = "The best application for BREW.";

...

// delegate the control privilege of SFXAnsiString object(str) to the SFXBuffer object(buffer)
str.DetachSFXBuffer(&buffer);  
// hereafter, the SFXAnsiString object(str) will be handled as the SFXBuffer object(buffer)

・・・

// after used, the SFXBuffer object(buffer) will be released automatically

Reference

SFXAnsiString::Attach | SFXAnsiString::AttachSFXBuffer | SFXAnsiString::Detach


SFXAnsiString::EmptyInstance
Get an empty string.
[ public, static ]
SFXAnsiStringConstRef EmptyInstance(Void);

Description

Return the reference to the instance of enpty string as the return value of function.


SFXAnsiString::EndsWith
Check whether the string ends with a specified string or not.
[ public, const ]
Bool EndsWith(
    SFXAnsiStringConstRef string   // string to check with
    Bool sensitive = true          // case-sensitive or not
);
[ public, const ]
Bool EndsWith(
    ACharConstPtr string    // string to check with
    Bool sensitive = true   // case-sensitive or not
);
[ public, const ]
Bool EndsWith(
    AChar character         // string to check with
    Bool sensitive = true   // case-sensitive or not
);

Return value

  • If ends with a specified string : true
  • Otherwise : false

Reference

SFXAnsiString::StartsWith


SFXAnsiString::Equals
Check whether the string equals the specified string or not.
[ public, const ]
Bool Equals(
    SFXAnsiStringConstRef string   // string to compare with
    Bool sensitive = true          // case-sensitive or not
);
[ public, const ]
Bool Equals(
    ACharConstPtr string    // string to compare with
    Bool sensitive = true   // case-sensitive or not
);

Return value

  • If equals the specified string : true
  • Otherwise : false

Reference

SFXAnsiString::Compare | operator== | operator!=


SFXAnsiString::Fill
Fill the string with a specified character.
[ public ]
Void Fill(
    AChar character   // character
);

SFXAnsiString::FirstIndexOf
Get the first index of SFXAnsiString object to match with a specified data, searching from the beginning.
[ public, const ]
SInt32 FirstIndexOf(
    SFXAnsiStringConstRef string    // string to match with
    SInt32 index = SINT32_MINIMUM   // starting index to search from
    Bool sensitive = true           // case-sensitive or not
);
[ public, const ]
SInt32 FirstIndexOf(
    ACharConstPtr string            // string to  match with
    SInt32 index = SINT32_MINIMUM   // starting index to search from
    Bool sensitive = true           // case-sensitive or not
);
[ public, const ]
SInt32 FirstIndexOf(
    AChar character                 // character to match with
    SInt32 index = SINT32_MINIMUM   // starting index to search from
    Bool sensitive = true           // case-sensitive or not
);

Return value

  • Success : The first index where found.
  • If failed : -1

Description

To search from other than the beginning, specify the starting index to match with. (The origin index is 0.)

Reference

SFXAnsiString::LastIndexOf


SFXAnsiString::Format
Create a string by using the format.
[ public, static ]
SFXAnsiString Format(
    va_ref< SFXAnsiStringConst > format   // string that represents a format
    ...                                   // data
);
[ public, static ]
SFXAnsiString Format(
    va_ref< SFXWideStringConst > format   // string that represents a format
    ...                                   // data
);
[ public, static ]
SFXAnsiString Format(
    ACharConstPtr format   // string that represents a format
    ...                    // data
);
[ public, static ]
SFXAnsiString Format(
    WCharConstPtr format   // string that represents a format
    ...                    // data
);

Description

The SFXAnsiString::Format function is almost the same as the printf function in C language, the format on float is not available.

Example

SIntN year = 2003;
SIntN month = 8;
SFXAnsiString str = SFXAnsiString::Format("%d Year %d Month ", year, month);

Reference

BREW API VSNPRINTF


SFXAnsiString::FormatV
Create a string by using the format with a variable-length argument.
[ public, static ]
SFXAnsiString FormatV(
    SFXAnsiStringConstRef format   // string that represents a format
    va_list argument               // variable-length argument
);
[ public, static ]
SFXAnsiString FormatV(
    SFXWideStringConstRef format   // string that represents a format
    va_list argument               // variable-length argument
);
[ public, static ]
SFXAnsiString FormatV(
    ACharConstPtr format   // string that represents a format
    va_list argument       // variable-length argument
);
[ public, static ]
SFXAnsiString FormatV(
    WCharConstPtr format   // string that represents a format
    va_list argument       // variable-length argument
);

Description

The SFXAnsiString::FormatV fun