19#ifndef __XRD_CL_BUFFER_HH__
20#define __XRD_CL_BUFFER_HH__
52 Steal( std::move( buffer ) );
60 Steal( std::move( buffer ) );
92 throw std::bad_alloc();
115 pBuffer = (
char *)malloc( size );
117 throw std::bad_alloc();
164 void Append(
const char *buffer, uint32_t size )
167 if( remaining < size )
177 void Append(
const char *buffer, uint32_t size, uint32_t offset )
179 uint32_t remaining =
pSize-offset;
180 if( remaining < size )
183 memcpy(
pBuffer+offset, buffer, size );
208 memcpy(
pBuffer, str.c_str(), str.length() );
217 char *bf =
new char[
pSize+1];
220 std::string tmp = bf;
228 void Grab(
char *buffer, uint32_t size )
254 pSize = buffer.pSize;
Binary blob representation.
Definition XrdClBuffer.hh:34
void Free()
Free the buffer.
Definition XrdClBuffer.hh:99
void FromString(const std::string str)
Fill the buffer from a string.
Definition XrdClBuffer.hh:205
Buffer(uint32_t size=0)
Constructor.
Definition XrdClBuffer.hh:39
void AdvanceCursor(uint32_t delta)
Advance the cursor.
Definition XrdClBuffer.hh:156
void Grab(char *buffer, uint32_t size)
Grab a buffer allocated outside.
Definition XrdClBuffer.hh:228
void Steal(Buffer &&buffer)
Definition XrdClBuffer.hh:249
void Zero()
Zero.
Definition XrdClBuffer.hh:124
uint32_t pSize
Definition XrdClBuffer.hh:267
char * GetBufferAtCursor()
Get the buffer pointer at the append cursor.
Definition XrdClBuffer.hh:189
Buffer(Buffer &&buffer)
Move Constructor.
Definition XrdClBuffer.hh:50
void Append(const char *buffer, uint32_t size)
Append data at the position pointed to by the append cursor.
Definition XrdClBuffer.hh:164
void ReAllocate(uint32_t size)
Reallocate the buffer to a new location of a given size.
Definition XrdClBuffer.hh:88
const char * GetBufferAtCursor() const
Get the buffer pointer at the append cursor.
Definition XrdClBuffer.hh:197
void Allocate(uint32_t size)
Allocate the buffer.
Definition XrdClBuffer.hh:110
uint32_t pCursor
Definition XrdClBuffer.hh:268
const char * GetBuffer(uint32_t offset=0) const
Get the message buffer.
Definition XrdClBuffer.hh:72
void SetCursor(uint32_t cursor)
Set the cursor.
Definition XrdClBuffer.hh:148
uint32_t GetCursor() const
Get append cursor.
Definition XrdClBuffer.hh:140
Buffer & operator=(const Buffer &)
Buffer & operator=(Buffer &&buffer)
Move assignment operator.
Definition XrdClBuffer.hh:58
uint32_t GetSize() const
Get the size of the message.
Definition XrdClBuffer.hh:132
char * GetBuffer(uint32_t offset=0)
Get the message buffer.
Definition XrdClBuffer.hh:80
void Append(const char *buffer, uint32_t size, uint32_t offset)
Append data at the given offset.
Definition XrdClBuffer.hh:177
virtual ~Buffer()
Destructor.
Definition XrdClBuffer.hh:67
char * Release()
Release the buffer.
Definition XrdClBuffer.hh:238
char * pBuffer
Definition XrdClBuffer.hh:266
std::string ToString() const
Convert the buffer to a string.
Definition XrdClBuffer.hh:215
Definition XrdClAction.hh:34