The C++ framework for developing highly scalable, high performance servers on Windows platforms.

CBufferChain Class Reference
[I/O BuffersAsynchronous I/O]

Inheritance diagram for CBufferChain:
Collaboration diagram for CBufferChain:

List of all members.

Public Types

typedef ULONG_PTR UserData

Public Member Functions

 CBufferChain (JetByteTools::Core::IIndexedOpaqueUserData::UserDataIndex nextBufferIndex=UseDefaultUserDataIndex)
 CBufferChain (CSmartBuffer &buffer, JetByteTools::Core::IIndexedOpaqueUserData::UserDataIndex nextBufferIndex=UseDefaultUserDataIndex)
 CBufferChain (IAllocateBuffer &bufferAllocator, const BYTE *pData, DWORD dataLength, JetByteTools::Core::IIndexedOpaqueUserData::UserDataIndex nextBufferIndex=UseDefaultUserDataIndex)
 CBufferChain (CBufferChain &&rhs) noexcept
 CBufferChain (const CBufferChain &rhs)
 ~CBufferChain () override
CBufferChainoperator= (const CBufferChain &rhs)
CBufferChainoperator= (CBufferChain &&rhs) noexcept
CSmartBuffer RemoveAsSingleBuffer ()
 Returns the entire content of the buffers in the chain as a single buffer. If only one buffer is present in the chain then it is returned, if more than one buffer is present then a custom sized buffer is allocated that will hold all of the data. No attempt is made to consolidate the data into the first buffer.
bool CopyData (BYTE *pDestinationBuffer, size_t bufferSize, size_t &bufferSizeUsed)
 Copies up to bufferSize bytes of the buffer chain into the supplied buffer and returns true if all the data in the chain was copied and false if only part of the chain was copied. Returns the number of bytes copied in bufferSizeUsed.
void Swap (CBufferChain &rhs)
 Swaps the current chain with 'rhs'.
void Attach (IBuffer *pChain)
 Attaches pBuffer to an empty chain. The supplied buffer can be a single buffer or a chain of buffers. The chain takes ownership of the supplied buffer's existing reference.
void Attach (CSmartBuffer &buffer)
 Attaches buffer to an empty chain. The supplied buffer can be a single buffer or a chain of buffers. The chain takes ownership of the supplied buffer and extracts it from the smart buffer.
void Splice (CBufferChain &buffers)
 Splices the supplied buffer chain, buffers, to the end of this chain.
void Splice (IBuffer *pBuffer)
 Splices pBuffer to the end of a chain. The chain may be empty. The supplied buffer can be a single buffer or a chain of buffers. The chain takes ownership of the supplied buffers' existing references.
void Splice (CSmartBuffer &buffer)
 Splices buffer to the end of a chain. The chain may be empty. The supplied buffer can be a single buffer or a chain of buffers. The chain takes ownership of the supplied buffer and extracts it from the smart buffer.
bool CanStoreNulls () const override
bool IsEmpty () const override
size_t Size () const override
size_t TotalBytes () const override
size_t AvailableSpace () const override
bool HasAvailableSpace () const override
void GetTotalBytesAndAvailableSpace (size_t &totalBytes, size_t &availableSpace) const override
size_t Purge () override
size_t Purge (IBufferChain::IHandlePurgedBufferRelease &purgeHandler, UserData userData) override
void Add (CSmartBuffer &buffer) override
void AddToFront (CSmartBuffer &buffer) override
CSmartBuffer GetNext (CSmartBuffer &buffer) override
CSmartBuffer GetNext () override
const IBuffer * PeekHead () const override
const IBuffer * PeekNext (const IBuffer *pBuffer) const override
IBuffer * PeekHead () override
IBuffer * PeekNext (const IBuffer *pBuffer) override
const IBuffer * PeekTail () const override
IBuffer * PeekTail () override
IBuffer * Detach () override
CSmartBuffer GetTail ()
 Removes the last buffer from the chain and returns it.
bool ConsolidateDataIntoChain (CSmartBuffer &buffer)
 Adds the contents of the supplied buffer to an existing chain by first filling the last buffer in the chain with as much of the new data as possible and then attaching the supplied buffer to the end of the chain if necessary. Returns true if the buffer is consumed.
void ConsolidateDataIntoChain (CBufferChain &buffers)
 Adds the contents of the supplied buffer chain to an existing chain. Examines the end of the target chain and the start of the source chain to determine if we should simply splice the chains together or consolidate the buffers in the source chain into the target chain.
void AddData (const BYTE *pData, DWORD dataLength)
 Adds the supplied data to an existing chain and extends the chain if necessary by allocating buffers from the tail buffer of the existing chain. Throws an exception if the chain is empty.
void AddData (IAllocateBuffer &bufferAllocator, const BYTE *pData, DWORD dataLength)
 Adds the supplied data to a chain and extends the chain if necessary by allocating buffers from the supplied allocator. The existing chain can be empty.
void GetData (BYTE *pData, DWORD dataLength)
 TODO - Remove data? return amount removed? similar functionality to CopyData...
void GetData (IPoolBuffers &pool, BYTE *pData, DWORD dataLength)
CBufferChain DuplicateBufferChain () const
 Makes a deep copy of the data in the buffer chain and returns a new chain. Buffers used to create the new chain are allocated from the head buffer of the source chain. Data will be consolidated into the new chain's buffers and use the minimum number of buffers.
virtual size_t Purge (IHandlePurgedBufferRelease &purgeHandler, UserData userData)=0
virtual bool TryAdd (CSmartBuffer &buffer)
virtual CSmartBuffer TryGetNext (CSmartBuffer &buffer, bool &inserted)

Static Public Member Functions

static void CopyBufferChain (const CBufferChain &originalBuffers, CBufferChain &buffers, IAllocateBufferHandles &allocator)
static size_t CopyChainIntoBuffer (const CBufferChain &originalBuffers, BYTE *pDestination, size_t destinationSize)
static void CopyDataIntoChain (const BYTE *pData, size_t dataLength, CBufferChain &chain)
static void CopyDataIntoChain (const JetByteTools::Core::Data data[], size_t numEntries, CBufferChain &chain)
static bool ConsoliateData (CBufferChain &buffers, CBufferChain &emptyBuffers, DWORD percentageUnusedSpaceRequired=10)

Static Public Attributes

static const
JetByteTools::Core::IIndexedOpaqueUserData::UserDataIndex 
UseDefaultUserDataIndex = static_cast<JetByteTools::Core::IIndexedOpaqueUserData::UserDataIndex>(-1)

Static Protected Member Functions

static
JetByteTools::Core::IIndexedOpaqueUserData::UserDataIndex 
GetNextBufferIndex (JetByteTools::Core::IIndexedOpaqueUserData::UserDataIndex nextBufferIndex)


Member Typedef Documentation

typedef ULONG_PTR UserData [inherited]


Constructor & Destructor Documentation

CBufferChain ( IAllocateBuffer bufferAllocator,
const BYTE pData,
DWORD  dataLength,
JetByteTools::Core::IIndexedOpaqueUserData::UserDataIndex  nextBufferIndex = UseDefaultUserDataIndex 
)

CBufferChain ( CBufferChain &&  rhs  ) 

CBufferChain ( const CBufferChain rhs  ) 

~CBufferChain (  )  [override]


Member Function Documentation

CBufferChain& operator= ( const CBufferChain rhs  ) 

CBufferChain & operator= ( CBufferChain &&  rhs  ) 

void CopyBufferChain ( const CBufferChain originalBuffers,
CBufferChain buffers,
IAllocateBufferHandles allocator 
) [static]

size_t CopyChainIntoBuffer ( const CBufferChain originalBuffers,
BYTE pDestination,
size_t  destinationSize 
) [static]

void CopyDataIntoChain ( const BYTE pData,
size_t  dataLength,
CBufferChain chain 
) [static]

void CopyDataIntoChain ( const JetByteTools::Core::Data  data[],
size_t  numEntries,
CBufferChain chain 
) [static]

bool ConsoliateData ( CBufferChain buffers,
CBufferChain emptyBuffers,
DWORD  percentageUnusedSpaceRequired = 10 
) [static]

CSmartBuffer RemoveAsSingleBuffer (  ) 

Returns the entire content of the buffers in the chain as a single buffer. If only one buffer is present in the chain then it is returned, if more than one buffer is present then a custom sized buffer is allocated that will hold all of the data. No attempt is made to consolidate the data into the first buffer.

bool CopyData ( BYTE pDestinationBuffer,
size_t  bufferSize,
size_t &  bufferSizeUsed 
)

Copies up to bufferSize bytes of the buffer chain into the supplied buffer and returns true if all the data in the chain was copied and false if only part of the chain was copied. Returns the number of bytes copied in bufferSizeUsed.

void Swap ( CBufferChain rhs  ) 

Swaps the current chain with 'rhs'.

void Attach ( IBuffer *  pChain  ) 

Attaches pBuffer to an empty chain. The supplied buffer can be a single buffer or a chain of buffers. The chain takes ownership of the supplied buffer's existing reference.

void Attach ( CSmartBuffer buffer  ) 

Attaches buffer to an empty chain. The supplied buffer can be a single buffer or a chain of buffers. The chain takes ownership of the supplied buffer and extracts it from the smart buffer.

void Splice ( CBufferChain buffers  ) 

Splices the supplied buffer chain, buffers, to the end of this chain.

void Splice ( IBuffer *  pBuffer  ) 

Splices pBuffer to the end of a chain. The chain may be empty. The supplied buffer can be a single buffer or a chain of buffers. The chain takes ownership of the supplied buffers' existing references.

void Splice ( CSmartBuffer buffer  ) 

Splices buffer to the end of a chain. The chain may be empty. The supplied buffer can be a single buffer or a chain of buffers. The chain takes ownership of the supplied buffer and extracts it from the smart buffer.

bool CanStoreNulls (  )  const [inline, override, virtual]

Implements IBufferChain.

bool IsEmpty (  )  const [override, virtual]

size_t Size (  )  const [override, virtual]

size_t TotalBytes (  )  const [override, virtual]

size_t AvailableSpace (  )  const [override, virtual]

Implements IBufferChain.

bool HasAvailableSpace (  )  const [override, virtual]

Implements IBufferChain.

void GetTotalBytesAndAvailableSpace ( size_t &  totalBytes,
size_t &  availableSpace 
) const [override, virtual]

Implements IBufferChain.

size_t Purge (  )  [override, virtual]

size_t Purge ( IBufferChain::IHandlePurgedBufferRelease purgeHandler,
UserData  userData 
) [override]

void Add ( CSmartBuffer buffer  )  [override, virtual]

Implements IBufferChain.

void AddToFront ( CSmartBuffer buffer  )  [override, virtual]

Implements IUnsortedBufferChain.

CSmartBuffer GetNext ( CSmartBuffer buffer  )  [override, virtual]

Implements IBufferChain.

CSmartBuffer GetNext (  )  [override, virtual]

const IBuffer * PeekHead (  )  const [override, virtual]

const IBuffer * PeekNext ( const IBuffer *  pBuffer  )  const [override, virtual]

IBuffer * PeekHead (  )  [override, virtual]

IBuffer * PeekNext ( const IBuffer *  pBuffer  )  [override, virtual]

const IBuffer * PeekTail (  )  const [override, virtual]

IBuffer * PeekTail (  )  [override, virtual]

IBuffer * Detach (  )  [override, virtual]

CSmartBuffer GetTail (  ) 

Removes the last buffer from the chain and returns it.

bool ConsolidateDataIntoChain ( CSmartBuffer buffer  ) 

Adds the contents of the supplied buffer to an existing chain by first filling the last buffer in the chain with as much of the new data as possible and then attaching the supplied buffer to the end of the chain if necessary. Returns true if the buffer is consumed.

void ConsolidateDataIntoChain ( CBufferChain buffers  ) 

Adds the contents of the supplied buffer chain to an existing chain. Examines the end of the target chain and the start of the source chain to determine if we should simply splice the chains together or consolidate the buffers in the source chain into the target chain.

void AddData ( const BYTE pData,
DWORD  dataLength 
)

Adds the supplied data to an existing chain and extends the chain if necessary by allocating buffers from the tail buffer of the existing chain. Throws an exception if the chain is empty.

void AddData ( IAllocateBuffer bufferAllocator,
const BYTE pData,
DWORD  dataLength 
)

Adds the supplied data to a chain and extends the chain if necessary by allocating buffers from the supplied allocator. The existing chain can be empty.

void GetData ( BYTE pData,
DWORD  dataLength 
)

TODO - Remove data? return amount removed? similar functionality to CopyData...

void GetData ( IPoolBuffers pool,
BYTE pData,
DWORD  dataLength 
)

CBufferChain DuplicateBufferChain (  )  const

Makes a deep copy of the data in the buffer chain and returns a new chain. Buffers used to create the new chain are allocated from the head buffer of the source chain. Data will be consolidated into the new chain's buffers and use the minimum number of buffers.

virtual size_t Purge ( IHandlePurgedBufferRelease purgeHandler,
UserData  userData 
) [pure virtual, inherited]

virtual bool TryAdd ( CSmartBuffer buffer  )  [inline, virtual, inherited]

Reimplemented in CSortedBufferChain.

virtual CSmartBuffer TryGetNext ( CSmartBuffer buffer,
bool inserted 
) [inline, virtual, inherited]

Reimplemented in CSortedBufferChain.

static JetByteTools::Core::IIndexedOpaqueUserData::UserDataIndex GetNextBufferIndex ( JetByteTools::Core::IIndexedOpaqueUserData::UserDataIndex  nextBufferIndex  )  [static, protected, inherited]


Member Data Documentation


Generated on Sun Sep 12 19:09:21 2021 for The Server Framework - v7.4 by doxygen 1.5.3