SophiaFramework UNIVERSE 5.3 |
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.
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.
|
[ 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 );
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')".
SFXBuffer::Allocate | SFXBuffer::SetSize | SFXBuffer::Attach | SFXBuffer::Set
[ public ] ~SFXBuffer(Void);
This destructor will call the SFXBuffer::Free function to release the internal buffer memory 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 );
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 | |
---|---|
This function will influence upon this buffer. To preserve the former data of this buffer, it is necessary to copy it somewhere. |
SFXBuffer::Mul | SFXBuffer::operator<< | operator+ | SFXBuffer::operator+=
This function allocates the specified size of memory to this buffer.
Note | |
---|---|
The buffer memory can be allocated with the SFXBuffer::Set function, the SFXBuffer::SetSize function, or the SFXBuffer::SFXBuffer constructor. |
Note | |
---|---|
The behaviours of some functions are not defined when they are called without the internal buffer memory being allocated. |
Note | |
---|---|
The data which this buffer contains before this function is executed will be destroyed. |
SFXBuffer::Free | SFXBuffer::SetSize | SFXBuffer::Set | SFXBuffer::SFXBuffer
[ 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 );
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 | |
---|---|
When this buffer object is released, the specified data area will be released automatically together with this buffer object. |
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
[ public ] SFCError AttachSFXAnsiString( SFXAnsiStringPtr string // pointer to the string to be attached to this buffer object );
Caution | |
---|---|
Since this function will be deprecated in SophiaFramework UNIVERSE 6.0 or above, use the SFXBuffer::Attach function instead. |
[ public ] SFCError AttachSFXWideString( SFXWideStringPtr string // string to use );
Caution | |
---|---|
Since this function will be deprecated in SophiaFramework UNIVERSE 6.0 or above, use the SFXBuffer::Attach function instead. |
[ 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 );
This function compares this buffer with the specified data.
SFXBuffer::Equals | operator== | operator!= | operator> | operator>= | operator< | operator<=
[ 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 );
This function overwrites the memory area of this buffer starting from the specified index with the specified data.
Caution | |
---|---|
If data to overwrite goes over the end of this buffer, SFERR_INVALID_PARAM will be returned and data will not be copied. |
[ 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 the Void data which the SFXBuffer object has.
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 | |
---|---|
The buffer data will not be copied. |
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);
[ public ] SFCError DetachSFXAnsiString( SFXAnsiStringPtr string // pointer to the detached string object );
Caution | |
---|---|
Since this function will be deprecated in SophiaFramework UNIVERSE 6.0 or above, use the SFXBuffer::Detach function instead. |
[ public ] SFCError DetachSFXWideString( SFXWideStringPtr string // pointer to the detached string object );
Caution | |
---|---|
Since this function will be deprecated in SophiaFramework UNIVERSE 6.0 or above, use the SFXBuffer::Detach function instead. |
[ public, static ] SFXBufferConstRef EmptyInstance(Void);
This function gets the empty instance of the SFXBuffer class that represents an empty buffer.
[ 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 );
This function checks whether or not this buffer ends with 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 );
This function checks whether or not this buffer equals the specified data.
This function fills this buffer with the specified data.
[ 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 );
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.)
[ public ] Void Free(Void);
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 | |
---|---|
This function will be called in the SFXBuffer::~SFXBuffer destructor. |
Note | |
---|---|
If no buffer memory is allocated to this buffer, nothing will happen. |
SFXBuffer::Allocate | SFXBuffer::SetSize | SFXBuffer::Set | SFXBuffer::SFXBuffer | SFXBuffer::~SFXBuffer
[ public ] VoidPtr GetBuffer(Void);
[ public, const ] VoidConstPtr GetBuffer(Void);
Pointer to the internal buffer memory of this buffer
This function gets the pointer to the internal buffer memory of this buffer.
Note | |
---|---|
The buffer memory of the SFXBuffer class can be accessed directly through the pointer gotten with this function. |
SFXBuffer buffer; buffer.Set(SFXAnsiString("test")); // set the buffer TRACE("%s", buffer.GetBuffer()); // "test" will be displayed on BREW output window
Byte data at the specified index of this buffer
This function gets the byte data at the specified index of this buffer.
SFXBuffer::GetBuffer | SFXBuffer::GetSize | SFXBuffer::SetByte | SFXBuffer::SetSize | SFXBuffer::operator[]
[ public, const ] UInt16 GetCluster(Void);
Minimum unit to allocate the internal buffer memory(SFXClusterHeap). [in bytes]
This function gets the minimum unit to allocate the internal buffer memory(SFXClusterHeap). [in bytes]
Note | |
---|---|
This function calls the SFXClusterHeap::GetCluster function of the SFXClusterHeap class which the SFXBuffer class manages internally. |
SFXBuffer::SetCluster | SFXClusterHeap::GetCluster | SFXClusterHeap
[ public, const ] UInt32 GetSize(Void);
Size of this buffer
This function gets the size of this buffer.
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
[ public, const ] UInt16 GetThreshold(Void);
Minimum memory of the internal buffer memory(SFXClusterHeap). [in bytes]
This function gets the minimum memory of the internal buffer memory(SFXClusterHeap). [in bytes]
Note | |
---|---|
This function calls the SFXClusterHeap::GetThreshold function of the SFXClusterHeap class which the SFXBuffer class manages internally. |
[ 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 );
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 | |
---|---|
This function will influence upon this buffer. To preserve the former data of this buffer, it is necessary to copy it somewhere. |
[ public, const ] Bool IsEmpty(Void);
This function checks whether or not this buffer is empty.
[ 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 );
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.)
This function extends this buffer by repeating the data of this buffer with the specified frequency.
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. |
[ public ] Void Remove( UInt32 begin // beginning index(this index is included) UInt32 end // ending index(this index is not included) );
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 | |
---|---|
This function will influence upon this buffer. To preserve the former data of this buffer, it is necessary to copy it somewhere. |
[ 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 );
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 | |
---|---|
The buffer memory to copy the specified data will be automatically allocated. |
SFXBuffer::Attach | SFXBuffer::Allocate | SFXBuffer::SFXBuffer
This function sets the specified byte data at the specified index of this buffer.
SFXBuffer::GetBuffer | SFXBuffer::GetByte | SFXBuffer::GetSize | SFXBuffer::SetSize | SFXBuffer::operator[]
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 | |
---|---|
This function calls the SFXClusterHeap::SetCluster function of the SFXClusterHeap class which the SFXBuffer class manages internally. |
SFXBuffer::GetCluster | SFXBuffer::DefaultEnum | SFXClusterHeap::SetCluster | SFXClusterHeap
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 | |
---|---|
|
SFXBuffer buffer;
buffer.SetSize(0x200); // set the buffer size to 0x200 bytes
SFXBuffer::GetSize | SFXBuffer::SetCluster | SFXBuffer::SetThreshold | SFXBuffer::GetBuffer | SFXBuffer::Allocate | SFXClusterHeap::Resize
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 | |
---|---|
This function calls the SFXClusterHeap::SetThreshold function of the SFXClusterHeap class which the SFXBuffer class manages internally. |
SFXBuffer::GetThreshold | SFXBuffer::DefaultEnum | SFXClusterHeap::SetThreshold | SFXClusterHeap
[ public ] Void Slice( UInt32 begin // beginning index of buffer to preserve UInt32 end // ending index of buffer to preserve );
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 | |
---|---|
The content of this buffer will be changed after this operation. To preserve it, it is necessary to copy it somewhere. |
SFXAnsiString s("abracadabra"); SFXBuffer buf1(s); // buf1 is copied with null buf1.Slice(2, 9); // buf1 = "racadab"
[ 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 );
[ public ] SFXBufferRef operator=( SFXBufferConstRef buffer // buffer object to copy );
[ public, friend ] Bool operator==( SFXBufferConstRef left // SFXBuffer object to compare with SFXBufferConstRef right // SFXBuffer object to compare with );
[ public, friend ] Bool operator>=( SFXBufferConstRef left // SFXBuffer object to compare with SFXBufferConstRef right // SFXBuffer object to compare with );
[ public, friend ] Bool operator>( SFXBufferConstRef left // SFXBuffer object to compare with SFXBufferConstRef right // SFXBuffer object to compare with );
[ public ] ByteRef operator[]( UInt32 index // index of buffer data to get );
[ public, const ] ByteConstRef operator[]( UInt32 index // index of buffer data to get );
[ public, friend ] SFXBufferRef operator<<( SFXBufferRef left // SFXBuffer object to be added SFXBufferConstRef right // SFXBuffer object to add );
The Soperator<< will influence upon the SFXBuffer object. To preserve the former buffer data, it is necessary to copy it somewhere.
[ public, friend ] Bool operator<=( SFXBufferConstRef left // SFXBuffer object to compare with SFXBufferConstRef right // SFXBuffer object to compare with );
[ public, friend ] Bool operator<( SFXBufferConstRef left // SFXBuffer object to compare with SFXBufferConstRef right // SFXBuffer object to compare with );
[ public ] SFXBufferRef operator*=( SInt32 repeat // frequency to repeat );
[ public, friend ] SFXBuffer operator*( SFXBufferConstRef left // SFXBuffer object to repeat SInt32 right // frequency to repeat );
[ public, friend ] Bool operator!=( SFXBufferConstRef left // SFXBuffer object to compare with SFXBufferConstRef right // SFXBuffer object to compare with );
[ public ] SFXBufferRef operator+=( SFXBufferConstRef buffer // SFXBuffer object to add );
[ public ] SFXBufferRef operator+=( Byte byte // Byte data to add );
[ 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 );
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] };
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]
SFXBuffer::SetCluster | SFXBuffer::SetThreshold | SFXClusterHeap
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |