Loading...
Searching...
No Matches
XrdCl::Buffer Class Reference

Binary blob representation. More...

`#include <XrdClBuffer.hh>`

Inheritance diagram for XrdCl::Buffer:
Collaboration diagram for XrdCl::Buffer:

## Public Member Functions

| Buffer (Buffer &&buffer)
| Move Constructor.
| Buffer (uint32_t size=0)
| Constructor.
virtual | ~Buffer ()
| Destructor.
void | AdvanceCursor (uint32_t delta)
| Advance the cursor.
void | Allocate (uint32_t size)
| Allocate the buffer.
void | Append (const char *buffer, uint32_t size)
| Append data at the position pointed to by the append cursor.
void | Append (const char *buffer, uint32_t size, uint32_t offset)
| Append data at the given offset.
void | Free ()
| Free the buffer.
void | FromString (const std::string str)
| Fill the buffer from a string.
char * | GetBuffer (uint32_t offset=0)
| Get the message buffer.
const char * | GetBuffer (uint32_t offset=0) const
| Get the message buffer.
char * | GetBufferAtCursor ()
| Get the buffer pointer at the append cursor.
const char * | GetBufferAtCursor () const
| Get the buffer pointer at the append cursor.
uint32_t | GetCursor () const
| Get append cursor.
uint32_t | GetSize () const
| Get the size of the message.
void | Grab (char *buffer, uint32_t size)
| Grab a buffer allocated outside.
Buffer & | operator= (Buffer &&buffer)
| Move assignment operator.
void | ReAllocate (uint32_t size)
| Reallocate the buffer to a new location of a given size.
char * | Release ()
| Release the buffer.
void | SetCursor (uint32_t cursor)
| Set the cursor.
std::string | ToString () const
| Convert the buffer to a string.
void | Zero ()
| Zero.

## Protected Member Functions

void | Steal (Buffer &&buffer)

## Detailed Description

Binary blob representation.

Definition at line 33 of file XrdClBuffer.hh.

## Constructor & Destructor Documentation

## Buffer() [1/2]

XrdCl::Buffer::Buffer | ( | uint32_t | size = 0 | ) |

inline

Constructor.

Definition at line 39 of file XrdClBuffer.hh.

: pBuffer(0), pSize(0), pCursor(0)
{
if( size )
{
Allocate( size );
}
}
XrdCl::Buffer::Allocate
void Allocate(uint32_t size)
Allocate the buffer.
Definition XrdClBuffer.hh:110

References Allocate().

Referenced by Buffer(), XrdCl::Message::Message(), XrdCl::Message::Message(), operator=(), and Steal().

Here is the call graph for this function:
Here is the caller graph for this function:

## Buffer() [2/2]

XrdCl::Buffer::Buffer | ( | Buffer && | buffer | ) |

inline

Move Constructor.

Definition at line 50 of file XrdClBuffer.hh.

{
Steal( std::move( buffer ) );
}
XrdCl::Buffer::Steal
void Steal(Buffer &&buffer)
Definition XrdClBuffer.hh:249

References Buffer(), and Steal().

Here is the call graph for this function:

## ~Buffer()

virtual XrdCl::Buffer::~Buffer | ( |  | ) |

inline virtual

Destructor.

Definition at line 67 of file XrdClBuffer.hh.

{ Free(); }
XrdCl::Buffer::Free
void Free()
Free the buffer.
Definition XrdClBuffer.hh:99

References Free().

Here is the call graph for this function:

## Member Function Documentation

## AdvanceCursor()

void XrdCl::Buffer::AdvanceCursor | ( | uint32_t | delta | ) |

inline

Advance the cursor.

Definition at line 156 of file XrdClBuffer.hh.

{
pCursor += delta;
}

Referenced by XrdCl::XRootDTransport::GetBody(), XrdCl::XRootDTransport::GetHeader(), XrdCl::XRootDTransport::GetMore(), and XrdCl::Socket::Send().

Here is the caller graph for this function:

## Allocate()

void XrdCl::Buffer::Allocate | ( | uint32_t | size | ) |

inline

Allocate the buffer.

Definition at line 110 of file XrdClBuffer.hh.

{
if( !size )
return;
pBuffer = (char *)malloc( size );
if( !pBuffer )
throw std::bad_alloc();
pSize = size;
}

Referenced by Buffer(), and XrdCl::XRootDTransport::GetHeader().

Here is the caller graph for this function:

## Append() [1/2]

void XrdCl::Buffer::Append | ( | const char * | buffer,
|  | uint32_t | size )

inline

Append data at the position pointed to by the append cursor.

Definition at line 164 of file XrdClBuffer.hh.

{
uint32_t remaining = pSize-pCursor;
if( remaining < size )
ReAllocate( pCursor+size );
memcpy( pBuffer+pCursor, buffer, size );
pCursor += size;
}
XrdCl::Buffer::ReAllocate
void ReAllocate(uint32_t size)
Reallocate the buffer to a new location of a given size.
Definition XrdClBuffer.hh:88

References ReAllocate().

Referenced by XrdCl::FileSystem::ChMod(), XrdCl::MessageUtils::CreateXAttrBody(), XrdCl::FileSystem::DirList(), XrdCl::FileStateHandler::Fcntl(), XrdCl::FileSystem::Locate(), XrdCl::FileSystem::MkDir(), XrdCl::FileSystem::Mv(), XrdCl::FileStateHandler::Open(), XrdCl::FileSystem::Prepare(), XrdCl::FileSystem::Query(), XrdCl::FileSystem::Rm(), XrdCl::FileSystem::RmDir(), XrdCl::FileSystem::Stat(), XrdCl::FileSystem::StatVFS(), and XrdCl::FileSystem::Truncate().

Here is the call graph for this function:
Here is the caller graph for this function:

## Append() [2/2]

void XrdCl::Buffer::Append | ( | const char * | buffer,
|  | uint32_t | size,
|  | uint32_t | offset )

inline

Append data at the given offset.

Definition at line 177 of file XrdClBuffer.hh.

{
uint32_t remaining = pSize-offset;
if( remaining < size )
ReAllocate( offset+size );
memcpy( pBuffer+offset, buffer, size );
}

References ReAllocate().

Here is the call graph for this function:

## Free()

void XrdCl::Buffer::Free | ( |  | ) |

inline

Free the buffer.

Definition at line 99 of file XrdClBuffer.hh.

{
free( pBuffer );
pBuffer = 0;
pSize = 0;
pCursor = 0;
}

Referenced by ~Buffer(), and Grab().

Here is the caller graph for this function:

## FromString()

void XrdCl::Buffer::FromString | ( | const std::string | str | ) |

inline

Fill the buffer from a string.

Definition at line 205 of file XrdClBuffer.hh.

{
ReAllocate( str.length()+1 );
memcpy( pBuffer, str.c_str(), str.length() );
pBuffer[str.length()] = 0;
}

References ReAllocate().

Referenced by XrdCl::Utils::CheckTPC(), XrdCl::Utils::CheckTPCLite(), XrdCl::EcHandler::Close(), DoQuery(), XrdCl::Utils::GetRemoteCheckSum(), XrdCl::FileSystemUtils::GetSpaceInfo(), XrdCl::Utils::GetSupportedCheckSums(), main(), and XrdPosixAdmin::Query().

Here is the call graph for this function:
Here is the caller graph for this function:

## GetBuffer() [1/2]

char * XrdCl::Buffer::GetBuffer | ( | uint32_t | offset = 0 | ) |

inline

Get the message buffer.

Definition at line 80 of file XrdClBuffer.hh.

{
return pBuffer+offset;
}

## GetBuffer() [2/2]

const char * XrdCl::Buffer::GetBuffer | ( | uint32_t | offset = 0 | ) | const

inline

Get the message buffer.

Definition at line 72 of file XrdClBuffer.hh.

{
return pBuffer+offset;
}

Referenced by XrdCl::Utils::CheckEC(), XrdCl::FileStateHandler::ChkptWrt(), XrdCl::FileStateHandler::ChkptWrtV(), XrdCl::MessageUtils::CreateRequest(), XrdCl::MessageUtils::CreateXAttrBody(), XrdCl::LocalFileHandler::ExecRequest(), XrdCl::FileStateHandler::Fcntl(), XrdCl::XRootDTransport::GetBody(), GetBufferAtCursor(), GetBufferAtCursor(), XrdCl::XRootDTransport::GetHeader(), XrdCl::XRootDTransport::GetMore(), XrdCl::XRootDTransport::GetSignature(), XrdCl::AsyncSocketHandler::HandleWaitRsp(), XrdCl::XRootDTransport::LogErrorResponse(), main(), main(), XrdCl::XRootDTransport::MarshallRequest(), XrdCl::XRootDTransport::MessageReceived(), XrdCl::XRootDTransport::MessageSent(), XrdCl::XRootDTransport::MultiplexSubStream(), XrdCl::FileSystem::Mv(), XrdCl::FileStateHandler::OnStateError(), XrdCl::FileStateHandler::OnStateResponse(), XrdCl::LocalFileHandler::Open(), XrdCl::FileStateHandler::PgReadImpl(), XrdCl::FileSystem::Query(), XrdPosixAdmin::Query(), XrdCl::MessageUtils::RewriteCGIAndPath(), XrdCl::MessageUtils::SendMessage(), XrdCl::XRootDTransport::SetDescription(), XrdCl::XRootDTransport::UnMarchalStatusMore(), XrdCl::XRootDTransport::UnMarshallBody(), XrdCl::XRootDTransport::UnMarshallHeader(), XrdCl::XRootDTransport::UnMarshallRequest(), XrdCl::XRootDTransport::UnMarshalStatusBody(), XrdCl::FileStateHandler::VectorRead(), and XrdCl::FileStateHandler::VectorWrite().

Here is the caller graph for this function:

## GetBufferAtCursor() [1/2]

char * XrdCl::Buffer::GetBufferAtCursor | ( |  | ) |

inline

Get the buffer pointer at the append cursor.

Definition at line 189 of file XrdClBuffer.hh.

{
return GetBuffer( pCursor );
}
XrdCl::Buffer::GetBuffer
const char * GetBuffer(uint32_t offset=0) const
Get the message buffer.
Definition XrdClBuffer.hh:72

References GetBuffer().

Referenced by XrdCl::XRootDTransport::GetBody(), XrdCl::XRootDTransport::GetHeader(), XrdCl::XRootDTransport::GetMore(), and XrdCl::Socket::Send().

Here is the call graph for this function:
Here is the caller graph for this function:

## GetBufferAtCursor() [2/2]

const char * XrdCl::Buffer::GetBufferAtCursor | ( |  | ) | const

inline

Get the buffer pointer at the append cursor.

Definition at line 197 of file XrdClBuffer.hh.

{
return GetBuffer( pCursor );
}

References GetBuffer().

Here is the call graph for this function:

## GetCursor()

uint32_t XrdCl::Buffer::GetCursor | ( |  | ) | const

inline

Get append cursor.

Definition at line 140 of file XrdClBuffer.hh.

{
return pCursor;
}

Referenced by XrdCl::XRootDTransport::GetBody(), XrdCl::XRootDTransport::GetHeader(), XrdCl::XRootDTransport::GetMore(), and XrdCl::Socket::Send().

Here is the caller graph for this function:

## GetSize()

uint32_t XrdCl::Buffer::GetSize | ( |  | ) | const

inline

Get the size of the message.

Definition at line 132 of file XrdClBuffer.hh.

{
return pSize;
}

Referenced by XrdCl::FileStateHandler::Fcntl(), XrdCl::XRootDTransport::GetBody(), XrdCl::XRootDTransport::GetHeader(), XrdCl::XRootDTransport::GetMore(), XrdCl::XRootDTransport::MultiplexSubStream(), XrdCl::FileSystem::Query(), XrdPosixAdmin::Query(), XrdCl::Socket::Send(), XrdCl::FcntlAction::Serialize(), and XrdCl::XRootDTransport::UnMarshalStatusBody().

Here is the caller graph for this function:

## Grab()

void XrdCl::Buffer::Grab | ( | char * | buffer,
|  | uint32_t | size )

inline

Grab a buffer allocated outside.

Definition at line 228 of file XrdClBuffer.hh.

{
Free();
pBuffer = buffer;
pSize = size;
}

References Free().

Referenced by XrdCl::XRootDTransport::GetSignature().

Here is the call graph for this function:
Here is the caller graph for this function:

## operator=()

Buffer & XrdCl::Buffer::operator= | ( | Buffer && | buffer | ) |

inline

Move assignment operator.

Definition at line 58 of file XrdClBuffer.hh.

{
Steal( std::move( buffer ) );
return *this;
}

References Buffer(), and Steal().

Here is the call graph for this function:

## ReAllocate()

void XrdCl::Buffer::ReAllocate | ( | uint32_t | size | ) |

inline

Reallocate the buffer to a new location of a given size.

Definition at line 88 of file XrdClBuffer.hh.

{
pBuffer = (char *)realloc( pBuffer, size );
if( !pBuffer )
throw std::bad_alloc();
pSize = size;
}

Referenced by Append(), Append(), FromString(), XrdCl::XRootDTransport::GetBody(), XrdCl::XRootDTransport::GetMore(), XrdCl::XRootDTransport::MultiplexSubStream(), and XrdCl::MessageUtils::RewriteCGIAndPath().

Here is the caller graph for this function:

## Release()

char * XrdCl::Buffer::Release | ( |  | ) |

inline

Release the buffer.

Definition at line 238 of file XrdClBuffer.hh.

{
char *buffer = pBuffer;
pBuffer = 0;
pSize = 0;
pCursor = 0;
return buffer;
}

## SetCursor()

void XrdCl::Buffer::SetCursor | ( | uint32_t | cursor | ) |

inline

Set the cursor.

Definition at line 148 of file XrdClBuffer.hh.

{
pCursor = cursor;
}

Referenced by XrdCl::Socket::Send().

Here is the caller graph for this function:

## Steal()

void XrdCl::Buffer::Steal | ( | Buffer && | buffer | ) |

inline protected

Definition at line 249 of file XrdClBuffer.hh.

{
pBuffer = buffer.pBuffer;
buffer.pBuffer = 0;
pSize = buffer.pSize;
buffer.pSize = 0;
pCursor = buffer.pCursor;
buffer.pCursor = 0;
}

References Buffer().

Referenced by Buffer(), operator=(), and XrdCl::Message::operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

## ToString()

std::string XrdCl::Buffer::ToString | ( |  | ) | const

inline

Convert the buffer to a string.

Definition at line 215 of file XrdClBuffer.hh.

{
char *bf = new char[pSize+1];
bf[pSize] = 0;
memcpy( bf, pBuffer, pSize );
std::string tmp = bf;
delete [] bf;
return tmp;
}

Referenced by XrdCl::Utils::CheckTPC(), XrdCl::Utils::CheckTPCLite(), DoCache(), DoPrepare(), DoQuery(), XrdCl::Utils::GetRemoteCheckSum(), XrdCl::FileSystemUtils::GetSpaceInfo(), XrdCl::Utils::GetSupportedCheckSums(), and main().

Here is the caller graph for this function:

## Zero()

void XrdCl::Buffer::Zero | ( |  | ) |

inline

Zero.

Definition at line 124 of file XrdClBuffer.hh.

{
memset( pBuffer, 0, pSize );
}

Referenced by XrdCl::Message::Message(), and XrdCl::MessageUtils::CreateRequest().

Here is the caller graph for this function:

The documentation for this class was generated from the following file:

- XrdClBuffer.hh