PrevNextUpHome SophiaFramework UNIVERSE 5.3
SFXBuffer
Class which represents a buffer.
#include <SFXBuffer.h.hpp>
class SFXBuffer;
SFMTYPEDEFCLASS(SFXBuffer)

Collaboration diagram

 Collaboration diagram of SFXBufferClass

Description

What is the SFXBuffer class?

The SFXBuffer class adds functionalities such as buffer concatenation, data search and replacement and so on to the SFXClusterHeap class.

To get the size of allocated memory, use the SFXBuffer::GetSize function.

Though the destructor automatically releases the allocated memory, it can be released explicitly by the SFXBuffer::Free function.

Also the size of allocated buffer can be updated by the SFXBuffer::SetSize function. At this time the data is saved.

To access directly the buffer that the SFXBuffer class manages inside, use the SFXBuffer::GetBuffer function.

Attach Function and Detach Function

The SFXBuffer::Attach function attaches the specified data area to the SFXBuffer object. The SFXWideString::Detach function provides the reverse functionality.

The SFXBuffer::Attach function delegates the control privilege of Void data to the SFXBufferg object. Therefore, it is unnecessary to release the memory of Void data. The SFXBuffer::Detach function has the reverse functionality.

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

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

Reference

SFXClusterHeap | SFXAnsiString | SFXWideString | Buffer

Member

Constructor/Destructor
SFXBuffer( Void )
Constructor of the SFXBuffer class.
SFXBuffer( SFXBufferConstRef buffer )
Constructor of the SFXBuffer class.
SFXBuffer( VoidConstPtr buffer , UInt32 size )
Constructor of the SFXBuffer class.
SFXBuffer( Byte byte )
Constructor of the SFXBuffer class.
SFXBuffer( SFXAnsiStringConstRef string )
Constructor of the SFXBuffer class.
SFXBuffer( SFXWideStringConstRef string )
Constructor of the SFXBuffer class.
SFXBuffer( UInt16 threshold , UInt16 cluster )
Constructor of the SFXBuffer class.
~SFXBuffer( Void )
Destructor of the SFXBuffer class.
Public Functions
SFCError Add( SFXBufferConstRef buffer )
Add the specified data onto the end of this buffer.
SFCError Add( VoidConstPtr buffer , UInt32 size )
Add the specified data onto the end of this buffer.
SFCError Add( Byte byte )
Add the specified data onto the end of this buffer.
SFCError Allocate( UInt32 size )
Allocate the specified size of memory to this buffer.
SFCError Attach( SFXBufferPtr buffer )
Attach the specified data to this buffer object.
SFCError Attach( VoidPtr buffer , UInt32 size )
Attach the specified data to this buffer object.
SFCError Attach( SFXAnsiStringPtr string )
Attach the specified data to this buffer object.
SFCError Attach( SFXWideStringPtr string )
Attach the specified data to this buffer object.
SFCError AttachSFXAnsiString( SFXAnsiStringPtr string )
[DEPRECATED]Attach the internal buffer memory of the specified string object to this buffer object.
SFCError AttachSFXWideString( SFXWideStringPtr string )
[DEPRECATED]Attach the internal buffer memory of the specified string object to this buffer object.
SInt32 Compare( SFXBufferConstRef buffer )
Compare this buffer with the specified data.
SInt32 Compare( VoidConstPtr buffer , UInt32 size )
Compare this buffer with the specified data.
SFCError Copy( UInt32 index , SFXBufferConstRef buffer )
Overwrite the memory area of this buffer starting from the specified index with the specified data.
SFCError Copy( UInt32 index , VoidConstPtr buffer , UInt32 size )
Overwrite the memory area of this buffer starting from the specified index with the specified data.
SFCError Detach( SFXBufferPtr buffer )
Detach the buffer data from this buffer object.
VoidPtr Detach( UInt32Ptr size = null )
Detach the buffer data from this buffer object.
SFCError Detach( SFXAnsiStringPtr string )
Detach the buffer data from this buffer object.
SFCError Detach( SFXWideStringPtr string )
Detach the buffer data from this buffer object.
SFCError DetachSFXAnsiString( SFXAnsiStringPtr string )
[DEPRECATED]Detach the string area from this buffer object.
SFCError DetachSFXWideString( SFXWideStringPtr string )
[DEPRECATED]Detach the string area from this buffer object.
static
SFXBufferConstRef
EmptyInstance( Void )
Get the empty buffer.
Bool EndsWith( SFXBufferConstRef buffer )
Check whether or not this buffer ends with the specified data.
Bool EndsWith( VoidConstPtr buffer , UInt32 size )
Check whether or not this buffer ends with the specified data.
Bool EndsWith( Byte byte )
Check whether or not this buffer ends with the specified data.
Bool Equals( SFXBufferConstRef buffer )
Check whether or not this buffer equals the specified data.
Bool Equals( VoidConstPtr buffer , UInt32 size )
Check whether or not this buffer equals the specified data.
Void Fill( Byte data )
Fill this buffer with the specified data.
SInt32 FirstIndexOf( SFXBufferConstRef buffer , SInt32 index = SINT32_MINIMUM )
Get the first index of the element of this buffer that equals the specified data, searching from the head.
SInt32 FirstIndexOf( VoidConstPtr buffer , UInt32 size , SInt32 index = SINT32_MINIMUM )
Get the first index of the element of this buffer that equals the specified data, searching from the head.
SInt32 FirstIndexOf( Byte byte , SInt32 index = SINT32_MINIMUM )
Get the first index of the element of this buffer that equals the specified data, searching from the head.
Void Free( Void )
Release the internal buffer memory of this buffer.
VoidPtr GetBuffer( Void )
Get the pointer to the internal buffer memory of this buffer.
VoidConstPtr GetBuffer( Void )
Get the pointer to the internal buffer memory of this buffer.
Byte GetByte( UInt32 index )
Get the byte data at the specified index of this buffer.
UInt16 GetCluster( Void )
Get the cluster size of the internal buffer memory. [in bytes]
UInt32 GetSize( Void )
Get the size of this buffer.
UInt16 GetThreshold( Void )
Get the minimum size of the internal buffer memory. [in bytes]
SFCError Insert( UInt32 index , SFXBufferConstRef buffer )
Insert the specified data at the specified index of this buffer.
SFCError Insert( UInt32 index , VoidConstPtr buffer , UInt32 size )
Insert the specified data at the specified index of this buffer.
SFCError Insert( Byte byte )
Insert the specified data at the specified index of this buffer.
Bool IsEmpty( Void )
Check whether or not this buffer is empty.
SInt32 LastIndexOf( SFXBufferConstRef buffer , SInt32 index = SINT32_MAXIMUM )
Get the last index of the element of this buffer that equals the specified data, searching from the tail.
SInt32 LastIndexOf( VoidConstPtr buffer , UInt32 size , SInt32 index = SINT32_MAXIMUM )
Get the last index of the element of this buffer that equals the specified data, searching from the tail.
SInt32 LastIndexOf( Byte byte , SInt32 index = SINT32_MAXIMUM )
Get the last index of the element of this buffer that equals the specified data, searching from the tail.
SFCError Mul( SInt32 repeat )
Extend this buffer by repeating the data of this buffer with the specified frequency.
Void Remove( UInt32 begin , UInt32 end )
Remove the specified data from this buffer.
SFCError Set( SFXBufferConstRef buffer )
Set this buffer by copying the specified data.
SFCError Set( VoidConstPtr buffer , UInt32 size )
Set this buffer by copying the specified data.
SFCError Set( Byte byte )
Set this buffer by copying the specified data.
SFCError Set( SFXAnsiStringConstRef string )
Set this buffer by copying the specified data.
SFCError Set( SFXWideStringConstRef string )
Set this buffer by copying the specified data.
SFCError SetByte( UInt32 index , Byte data )
Set the specified byte data at the specified index of this buffer.
Void SetCluster( UInt16 size )
Set the cluster size of the internal cluster heap. [in bytes]
SFCError SetSize( UInt32 size )
Set the size of this buffer.
Void SetThreshold( UInt16 size )
Set the minimum size of the internal buffer memory. [in bytes]
Void Slice( UInt32 begin , UInt32 end )
Preserve data in the specified range and remove the other.
Bool StartsWith( SFXBufferConstRef buffer )
Check whether or not this buffer starts with the specified data.
Bool StartsWith( VoidConstPtr buffer , UInt32 size )
Check whether or not this buffer starts with the specified data.
Bool StartsWith( Byte byte )
Check whether or not this buffer starts with the specified data.
SFXBufferRef operator*=( SInt32 repeat )
Repeat the data of buffer with the specified frequency.
SFXBufferRef operator+=( SFXBufferConstRef buffer )
Add the specified data onto the end of buffer.
SFXBufferRef operator+=( Byte byte )
Add the specified data onto the end of buffer.
SFXBufferRef operator<<( SFXBufferRef left , SFXBufferConstRef right )
Add the right buffer onto the end of left buffer.
SFXBufferRef operator=( SFXBufferConstRef buffer )
Assign buffer.
ByteRef operator[]( UInt32 index )
Get the buffer data at the specified index.
ByteConstRef operator[]( UInt32 index )
Get the buffer data at the specified index.
Bool operator==( SFXBufferConstRef left , SFXBufferConstRef right )
Check the relation of "==".
Bool operator>=( SFXBufferConstRef left , SFXBufferConstRef right )
Check the relation of ">=".
Bool operator>( SFXBufferConstRef left , SFXBufferConstRef right )
Check the relation of ">".
Bool operator<=( SFXBufferConstRef left , SFXBufferConstRef right )
Check the relation of "<=".
Bool operator<( SFXBufferConstRef left , SFXBufferConstRef right )
Check the relation of "<".
SFXBuffer operator*( SFXBufferConstRef left , SInt32 right )
Repeat the data of buffer with the specified frequency.
Bool operator!=( SFXBufferConstRef left , SFXBufferConstRef right )
Check the relation of "!=".
SFXBuffer operator+( SFXBufferConstRef left , SFXBufferConstRef right )
Add the specified data onto the end of buffer.
SFXBuffer operator+( SFXBufferConstRef left , Byte right )
Add the specified data onto the end of buffer.
Types
DefaultEnum
Constants that represent the default values for the minimum size and the cluster size of the internal buffer memory. [in bytes]
Global Functions
Bool operator==( SFXBufferConstRef left , SFXBufferConstRef right )
Check the relation of "==".
Bool operator>=( SFXBufferConstRef left , SFXBufferConstRef right )
Check the relation of ">=".
Bool operator>( SFXBufferConstRef left , SFXBufferConstRef right )
Check the relation of ">".
Bool operator<=( SFXBufferConstRef left , SFXBufferConstRef right )
Check the relation of "<=".
Bool operator<( SFXBufferConstRef left , SFXBufferConstRef right )
Check the relation of "<".
SFXBuffer operator*( SFXBufferConstRef left , SInt32 right )
Repeat the data of buffer with the specified frequency.
Bool operator!=( SFXBufferConstRef left , SFXBufferConstRef right )
Check the relation of "!=".
SFXBuffer operator+( SFXBufferConstRef left , SFXBufferConstRef right )
Add the specified data onto the end of buffer.
SFXBuffer operator+( SFXBufferConstRef left , Byte right )
Add the specified data onto the end of buffer.

SFXBuffer::SFXBuffer
Constructor of the SFXBuffer class.
[ public, explicit ]
SFXBuffer(Void);
[ public ]
SFXBuffer(
    SFXBufferConstRef buffer   // buffer to copy
);
[ public, explicit ]
SFXBuffer(
    VoidConstPtr buffer   // memory block to copy
    UInt32 size           // size of the memory block
);
[ public, explicit ]
SFXBuffer(
    Byte byte   // byte to copy
);
[ public, explicit ]
SFXBuffer(
    SFXAnsiStringConstRef string   // string to copy
);
[ public, explicit ]
SFXBuffer(
    SFXWideStringConstRef string   // string to copy
);
[ public, explicit ]
SFXBuffer(
    UInt16 threshold   // minimum size of the internal buffer
    UInt16 cluster     // cluster size of the internal buffer
);

Description

This constructor set this buffer by copying the specified data in the argument. The former buffer will be destroyed with this operation. To set this buffer without copying data, use the SFXBuffer::Attach function.

If no arugument or the "threshold" and "cluster" arguments are specified, the internal buffer will not be allocated. In this case, to allocate it, call the SFXBuffer::Allocate, SFXBuffer::SetSize, or SFXBuffer::Set function.

When the SFXAnsiString object is specified, the size of this buffer is "the length of the string + 1(= 1 byte of '\0')". In case of SFXWideString, it is "( the length of the string ) * 2 + 2(= 2 byte of '\0')".

Reference

SFXBuffer::Allocate | SFXBuffer::SetSize | SFXBuffer::Attach | SFXBuffer::Set


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

Description

This destructor will call the SFXBuffer::Free function to release the internal buffer memory of this buffer.

Reference

SFXBuffer::Free


SFXBuffer::Add
Add the specified data onto the end of this buffer.
[ public ]
SFCError Add(
    SFXBufferConstRef buffer   // buffer to add
);
[ public ]
SFCError Add(
    VoidConstPtr buffer   // buffer data to add
    UInt32 size           // size of the buffer data to add
);
[ public ]
SFCError Add(
    Byte byte   // byte to add
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMORY

Description

This function adds the specified data onto the end of this buffer.

The internal buffer memory will be enlarged by the size of the added data.

[Note] Note
This function will influence upon this buffer. To preserve the former data of this buffer, it is necessary to copy it somewhere.

Reference

SFXBuffer::Mul | SFXBuffer::operator<< | operator+ | SFXBuffer::operator+=


SFXBuffer::Allocate
Allocate the specified size of memory to this buffer.
[ public ]
SFCError Allocate(
    UInt32 size   // memory size to allocate
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMORY

Description

This function allocates the specified size of memory to this buffer.

[Note] Note
The buffer memory can be allocated with the SFXBuffer::Set function, the SFXBuffer::SetSize function, or the SFXBuffer::SFXBuffer constructor.
[Note] Note
The behaviours of some functions are not defined when they are called without the internal buffer memory being allocated.
[Caution] Note

The data which this buffer contains before this function is executed will be destroyed.

Reference

SFXBuffer::Free | SFXBuffer::SetSize | SFXBuffer::Set | SFXBuffer::SFXBuffer


SFXBuffer::Attach
Attach the specified data to this buffer object.
[ public ]
SFCError Attach(
    SFXBufferPtr buffer   // SFXBuffer object to attach
);
[ public ]
SFCError Attach(
    VoidPtr buffer   // memory block to attach
    UInt32 size      // size of memory block
);
[ public ]
SFCError Attach(
    SFXAnsiStringPtr string   // SFXAnsiString object to attach
);
[ public ]
SFCError Attach(
    SFXWideStringPtr string   // SFXWideString object to attach
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If the argument is null: SFERR_INVALID_PARAM

Description

This function attaches the specified data to this buffer object. After this function is executed, the specified data can be handled as the SFXBuffer object.

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

[Note] Note
When this buffer object is released, the specified data area will be released automatically together with this buffer object.

Example

The code to attach the VoidPtr data to the SFXBuffer object is as follows:

SFXBuffer buffer;
VoidPtr void_ptr;

// allocate the 10240-byte data area to void_ptr
void_ptr = static_cast<VoidPtr>(MemoryAllocate(10240)); 

...

// attach the allocated void_ptr area to the buffer object
buffer.Attach(void_ptr, 10240);

// hereafter, the allocated void_ptr area can be handled as the buffer object

・・・

// after used, the allocated void_ptr area will be released automatically

Reference

SFXBuffer::Detach


SFXBuffer::AttachSFXAnsiString
[DEPRECATED]Attach the internal buffer memory of the specified string object to this buffer object.
[ public ]
SFCError AttachSFXAnsiString(
    SFXAnsiStringPtr string   // pointer to the string to be attached to this buffer object
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If the argument is null: SFERR_INVALID_PARAM

Description

[Caution] Caution
Since this function will be deprecated in SophiaFramework UNIVERSE 6.0 or above, use the SFXBuffer::Attach function instead.

Reference

SFXBuffer::Attach


SFXBuffer::AttachSFXWideString
[DEPRECATED]Attach the internal buffer memory of the specified string object to this buffer object.
[ public ]
SFCError AttachSFXWideString(
    SFXWideStringPtr string   // string to use
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If the argument is null: SFERR_INVALID_PARAM

Description

[Caution] Caution
Since this function will be deprecated in SophiaFramework UNIVERSE 6.0 or above, use the SFXBuffer::Attach function instead.

Reference

SFXBuffer::Attach


SFXBuffer::Compare
Compare this buffer with the specified data.
[ public, const ]
SInt32 Compare(
    SFXBufferConstRef buffer   // buffer object to compare with
);
[ public, const ]
SInt32 Compare(
    VoidConstPtr buffer   // buffer data to compare with
    UInt32 size           // size of the buffer data to compare with
);

Return value

  • If smaller: minus value
  • If equals: 0
  • If bigger: plus value

Description

This function compares this buffer with the specified data.

Reference

SFXBuffer::Equals | operator== | operator!= | operator> | operator>= | operator< | operator<=


SFXBuffer::Copy
Overwrite the memory area of this buffer starting from the specified index with the specified data.
[ public ]
SFCError Copy(
    UInt32 index               // beginning index to overwrite
    SFXBufferConstRef buffer   // buffer to copy
);
[ public ]
SFCError Copy(
    UInt32 index          // beginning index to overwrite
    VoidConstPtr buffer   // memory block to copy
    UInt32 size           // size of the memory block to copy
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If data to overwrite goes over the end of this buffer: SFERR_INVALID_PARAM

Description

This function overwrites the memory area of this buffer starting from the specified index with the specified data.

[Caution] Caution
If data to overwrite goes over the end of this buffer, SFERR_INVALID_PARAM will be returned and data will not be copied.

SFXBuffer::Detach
Detach the buffer data from this buffer object.
[ public ]
SFCError Detach(
    SFXBufferPtr buffer   // SFXBuffer object to be detached
);
[ public ]
VoidPtr Detach(
    UInt32Ptr size = null   // data size
);
[ public ]
SFCError Detach(
    SFXAnsiStringPtr string   // SFXAnsiString object to be detached
);
[ public ]
SFCError Detach(
    SFXWideStringPtr string   // SFXWideString object to be detachedd
);

Return value

Return the Void data which the SFXBuffer object has.

Description

This function detaches and returns the pointer to the buffer data which this buffer object has controled.

The size of the buffer data will be returned into the size argument after this function is called.

[Note] Note
The buffer data will not be copied.

Example

SFXBuffer buffer;
VoidPtr void_ptr;
UInt32 length;

...

// detach the data area from the buffer object and set the void_ptr variable to this pointer
// the size of the detached buffer data will be stored into the length variable
void_ptr = buffer.Detach(&length);

// hereafter, the heap data of the heap object will be handled via the void_ptr variable

...

// after used, the detached buffer area must be released explicitly
MemoryFree(void_ptr);

Reference

SFXBuffer::Attach


SFXBuffer::DetachSFXAnsiString
[DEPRECATED]Detach the string area from this buffer object.
[ public ]
SFCError DetachSFXAnsiString(
    SFXAnsiStringPtr string   // pointer to the detached string object
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If the argument is null: SFERR_INVALID_PARAM

Description

[Caution] Caution
Since this function will be deprecated in SophiaFramework UNIVERSE 6.0 or above, use the SFXBuffer::Detach function instead.

Reference

SFXBuffer::Detach


SFXBuffer::DetachSFXWideString
[DEPRECATED]Detach the string area from this buffer object.
[ public ]
SFCError DetachSFXWideString(
    SFXWideStringPtr string   // pointer to the detached string object
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If the argument is null: SFERR_INVALID_PARAM

Description

[Caution] Caution
Since this function will be deprecated in SophiaFramework UNIVERSE 6.0 or above, use the SFXBuffer::Detach function instead.

Reference

SFXBuffer::Detach


SFXBuffer::EmptyInstance
Get the empty buffer.
[ public, static ]
SFXBufferConstRef EmptyInstance(Void);

Description

This function gets the empty instance of the SFXBuffer class that represents an empty buffer.


SFXBuffer::EndsWith
Check whether or not this buffer ends with the specified data.
[ public, const ]
Bool EndsWith(
    SFXBufferConstRef buffer   // buffer object to check with
);
[ public, const ]
Bool EndsWith(
    VoidConstPtr buffer   // buffer data to check with
    UInt32 size           // size of the buffer data to check with
);
[ public, const ]
Bool EndsWith(
    Byte byte   // byte data to check with
);

Return value

  • If ends with the specified data: true
  • Otherwise: false

Description

This function checks whether or not this buffer ends with the specified data.

Reference

SFXBuffer::StartsWith


SFXBuffer::Equals
Check whether or not this buffer equals the specified data.
[ public, const ]
Bool Equals(
    SFXBufferConstRef buffer   // buffer object to compare with
);
[ public, const ]
Bool Equals(
    VoidConstPtr buffer   // buffer data to compare with
    UInt32 size           // size of the buffer data to compare with
);

Return value

  • If yes: true
  • Otherwise: false

Description

This function checks whether or not this buffer equals the specified data.

Reference

SFXBuffer::Compare | operator== | operator!=


SFXBuffer::Fill
Fill this buffer with the specified data.
[ public ]
Void Fill(
    Byte data   // data to fill this buffer with
);

Description

This function fills this buffer with the specified data.


SFXBuffer::FirstIndexOf
Get the first index of the element of this buffer that equals the specified data, searching from the head.
[ public, const ]
SInt32 FirstIndexOf(
    SFXBufferConstRef buffer        // buffer object to match
    SInt32 index = SINT32_MINIMUM   // beginning index to search from
);
[ public, const ]
SInt32 FirstIndexOf(
    VoidConstPtr buffer             // buffer data to match
    UInt32 size                     // size of the buffer data to match
    SInt32 index = SINT32_MINIMUM   // beginning index to search from
);
[ public, const ]
SInt32 FirstIndexOf(
    Byte byte                       // byte data to match
    SInt32 index = SINT32_MINIMUM   // beginning index to search from
);

Return value

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

Description

This function gets the first index of the element of this buffer that equals the specified value, searching from the head to the tail.

By specifying the beginning index in the argument, you can search from any position other than the head. (The index of the head is 0.)

Reference

SFXBuffer::LastIndexOf


SFXBuffer::Free
Release the internal buffer memory of this buffer.
[ public ]
Void Free(Void);

Description

This function releases the internal buffer memory allocated to this buffer with the SFXBuffer::Allocate / SFXBuffer::SetSize / SFXBuffer::Set function or the SFXBuffer::SFXBuffer constructor.

[Tip] Tip
This function will be called in the SFXBuffer::~SFXBuffer destructor.
[Note] Note
If no buffer memory is allocated to this buffer, nothing will happen.

Reference

SFXBuffer::Allocate | SFXBuffer::SetSize | SFXBuffer::Set | SFXBuffer::SFXBuffer | SFXBuffer::~SFXBuffer


SFXBuffer::GetBuffer
Get the pointer to the internal buffer memory of this buffer.
[ public ]
VoidPtr GetBuffer(Void);
[ public, const ]
VoidConstPtr GetBuffer(Void);

Return value

Pointer to the internal buffer memory of this buffer

Description

This function gets the pointer to the internal buffer memory of this buffer.

[Note] Note
The buffer memory of the SFXBuffer class can be accessed directly through the pointer gotten with this function.

Example

SFXBuffer buffer;

buffer.Set(SFXAnsiString("test"));   // set the buffer
TRACE("%s", buffer.GetBuffer());     // "test" will be displayed on BREW output window

Reference

SFXBuffer::Set


SFXBuffer::GetByte
Get the byte data at the specified index of this buffer.
[ public, const ]
Byte GetByte(
    UInt32 index   // index to get
);

Return value

Byte data at the specified index of this buffer

Description

This function gets the byte data at the specified index of this buffer.

Reference

SFXBuffer::GetBuffer | SFXBuffer::GetSize | SFXBuffer::SetByte | SFXBuffer::SetSize | SFXBuffer::operator[]


SFXBuffer::GetCluster
Get the cluster size of the internal buffer memory. [in bytes]
[ public, const ]
UInt16 GetCluster(Void);

Return value

Minimum unit to allocate the internal buffer memory(SFXClusterHeap). [in bytes]

Description

This function gets the minimum unit to allocate the internal buffer memory(SFXClusterHeap). [in bytes]

[Note] Note
This function calls the SFXClusterHeap::GetCluster function of the SFXClusterHeap class which the SFXBuffer class manages internally.

Reference

SFXBuffer::SetCluster | SFXClusterHeap::GetCluster | SFXClusterHeap


SFXBuffer::GetSize
Get the size of this buffer.
[ public, const ]
UInt32 GetSize(Void);

Return value

Size of this buffer

Description

This function gets the size of this buffer.

Example

SFXBuffer buffer;

buffer.Set(SFXAnsiString("test"));   // set the buffer to "test"
TRACE("%d", buffer.GetSize());       // "5", length of the "test" string including "\0",  will be displayed on BREW output window

Reference

SFXBuffer::SetSize | SFXBuffer::Set


SFXBuffer::GetThreshold
Get the minimum size of the internal buffer memory. [in bytes]
[ public, const ]
UInt16 GetThreshold(Void);

Return value

Minimum memory of the internal buffer memory(SFXClusterHeap). [in bytes]

Description

This function gets the minimum memory of the internal buffer memory(SFXClusterHeap). [in bytes]

[Note] Note
This function calls the SFXClusterHeap::GetThreshold function of the SFXClusterHeap class which the SFXBuffer class manages internally.

Reference

SFXBuffer::SetThreshold | SFXClusterHeap::GetThreshold | SFXClusterHeap


SFXBuffer::Insert
Insert the specified data at the specified index of this buffer.
[ public ]
SFCError Insert(
    UInt32 index               // index to insert
    SFXBufferConstRef buffer   // buffer object to insert
);
[ public ]
SFCError Insert(
    UInt32 index          // index to insert
    VoidConstPtr buffer   // buffer data to insert
    UInt32 size           // size of the buffer data to insert
);
[ public ]
SFCError Insert(
    Byte byte   // Byte data to insert
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMOERY

Description

This function inserts the specified data at the specified index of this buffer.

The internal buffer memory will be enlarged by the size of the inserted data.

[Note] Note
This function will influence upon this buffer. To preserve the former data of this buffer, it is necessary to copy it somewhere.

Reference

SFXBuffer::Remove


SFXBuffer::IsEmpty
Check whether or not this buffer is empty.
[ public, const ]
Bool IsEmpty(Void);

Return value

  • If yes: true
  • Otherwise: false

Description

This function checks whether or not this buffer is empty.


SFXBuffer::LastIndexOf
Get the last index of the element of this buffer that equals the specified data, searching from the tail.
[ public, const ]
SInt32 LastIndexOf(
    SFXBufferConstRef buffer        // buffer object to match
    SInt32 index = SINT32_MAXIMUM   // beginning index to search from
);
[ public, const ]
SInt32 LastIndexOf(
    VoidConstPtr buffer             // buffer data to match
    UInt32 size                     // size of the buffer data to match
    SInt32 index = SINT32_MAXIMUM   // beginning index to search from
);
[ public, const ]
SInt32 LastIndexOf(
    Byte byte                       // byte data to match
    SInt32 index = SINT32_MAXIMUM   // beginning index to search from
);

Return value

  • If succeeds: The last index where found.
  • If failed: -1

Description

This function gets the last index of the element of this buffer that equals the specified value, searching from the tail to the head.

By specifying the beginning index in the argument, you can search from any position other than the tail. (The index of the head is 0.)

Reference

SFXBuffer::FirstIndexOf


SFXBuffer::Mul
Extend this buffer by repeating the data of this buffer with the specified frequency.
[ public ]
SFCError Mul(
    SInt32 repeat   // frequency to repeat
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMORY

Description

This function extends this buffer by repeating the data of this buffer with the specified frequency.

[Note] Note
The content of this buffer will be changed after this operation. To preserve it, it is necessary to copy it somewhere or use the operator* operator.

Reference

SFXBuffer::Add | operator* | SFXBuffer::operator*=


SFXBuffer::Remove
Remove the specified data from this buffer.
[ public ]
Void Remove(
    UInt32 begin   // beginning index(this index is included)
    UInt32 end     // ending index(this index is not included)
);

Description

This function removes data from the specified starting index to the specified ending index from this buffer.

The internal buffer memory will be shrinked by the size of the removed data.

[Note] Note
This function will influence upon this buffer. To preserve the former data of this buffer, it is necessary to copy it somewhere.

Reference

SFXBuffer::Insert


SFXBuffer::Set
Set this buffer by copying the specified data.
[ public ]
SFCError Set(
    SFXBufferConstRef buffer   // buffer object to copy
);
[ public ]
SFCError Set(
    VoidConstPtr buffer   // buffer data to copy
    UInt32 size           // size of the data to copy
);
[ public ]
SFCError Set(
    Byte byte   // Byte data to copy
);
[ public ]
SFCError Set(
    SFXAnsiStringConstRef string   // string to copy
);
[ public ]
SFCError Set(
    SFXWideStringConstRef string   // string to copy
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMORY

Description

This function set this buffer by copying the specified data in the argument. The former buffer will be destroyed with this operation.

To set this buffer without copying data, use the SFXBuffer::Attach function.

When the SFXAnsiString object is specified, the size of this buffer is "the length of the string + 1(= 1 byte of '\0')". In case of SFXWideString, it is "( the length of the string ) * 2 + 2(= 2 byte of '\0')".

[Note] Note
The buffer memory to copy the specified data will be automatically allocated.

Reference

SFXBuffer::Attach | SFXBuffer::Allocate | SFXBuffer::SFXBuffer


SFXBuffer::SetByte
Set the specified byte data at the specified index of this buffer.
[ public ]
SFCError SetByte(
    UInt32 index   // index to set
    Byte data      // Byte data
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If the specified index is outside of this buffer: SFERR_INVALID_PARAM

Description

This function sets the specified byte data at the specified index of this buffer.

Reference

SFXBuffer::GetBuffer | SFXBuffer::GetByte | SFXBuffer::GetSize | SFXBuffer::SetSize | SFXBuffer::operator[]


SFXBuffer::SetCluster
Set the cluster size of the internal cluster heap. [in bytes]
[ public ]
Void SetCluster(
    UInt16 size   // cluster size to set
);

Description

This function sets the minimum unit to allocate the internal buffer memory(SFXClusterHeap). [in bytes]

Default: SFXBuffer::DEFAULT_CLUSTER bytes

For the value of SFXBuffer::DEFAULT_CLUSTER, refer to SFXBuffer::DefaultEnum.

[Note] Note
This function calls the SFXClusterHeap::SetCluster function of the SFXClusterHeap class which the SFXBuffer class manages internally.

Reference

SFXBuffer::GetCluster | SFXBuffer::DefaultEnum | SFXClusterHeap::SetCluster | SFXClusterHeap


SFXBuffer::SetSize
Set the size of this buffer.
[ public ]
SFCError SetSize(
    UInt32 size   // size to set
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMORY

Description

This function allocates the specified size as the internal buffer memory from the heap of the SFXClusterHeap class which the SFXBuffer class manages internally.

This heap size is determined by the value of the minimun heap size and the cluster size. The minimun heap size is set with the threshold argument of the SFXBuffer::SFXBuffer constructor or the SFXBuffer::SetThreshold function. And the cluster size is specified with the threshold argument of the SFXBuffer::SFXBuffer constructor or the SFXBuffer::SetCluster function.

If the value of size is smaller than or equals that of the minimun heap size, the allocated heap size equals the value of the minimun heap size in effect.

Otherwise, the heap bigger than the minimun heap size is allocated by the cluster size.

[Caution] Caution
  1. If the heap of the SFXClusterHeap class which the SFXBuffer class manages internally is resized, the pointer to the internal buffer which the SFXBuffer::GetBuffer function returns will be changed too.
  2. In case of making the size of the internal buffer memory smaller, the data at the tail will be lost.

Example

SFXBuffer buffer;

buffer.SetSize(0x200); // set the buffer size to 0x200 bytes

Reference

SFXBuffer::GetSize | SFXBuffer::SetCluster | SFXBuffer::SetThreshold | SFXBuffer::GetBuffer | SFXBuffer::Allocate | SFXClusterHeap::Resize


SFXBuffer::SetThreshold
Set the minimum size of the internal buffer memory. [in bytes]
[ public ]
Void SetThreshold(
    UInt16 size   // minimum size of the internal buffer memory to set
);

Description

This function sets the minimum memory of the internal buffer memory(SFXClusterHeap). [in bytes]

Default: SFXBuffer::DEFAULT_THRESHOLD bytes

For the value of SFXBuffer::DEFAULT_THRESHOLD, refer to SFXBuffer::DefaultEnum.

[Note] Note
This function calls the SFXClusterHeap::SetThreshold function of the SFXClusterHeap class which the SFXBuffer class manages internally.

Reference

SFXBuffer::GetThreshold | SFXBuffer::DefaultEnum | SFXClusterHeap::SetThreshold | SFXClusterHeap


SFXBuffer::Slice
Preserve data in the specified range and remove the other.
[ public ]
Void Slice(
    UInt32 begin   // beginning index of buffer to preserve
    UInt32 end     // ending index of buffer to preserve
);

Description

This function preserves the data between "begin" and "end" parameter specified, and removes the other.

The "begin" parameter is set to the first index of the preserved data, and the "end" parameter is set to next to the last index of the preserved data.

[Note] Note
The content of this buffer will be changed after this operation. To preserve it, it is necessary to copy it somewhere.

Example

SFXAnsiString s("abracadabra");
SFXBuffer buf1(s);  // buf1 is copied with null
buf1.Slice(2, 9);   // buf1 = "racadab"

SFXBuffer::StartsWith
Check whether or not this buffer starts with the specified data.
[ public, const ]
Bool StartsWith(
    SFXBufferConstRef buffer   // buffer object to check with
);
[ public, const ]
Bool StartsWith(
    VoidConstPtr buffer   // buffer data to check with
    UInt32 size           // size of the buffer data to check with
);
[ public, const ]
Bool StartsWith(
    Byte byte   // byte data to check with
);

Return value

  • If starts with the specified data: true
  • Otherwise: false

Reference

SFXBuffer::EndsWith


SFXBuffer::operator=
Assign buffer.
[ public ]
SFXBufferRef operator=(
    SFXBufferConstRef buffer   // buffer object to copy
);

Reference

SFXBuffer::Set


operator==
Check the relation of "==".
[ public, friend ]
Bool operator==(
    SFXBufferConstRef left    // SFXBuffer object to compare with
    SFXBufferConstRef right   // SFXBuffer object to compare with
);

Return value

  • If left equals right: true
  • Otherwise: false

Reference

SFXBuffer::Equals | operator!=


operator>=
Check the relation of ">=".
[ public, friend ]
Bool operator>=(
    SFXBufferConstRef left    // SFXBuffer object to compare with
    SFXBufferConstRef right   // SFXBuffer object to compare with
);

Return value

  • If left is greater than or equals right: true
  • Otherwise: false

Reference

SFXBuffer::Compare


operator>
Check the relation of ">".
[ public, friend ]
Bool operator>(
    SFXBufferConstRef left    // SFXBuffer object to compare with
    SFXBufferConstRef right   // SFXBuffer object to compare with
);

Return value

  • If left is greater than right: true
  • Otherwise: false

Reference

SFXBuffer::Compare


SFXBuffer::operator[]
Get the buffer data at the specified index.
[ public ]
ByteRef operator[](
    UInt32 index   // index of buffer data to get
);
[ public, const ]
ByteConstRef operator[](
    UInt32 index   // index of buffer data to get
);

Reference

SFXBuffer::GetByte | SFXBuffer::SetByte


SFXBuffer::operator<<
Add the right buffer onto the end of left buffer.
[ public, friend ]
SFXBufferRef operator<<(
    SFXBufferRef left         // SFXBuffer object to be added
    SFXBufferConstRef right   // SFXBuffer object to add
);

Description

The Soperator<< will influence upon the SFXBuffer object. To preserve the former buffer data, it is necessary to copy it somewhere.

Reference

SFXBuffer::Add


operator<=
Check the relation of "<=".
[ public, friend ]
Bool operator<=(
    SFXBufferConstRef left    // SFXBuffer object to compare with
    SFXBufferConstRef right   // SFXBuffer object to compare with
);

Return value

  • If left is less than or equals right: true
  • Otherwise: false

Reference

SFXBuffer::Compare


operator<
Check the relation of "<".
[ public, friend ]
Bool operator<(
    SFXBufferConstRef left    // SFXBuffer object to compare with
    SFXBufferConstRef right   // SFXBuffer object to compare with
);

Return value

  • If left is less than right: true
  • Otherwise: false

Reference

SFXBuffer::Compare


SFXBuffer::operator*=
Repeat the data of buffer with the specified frequency.
[ public ]
SFXBufferRef operator*=(
    SInt32 repeat   // frequency to repeat
);

Reference

SFXBuffer::Mul | operator*


operator*
Repeat the data of buffer with the specified frequency.
[ public, friend ]
SFXBuffer operator*(
    SFXBufferConstRef left   // SFXBuffer object to repeat
    SInt32 right             // frequency to repeat
);

Reference

SFXBuffer::Mul | SFXBuffer::operator*=


operator!=
Check the relation of "!=".
[ public, friend ]
Bool operator!=(
    SFXBufferConstRef left    // SFXBuffer object to compare with
    SFXBufferConstRef right   // SFXBuffer object to compare with
);

Return value

  • If left does not equal right: true
  • Otherwise: false

Reference

SFXBuffer::Equals | operator==


SFXBuffer::operator+=
Add the specified data onto the end of buffer.
[ public ]
SFXBufferRef operator+=(
    SFXBufferConstRef buffer   // SFXBuffer object to add
);
[ public ]
SFXBufferRef operator+=(
    Byte byte   // Byte data to add
);

Reference

SFXBuffer::Add | operator+


operator+
Add the specified data onto the end of buffer.
[ public, friend ]
SFXBuffer operator+(
    SFXBufferConstRef left    // SFXBuffer object to be added
    SFXBufferConstRef right   // SFXBuffer object to add
);
[ public, friend ]
SFXBuffer operator+(
    SFXBufferConstRef left   // SFXBuffer object to be added
    Byte right               // Byte data to add
);

Reference

SFXBuffer::Add | SFXBuffer::operator+=


SFXBuffer::DefaultEnum
Constants that represent the default values for the minimum size and the cluster size of the internal buffer memory. [in bytes]
enum DefaultEnum {
    DEFAULT_THRESHOLD = 16,     // default minimum size of the internal buffer memory [in bytes]
    DEFAULT_CLUSTER   = 8       // default cluster size to allocate the internal buffer memory [in bytes]
};

Description

DEFAULT_THRESHOLD and DEFAULT_CLUSTER are the constants that represent the default values for the minimum size and the cluster size of the internal buffer memory(SFXClusterHeap). [in bytes]

Reference

SFXBuffer::SetCluster | SFXBuffer::SetThreshold | SFXClusterHeap