PrevNextUpHome BREW C++ Class Library & GUI Framework & XML Middleware : SophiaFramework 4.1
SFXBuffer
Class that 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 delegates the control privilege of the Void data to the instance of SFXBuffer class. Therefore, it is unnecessary to release the memory of the Void data. 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.

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

Example 458. How to use the Attach function

SFXBuffer buffer;
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 SFXBuffer object(buffer)
buffer.Attach(ptr, 10240);
// hereafter, the AChar string(ptr) will be handled as the SFXBuffer object(buffer)

・・・

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

Example 459. How to use the Detach function

SFXBuffer buffer;
VoidPtr ptr;
UInt32 length;

...

// delegate the control privilege of SFXBuffer object(buffer) to the Void data(ptr)
ptr = buffer.Detach(&length);
// hereafter, the SFXBuffer object(buffer) will be operated as the Void data(ptr)

...

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

AttachSFXAnsiString Function and DetachSFXAnsiString Function

These functions are used when delegeting the control privilege between SFXBuffer and SFXAnsiString objects.

Related information : Attach Function and Detach Function

AttachSFXWideString Function and DetachSFXWideString Function

These functions are used when delegeting the control privilege between SFXBuffer and SFXWideString objects.

Related information : Attach Function and Detach Function

Reference

SFXClusterHeap | SFXAnsiString | SFXWideString | Buffer

Member

Constructor/Destructor
SFXBuffer( Void )
Constructor of SFXBuffer class.
SFXBuffer( SFXBufferConstRef buffer )
Constructor of SFXBuffer class.
SFXBuffer( VoidConstPtr buffer , UInt32 size )
Constructor of SFXBuffer class.
SFXBuffer( Byte byte )
Constructor of SFXBuffer class.
SFXBuffer( SFXAnsiStringConstRef string )
Constructor of SFXBuffer class.
SFXBuffer( SFXWideStringConstRef string )
Constructor of SFXBuffer class.
SFXBuffer( UInt16 threshold , UInt16 cluster )
Constructor of SFXBuffer class.
~SFXBuffer( Void )
Destructor of the SFXBuffer class.
Public Functions
SFCError Add( SFXBufferConstRef buffer )
Add( Byte byte )
Add( VoidConstPtr buffer , UInt32 size )
Add the specified data onto the end of buffer.
SFCError Allocate( UInt32 size )
Allocate buffer memory.
SFCError Attach( VoidPtr buffer , UInt32 size )
Delegate the control privilege of the specified Void data to the SFXBuffer object.
SFCError AttachSFXAnsiString( SFXAnsiStringPtr string )
Delegate the control privilege of the specified SFXAnsiString object to the SFXBuffer object.
SFCError AttachSFXWideString( SFXWideStringPtr string )
Delegate the control privilege of the specified SFXWideString object to the SFXBuffer object.
SInt32 Compare( SFXBufferConstRef buffer )
Compare( VoidConstPtr buffer , UInt32 size )
Compare the buffer.
SFCError Copy( UInt32 index , SFXBufferConstRef buffer )
Copy( UInt32 index , VoidConstPtr buffer , UInt32 size )
Overwrite the buffer with the specified data.
VoidPtr Detach( UInt32Ptr size = null )
Delegate the control privilege of SFXBuffer object to the specified Void data.
SFCError DetachSFXAnsiString( SFXAnsiStringPtr string )
Delegate the control privilege of the specified SFXBuffer object to the SFXAnsiString object.
SFCError DetachSFXWideString( SFXWideStringPtr string )
Delegate the control privilege of the specified SFXBuffer object to the SFXWideString object.
static
SFXBufferConstRef
EmptyInstance( Void )
Get an empty buffer.
Bool EndsWith( SFXBufferConstRef buffer )
EndsWith( Byte byte )
EndsWith( VoidConstPtr buffer , UInt32 size )
Check whether the buffer ends with the specified data or not.
Bool Equals( SFXBufferConstRef buffer )
Equals( VoidConstPtr buffer , UInt32 size )
Check whether the buffer equals the specified data or not.
Void Fill( Byte data )
Fill the buffer with the specified data.
SInt32 FirstIndexOf( SFXBufferConstRef buffer , SInt32 index = SINT32_MINIMUM )
FirstIndexOf( Byte byte , SInt32 index = SINT32_MINIMUM )
FirstIndexOf( VoidConstPtr buffer , UInt32 size , SInt32 index = SINT32_MINIMUM )
Get the first index of SFXBuffer object to match with the specified data, searching from the beginning.
Void Free( Void )
Release the buffer memory that the SFXBuffer object manages.
VoidPtr GetBuffer( Void )
Get a pointer to the buffer memory.
VoidConstPtr GetBuffer( Void )
Get a pointer to the buffer memory.
Byte GetByte( UInt32 index )
Get the Byte data at the specified index.
UInt16 GetCluster( Void )
Get the cluster size to increase or decrease the internal buffer memory.
UInt32 GetSize( Void )
Get the size of buffer memory.
UInt16 GetThreshold( Void )
Get the minimum size of internal buffer.
SFCError Insert( UInt32 index , SFXBufferConstRef buffer )
Insert( Byte byte )
Insert( UInt32 index , VoidConstPtr buffer , UInt32 size )
Insert data at the specified index of SFXBuffer object.
Bool IsEmpty( Void )
Check whether the buffer is empty or not.
SInt32 LastIndexOf( SFXBufferConstRef buffer , SInt32 index = SINT32_MAXIMUM )
LastIndexOf( Byte byte , SInt32 index = SINT32_MAXIMUM )
LastIndexOf( VoidConstPtr buffer , UInt32 size , SInt32 index = SINT32_MAXIMUM )
Get the last index of SFXBuffer object to match with the specified data, searching from the end.
SFCError Mul( SInt32 repeat )
Repeat the data of buffer with the specified frequency.
Void Remove( UInt32 begin , UInt32 end )
Remove data in the specified range.
SFCError Set( SFXBufferConstRef buffer )
Set( SFXWideStringConstRef string )
Set( SFXAnsiStringConstRef string )
Set( Byte byte )
Set( VoidConstPtr buffer , UInt32 size )
Set buffer by copying data.
SFCError SetByte( UInt32 index , Byte data )
Set the Byte data at the specified index.
Void SetCluster( UInt16 size )
Set the cluster size to increase or decrease the internal buffer memory.
SFCError SetSize( UInt32 size )
Set the size of buffer memory.
Void SetThreshold( UInt16 size )
Set the minimum size of internal buffer.
SFXBuffer Slice( UInt32 begin , UInt32 end )
Preserve data in the specified range and remove the other.
Bool StartsWith( SFXBufferConstRef buffer )
StartsWith( Byte byte )
StartsWith( VoidConstPtr buffer , UInt32 size )
Check whether the buffer starts with the specified data or not.
SFXBufferRef operator*=( SInt32 repeat )
Repeat the data of buffer with the specified frequency.
SFXBufferRef operator+=( SFXBufferConstRef buffer )
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 )
operator+( SFXBufferConstRef left , Byte right )
Add the specified data onto the end of buffer.
Types
DefaultEnum
Default values of minimun heap size and cluster size used inside the buffer.
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 )
operator+( SFXBufferConstRef left , Byte right )
Add the specified data onto the end of buffer.

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

Description

Construct the SFXBuffer object by copying the specified data. To get data without copying, use the Attach function.

When no arugument is specified or arguments are "threshold" and "cluster", internal buffer is not allocated. And it is necessary to call the Allocate function.

When an argument is specified as the SFXAnsiString object, the buffer length equals "the string length + 1( '\0' ) ". In case of SFXWideString, the buffer length equals "the string length * 2 + 1".

Reference

SFXBuffer::Allocate | SFXBuffer::Attach | SFXBuffer::AttachSFXAnsiString SFXBuffer::Set


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

Description

When buffer memory is allocated, it will be released automatically by calling the SFXBuffer::Free function.

Reference

SFXBuffer::Free


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

Return value

  • Success : SFERR_NO_ERROR
  • If insufficient memory : SFERR_NO_MEMORY

Description

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

The SFXBuffer::Add function enlarges the internal buffer.

Reference

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


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

Return value

  • Success : SFERR_NO_ERROR
  • If insufficient memory : SFERR_NO_MEMOERY

Description

If buffer memory is not allocated in the constructor, it is necessary to allocate buffer memory by using the SFXBuffer::Allocate function. The behaviour is not defined when calling other functions without allocation.

[Caution] Note

The SFXBuffer::Allocate function destroys data in the area to allocate memory. Even if errors occur inside the SFXBuffer::Allocate function, the former data cannot be restored.

Reference

SFXBuffer::SFXBuffer | SFXBuffer::Free


SFXBuffer::Attach
Delegate the control privilege of the specified Void data to the SFXBuffer object.
[ public ]
SFCError Attach(
    VoidPtr buffer   // memory block to use
    UInt32 size      // size of memory block
);

Return value

  • Success : SFERR_NO_ERROR
  • If failed : SFERR_INVALID_PARAM

Description

The SFXBuffer::Attach function is more efficient than the SFXBuffer::Set function, since the Void data(buffer) is not copied and the problem on insufficient memory or performance deterioration can be avoided.

The memory the allocated to Void data(buffer) will be released automatically when the SFXBuffer is released. To release the memory allocated to the Void data(buffer) explicitly, it is necessary to call the SFXBuffer::Detach function.

Example

Delegate the control privilege of AChar string to the SFXBuffer object.

SFXBuffer buffer;
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 SFXBuffer object(buffer)
buffer.Attach(ptr, 10240);
// hereafter, the AChar string(ptr) will be handled as the SFXBuffer object(buffer)

・・・

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

Reference

SFXBuffer::AttachSFXAnsiString | SFXBuffer::AttachSFXWideString | SFXBuffer::Detach


SFXBuffer::AttachSFXAnsiString
Delegate the control privilege of the specified SFXAnsiString object to the SFXBuffer object.
[ public ]
SFCError AttachSFXAnsiString(
    SFXAnsiStringPtr string   // string to use
);

Return value

  • Success : SFERR_NO_ERROR
  • If failed : SFERR_INVALID_PARAM

Description

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

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

Example

SFXAnsiString str;
SFXBuffer buffer;

...

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

...

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

Reference

SFXBuffer::Attach | SFXBuffer::AttachSFXWideString | SFXAnsiString::AttachSFXBuffer | SFXBuffer::Detach | SFXBuffer::DetachSFXAnsiString | SFXAnsiString::DetachSFXBuffer


SFXBuffer::AttachSFXWideString
Delegate the control privilege of the specified SFXWideString object to the SFXBuffer object.
[ public ]
SFCError AttachSFXWideString(
    SFXWideStringPtr string   // string to use
);

Return value

  • Success : SFERR_NO_ERROR
  • If failed : SFERR_INVALID_PARAM

Description

The SFXBuffer::AttachSFXWideString function is more efficient than the SFXBuffer::Set function, since the SFXWideString object(string) is not copied and the problem on insufficient memory or performance deterioration can be avoided.

The memory the allocated to SFXWideString object(string) will be released automatically when the SFXBuffer is released. To release the memory allocated to the SFXWideString object(string) explicitly, it is necessary to call the SFXBuffer::DetachSFXWideString function.

Example

SFXWideString str;
SFXBuffer buffer;

...

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

...

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

Reference

SFXBuffer::Attach | SFXBuffer::AttachSFXAnsiString | SFXWideString::AttachSFXBuffer | SFXBuffer::Detach | SFXBuffer::DetachSFXWideString SFXWideString::DetachSFXBuffer


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

Return value

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

Reference

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


SFXBuffer::Copy
Overwrite the buffer 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 memory block to copy
);

Return value

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

Description

If data to overwrite goes over the end of buffer, SFERR_INVALID_PARAM is returned and data is not copied.


SFXBuffer::Detach
Delegate the control privilege of SFXBuffer object to the specified Void data.
[ public ]
VoidPtr Detach(
    UInt32Ptr size = null   // data size
);

Return value

Return the Void data which the SFXBuffer object has.

Description

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

Example

SFXBuffer buffer;
VoidPtr ptr;
UInt32 length;

...

// delegate the control privilege of SFXBuffer object(buffer) to the Void data(ptr)
ptr = buffer.Detach(&length);
// hereafter, the SFXBuffer object(buffer) will be operated as the Void data(ptr)

...

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

Reference

SFXBuffer::Attach | SFXBuffer::DetachSFXAnsiString | SFXBuffer::DetachSFXWideString


SFXBuffer::DetachSFXAnsiString
Delegate the control privilege of the specified SFXBuffer object to the SFXAnsiString object.
[ public ]
SFCError DetachSFXAnsiString(
    SFXAnsiStringPtr string   // pointer to the SFXAnsiString object
);

Return value

  • Success : SFERR_NO_ERROR
  • If failed : SFERR_INVALID_PARAM

Description

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

Example

SFXAnsiString str;
SFXBuffer buffer;

...

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

...

// after used, the allocated memory will be released automatically
MemoryFree(ptr);

Reference

SFXBuffer::Attach | SFXBuffer::AttachSFXAnsiString | SFXBuffer::Detach | SFXBuffer::DetachSFXWideString


SFXBuffer::DetachSFXWideString
Delegate the control privilege of the specified SFXBuffer object to the SFXWideString object.
[ public ]
SFCError DetachSFXWideString(
    SFXWideStringPtr string   // pointer to the SFXWideString object
);

Return value

  • Success : SFERR_NO_ERROR
  • If failed : SFERR_INVALID_PARAM

Description

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

Example

SFXWideString str;
SFXBuffer buffer;

...

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

...

// after used, the allocated memory will be released automatically
MemoryFree(ptr);

Reference

SFXBuffer::Attach | SFXBuffer::AttachSFXWideString | SFXBuffer::Detach | SFXBuffer::DetachSFXAnsiString


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

Description

Get an instance that represents an empty buffer.


SFXBuffer::EndsWith
Check whether the buffer ends with the specified data or not.
[ 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 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

Reference

SFXBuffer::StartsWith


SFXBuffer::Equals
Check whether the buffer equals the specified data or not.
[ 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 buffer data to compare with
);

Return value

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

Reference

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


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

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

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

SFXBuffer::LastIndexOf


SFXBuffer::Free
Release the buffer memory that the SFXBuffer object manages.
[ public ]
Void Free(Void);

Description

If the SFXBuffer object has no buffer memory, nothing happens.

Reference

SFXBuffer::Allocate


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

Description

By using the SFXBuffer::GetBuffer function, the buffer memory can be operated directly.

Example

SFXBuffer buffer;

buffer.Set(SFXAnsiString("test"));   // set a buffer
TRACE("%s", buffer.GetBuffer());     // test

Reference

SFXBuffer::GetByte | SFXBuffer::GetSize | SFXBuffer::SetByte | SFXBuffer::SetSize


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

Reference

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


SFXBuffer::GetCluster
Get the cluster size to increase or decrease the internal buffer memory.
[ public, const ]
UInt16 GetCluster(Void);

Reference

SFXBuffer::SetCluster


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

Example

SFXBuffer buffer;

buffer.Set(SFXAnsiString("test"));   // set buffer
TRACE("%s", buffer.GetSize());       // 5( test + \0 )

Reference

SFXBuffer::GetBuffer | SFXBuffer::GetByte | SFXBuffer::SetByte | SFXBuffer::SetSize


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

Reference

SFXBuffer::SetThreshold


SFXBuffer::Insert
Insert data at the specified index of SFXBuffer object.
[ 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 buffer data to insert
);
[ public ]
SFCError Insert(
    Byte byte   // Byte data to insert
);

Return value

  • Success : SFERR_NO_ERROR
  • If insufficient memory : SFERR_NO_MEMOERY

Description

The SFXBuffer::Insert function enlarges the internal buffer with the buffer size specified as an argument.

Reference

SFXBuffer::Remove


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

Return value

  • If empty : true
  • Otherwise : false

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

Return value

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

Description

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

Reference

SFXBuffer::FirstIndexOf


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

Return value

  • Success : SFERR_NO_ERROR
  • If insufficient memory : SFERR_NO_MEMOERY

Description

The SFXBuffer::Mul function will influence upon the SFXBuffer object. To preserve the current data, it is necessary to copy it somewhere or use the operator* operator.

Reference

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


SFXBuffer::Remove
Remove data in the specified range.
[ public ]
Void Remove(
    UInt32 begin   // beginning index
    UInt32 end     // end index
);

Description

The SFXBuffer::Remove function shrinks the internal buffer.

Reference

SFXBuffer::Insert


SFXBuffer::Set
Set buffer by copying data.
[ public ]
SFCError Set(
    SFXBufferConstRef buffer   // buffer object to copy
);
[ public ]
SFCError Set(
    VoidConstPtr buffer   // buffer data to copy
    UInt32 size           // size of buffer 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

  • Success : SFERR_NO_ERROR
  • If insufficient memory : SFERR_NO_MEMORY

Description

Construct buffer by copying data specified as an argument. The former buffer will be destroyed. To set buffer by not copying data, use the SFXBuffer::Attachfunction.

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

Reference

SFXBuffer::Attach | SFXBuffer::AttachSFXAnsiString


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

Return value

  • Success : SFERR_NO_ERROR
  • If failed : SFERR_INVALID_PARAM

Reference

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


SFXBuffer::SetCluster
Set the cluster size to increase or decrease the internal buffer memory.
[ public ]
Void SetCluster(
    UInt16 size   // cluster size to set
);

Description

Set the minimum size when allocating memory.

Reference

SFXBuffer::GetCluster


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

Return value

  • Success : SFERR_NO_ERROR
  • If insufficient memory : SFERR_NO_MEMORY

Reference

SFXBuffer::GetBuffer | SFXBuffer::GetByte | SFXBuffer::GetSize | SFXBuffer::SetByte


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

Reference

SFXBuffer::GetThreshold


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

Description

The SFXBuffer::Slice function will influence upon the SFXBuffer object. To preserve the current data, it is necessary to copy it somewhere.

Preserve data between "begin" and "end" parameter specified, and remove the other.

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

Example

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

SFXBuffer::StartsWith
Check whether the buffer starts with the specified data or not.
[ 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 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
Default values of minimun heap size and cluster size used inside the buffer.
enum DefaultEnum {
    DEFAULT_THRESHOLD           = 16,     // default value of minimum heap size
    DEFAULT_CLUSTER             = 8       // default value of cluster size
};

Reference

SFXBuffer::GetCluster | SFXBuffer::GetThreshold | SFXBuffer::SetCluster | SFXBuffer::SetThreshold