Foxit PDF SDK

Public Member Functions | Public Attributes | List of all members
CFX_BinaryBuf Class Reference
FXCRT

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

Inheritance diagram for CFX_BinaryBuf:

## 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_Allocator * | m_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] | pAllocator | An 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] | size | The size of buffer.
  [in] | pAllocator | An 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] | pBuf | A pointer to a binary buffer block.
  [in] | size | The 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] | byte | A 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] | byte | The input byte.
  [in] | count | Number 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] | str | A 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] | pBuf | A pointer to a binary buffer.
  [in] | size | The 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] | pBuf | A pointer to a binary buffer.
  [in] | size | The 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_index | Specifies the zero-based index of the start position to be deleted in the binary buffer.
  [in] | count | Specifies 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] | size | The new size expected.
  [in] | alloc_step | The 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] | str | Receives 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] | pos | Specifies the zero-based index of the position in the binary buffer.
  [in] | pBuf | A pointer to a binary buffer block.
  [in] | size | The 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] | other | A ref to CFX_BinaryBuf object.

Returns
  None.