Foxit PDF Conversion SDK
CFX_BinaryBuf Class Reference

Dynamic binary buffers designed for more efficient appending. More...

Inheritance diagram for CFX_BinaryBuf:
CFX_ByteTextBuf CFX_WideTextBuf

Public Member Functions

 CFX_BinaryBuf (IFX_Allocator *pAllocator=0)
 A default constructor creating an empty buffer. More...
 
 CFX_BinaryBuf (FX_STRSIZE size, IFX_Allocator *pAllocator=0)
 A default constructor creating an empty buffer. More...
 
 ~CFX_BinaryBuf ()
 The destructor.
 
FX_BOOL AppendBlock (const void *pBuf, FX_STRSIZE size)
 Append a binary buffer block. More...
 
FX_BOOL AppendByte (FX_BYTE byte)
 Append a single byte. More...
 
FX_BOOL AppendFill (FX_BYTE byte, FX_STRSIZE count)
 Append a byte for specified number times. Not a byte-by-byte processing, but a byte filling processing internally. More...
 
void AppendString (FX_BSTR str)
 Append a non-buffered byte string. More...
 
void AttachData (void *pBuf, FX_STRSIZE size)
 Attach to a buffer (this buffer will belong to this object). The buffer must be allocated by FX_Alloc. More...
 
void Clear ()
 Set the binary buffer to be empty. More...
 
FX_BOOL CopyData (const void *pBuf, FX_STRSIZE size)
 Copy from another buffer. More...
 
void Delete (int start_index, int count)
 Delete a inter-zone buffer defining by parameters start_index and count in the binary buffer. More...
 
void DetachBuffer ()
 Detach the buffer. Just set buffer pointer to NULL, and set the binary buffer size to zero. More...
 
FX_BOOL EstimateSize (FX_STRSIZE size, FX_STRSIZE alloc_step=0)
 Change the allocated buffer size, and set the allocation step if alloc_step is non-zero. More...
 
FX_LPBYTE GetBuffer () const
 Get a byte pointer to the binary buffer. More...
 
CFX_ByteStringC GetByteString () const
 Get a byte string from the buffer. More...
 
void GetByteStringL (CFX_ByteStringL &str) const
 Get a byte string from current buffer object. More...
 
FX_STRSIZE GetSize () const
 Get the length of the binary buffer. More...
 
FX_BOOL InsertBlock (FX_STRSIZE pos, const void *pBuf, FX_STRSIZE size)
 Insert a binary buffer block at the specified position. More...
 
void TakeOver (CFX_BinaryBuf &other)
 Takeover another buffer. More...
 

Public Attributes

IFX_Allocatorm_pAllocator
 Special allocator pointer. NULL means to use default allocator.
 

Detailed Description

Dynamic binary buffers designed for more efficient appending.

Constructor & Destructor Documentation

◆ CFX_BinaryBuf() [1/2]

CFX_BinaryBuf::CFX_BinaryBuf ( IFX_Allocator pAllocator = 0)

A default constructor creating an empty buffer.

Parameters
[in]pAllocatorAn allocator. Default value: NULL.

◆ CFX_BinaryBuf() [2/2]

CFX_BinaryBuf::CFX_BinaryBuf ( FX_STRSIZE  size,
IFX_Allocator pAllocator = 0 
)

A default constructor creating an empty buffer.

Parameters
[in]sizeThe size of buffer.
[in]pAllocatorAn allocator. Default value: NULL.

Member Function Documentation

◆ AppendBlock()

FX_BOOL CFX_BinaryBuf::AppendBlock ( const void *  pBuf,
FX_STRSIZE  size 
)

Append a binary buffer block.

Parameters
[in]pBufA pointer to a binary buffer block.
[in]sizeThe size in bytes of the buffer block.
Returns
true means success, while false means failure.

◆ AppendByte()

FX_BOOL CFX_BinaryBuf::AppendByte ( FX_BYTE  byte)
inline

Append a single byte.

Parameters
[in]byteA single byte.
Returns
true means success, while false means failure.

◆ AppendFill()

FX_BOOL CFX_BinaryBuf::AppendFill ( FX_BYTE  byte,
FX_STRSIZE  count 
)

Append a byte for specified number times. Not a byte-by-byte processing, but a byte filling processing internally.

Parameters
[in]byteThe input byte.
[in]countNumber of times.
Returns
true means success, while false means failure.

◆ AppendString()

void CFX_BinaryBuf::AppendString ( FX_BSTR  str)
inline

Append a non-buffered byte string.

Parameters
[in]strA no-buffered byte string.
Returns
None.

◆ AttachData()

void CFX_BinaryBuf::AttachData ( void *  pBuf,
FX_STRSIZE  size 
)

Attach to a buffer (this buffer will belong to this object). The buffer must be allocated by FX_Alloc.

Parameters
[in]pBufA pointer to a binary buffer.
[in]sizeThe size in bytes of the buffer.
Returns
None.

◆ Clear()

void CFX_BinaryBuf::Clear ( )

Set the binary buffer to be empty.

Returns
None.

◆ CopyData()

FX_BOOL CFX_BinaryBuf::CopyData ( const void *  pBuf,
FX_STRSIZE  size 
)

Copy from another buffer.

Parameters
[in]pBufA pointer to a binary buffer.
[in]sizeThe size in bytes of the input buffer.
Returns
true means success, while false means failure.

◆ Delete()

void CFX_BinaryBuf::Delete ( int  start_index,
int  count 
)

Delete a inter-zone buffer defining by parameters start_index and count in the binary buffer.

Parameters
[in]start_indexSpecifies the zero-based index of the start position to be deleted in the binary buffer.
[in]countSpecifies the length in bytes to be deleted.
Returns
None.

◆ DetachBuffer()

void CFX_BinaryBuf::DetachBuffer ( )

Detach the buffer. Just set buffer pointer to NULL, and set the binary buffer size to zero.

Returns
None.

◆ EstimateSize()

FX_BOOL CFX_BinaryBuf::EstimateSize ( FX_STRSIZE  size,
FX_STRSIZE  alloc_step = 0 
)

Change the allocated buffer size, and set the allocation step if alloc_step is non-zero.

Parameters
[in]sizeThe new size expected.
[in]alloc_stepThe new allocation step. If alloc_step is 0, then the allocation step will not change. Default value: 0.
Returns
true means success, while false means failure.

◆ GetBuffer()

FX_LPBYTE CFX_BinaryBuf::GetBuffer ( ) const
inline

Get a byte pointer to the binary buffer.

Returns
A byte pointer to the binary buffer.

◆ GetByteString()

CFX_ByteStringC CFX_BinaryBuf::GetByteString ( ) const

Get a byte string from the buffer.

Returns
A byte string.

◆ GetByteStringL()

void CFX_BinaryBuf::GetByteStringL ( CFX_ByteStringL &  str) const

Get a byte string from current buffer object.

Parameters
[out]strReceives the byte string from current buffer object.
Returns
None,

◆ GetSize()

FX_STRSIZE CFX_BinaryBuf::GetSize ( ) const
inline

Get the length of the binary buffer.

Returns
The length in bytes of the binary buffer.

◆ InsertBlock()

FX_BOOL CFX_BinaryBuf::InsertBlock ( FX_STRSIZE  pos,
const void *  pBuf,
FX_STRSIZE  size 
)

Insert a binary buffer block at the specified position.

Parameters
[in]posSpecifies the zero-based index of the position in the binary buffer.
[in]pBufA pointer to a binary buffer block.
[in]sizeThe size in bytes of the buffer block.
Returns
true means success, while false means failure.

◆ TakeOver()

void CFX_BinaryBuf::TakeOver ( CFX_BinaryBuf other)

Takeover another buffer.

This function attaches to the source CFX_BinaryBuf object's buffer. The source CFX_BinaryBuf object has detached the buffer.

Parameters
[in]otherA ref to CFX_BinaryBuf object.
Returns
None.