27 #include "dabc/defines.h"
91 #ifdef DABC_EXTRA_CHECKS
92 DebugObject(
"Buffer",
this, 1);
96 void*
operator new(
size_t sz) {
100 void*
operator new(
size_t sz,
void* area) {
101 if (area)
return area;
105 void operator delete(
void* area)
314 static
Buffer CreateBuffer(const
void* ptr,
unsigned size,
bool owner = false,
bool makecopy = false) throw();
#define DABC_REFERENCE(RefClass, ParentClass, T)
Container for data, referenced by Buffer class.
MemSegment * fSegm
array of segments
unsigned fNumSegments
number of entries in segments list
virtual ~BufferContainer()
unsigned fTypeId
buffer type, identifies content of the buffer
Reference fPool
reference on the memory pool (or other object, containing memory)
unsigned fCapacity
capacity of segments list
Reference on memory from memory pool.
Buffer Duplicate() const
Duplicates instance of Buffer with new segments list independent from source.
unsigned NumSegments() const
Returns number of segment in buffer.
bool Insert(BufferSize_t pos, Buffer &src, bool moverefs=true)
Insert content of buffer at specified position.
bool Append(Buffer &src, bool moverefs=true)
Append content of provided buffer.
bool IsPool(const Reference &pool) const
Returns true if buffer produced by the pool provided as reference.
unsigned SegmentSize(unsigned n=0) const
Returns size on the segment, no any boundary checks.
void AllocateContainer(unsigned capacity)
void MakeEmpty(unsigned capacity=8)
Method produce buffer with empty segments list Such buffer can be used to collect segments from other...
BufferSize_t CopyTo(void *ptr, BufferSize_t len) const
Copy content into provided raw buffer.
void CutFromBegin(BufferSize_t len)
Remove part of buffer from the beginning.
void SetTotalSize(BufferSize_t len)
Set total length of the buffer to specified value Size cannot be bigger than original size of the buf...
BufferSize_t CopyFrom(const Buffer &srcbuf, BufferSize_t len=0)
Copy content from source buffer.
unsigned GetTypeId() const
BufferSize_t GetTotalSize() const
Return total size of all buffer segments.
MemoryPool * PoolPtr() const
MemSegment * Segments() const
Buffer GetNextPart(Pointer &ptr, BufferSize_t len, bool allowsegmented=true)
Returns reference on the part of the memory, referenced by the object.
std::string AsStdString()
Convert content of the buffer into std::string.
BufferSize_t CopyFromStr(const char *src, unsigned len=0)
Copy data from string.
bool Prepend(Buffer &src, bool moverefs=true)
Prepend content of provided buffer.
unsigned SegmentId(unsigned n=0) const
Returns id of the segment, no any boundary checks.
Buffer HandOver()
Method hands over buffer, that source will be emptied at the end.
bool CanSafelyChange() const
Returns true when user can modify buffer content without any doubts.
Reference GetPool() const
Returns reference on the pool, in user code MemoryPoolRef can be used like dabc::Buffer buf = Recv();...
static Buffer CreateBuffer(BufferSize_t sz)
This static method create independent buffer for any other memory pools Therefore it can be used in s...
void SetTypeId(unsigned tid)
void Locate(BufferSize_t p, unsigned &seg_indx, unsigned &seg_shift) const
void * SegmentPtr(unsigned n=0) const
Returns pointer on the segment, no any boundary checks.
Base class for most of the DABC classes.
@ flNoMutex
object will be created without mutex, only can be used in constructor
@ flAutoDestroy
object will be automatically destroyed when no references exists, normally set in constructor,...
Manipulator with dabc::Buffer class.
Reference on the arbitrary object
Object * GetObject() const
Return pointer on the object.
Reference Take()
Copy reference to output object.
const BufferSize_t BufferSizeError
Structure with descriptor of single memory segment.
unsigned id
id of the buffer
void * buffer
pointer on the beginning of buffer (must be in the area of id)
unsigned datasize
length of data
void copy_from(MemSegment *src)