Go to the documentation of this file.
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;
270 #endif // __XRD_CL_BUFFER_HH__
uint32_t GetCursor() const
Get append cursor.
Definition: XrdClBuffer.hh:140
void Allocate(uint32_t size)
Allocate the buffer.
Definition: XrdClBuffer.hh:110
std::string ToString() const
Convert the buffer to a string.
Definition: XrdClBuffer.hh:215
void SetCursor(uint32_t cursor)
Set the cursor.
Definition: XrdClBuffer.hh:148
char * pBuffer
Definition: XrdClBuffer.hh:264
virtual ~Buffer()
Destructor.
Definition: XrdClBuffer.hh:67
const char * GetBuffer(uint32_t offset=0) const
Get the message buffer.
Definition: XrdClBuffer.hh:72
void Append(const char *buffer, uint32_t size, uint32_t offset)
Append data at the given offset.
Definition: XrdClBuffer.hh:177
Buffer & operator=(const Buffer &)
char * GetBufferAtCursor()
Get the buffer pointer at the append cursor.
Definition: XrdClBuffer.hh:189
void ReAllocate(uint32_t size)
Reallocate the buffer to a new location of a given size.
Definition: XrdClBuffer.hh:88
void Steal(Buffer &&buffer)
Definition: XrdClBuffer.hh:249
uint32_t pCursor
Definition: XrdClBuffer.hh:266
Buffer(Buffer &&buffer)
Move Constructor.
Definition: XrdClBuffer.hh:50
Buffer(uint32_t size=0)
Constructor.
Definition: XrdClBuffer.hh:39
char * GetBuffer(uint32_t offset=0)
Get the message buffer.
Definition: XrdClBuffer.hh:80
uint32_t GetSize() const
Get the size of the message.
Definition: XrdClBuffer.hh:132
char * Release()
Release the buffer.
Definition: XrdClBuffer.hh:238
uint32_t pSize
Definition: XrdClBuffer.hh:265
Buffer & operator=(Buffer &&buffer)
Move assignment operator.
Definition: XrdClBuffer.hh:58
const char * GetBufferAtCursor() const
Get the buffer pointer at the append cursor.
Definition: XrdClBuffer.hh:197
void Append(const char *buffer, uint32_t size)
Append data at the position pointed to by the append cursor.
Definition: XrdClBuffer.hh:164
Definition: XrdClAnyObject.hh:26
void FromString(const std::string str)
Fill the buffer from a string.
Definition: XrdClBuffer.hh:205
Binary blob representation.
Definition: XrdClBuffer.hh:34
void Zero()
Zero.
Definition: XrdClBuffer.hh:124
void Grab(char *buffer, uint32_t size)
Grab a buffer allocated outside.
Definition: XrdClBuffer.hh:228
void AdvanceCursor(uint32_t delta)
Advance the cursor.
Definition: XrdClBuffer.hh:156
void Free()
Free the buffer.
Definition: XrdClBuffer.hh:99