12#ifndef ALICEO2_ITSMFT_PAYLOADCONT_H
13#define ALICEO2_ITSMFT_PAYLOADCONT_H
46 const uint8_t*
data()
const {
return mBuffer.data(); }
51 bool isEmpty()
const {
return mPtr >= mEnd; }
56 mPtr = mBuffer.data();
64 size_t getSize()
const {
return mEnd - mBuffer.data(); }
67 size_t getOffset()
const {
return mPtr - mBuffer.data(); }
86 std::memset(mEnd,
c,
n);
93 std::memcpy(mEnd,
ptr,
n);
104 *mEnd++ = 0xff &
val;
183 if (mPtr < mEnd - (
sizeof(uint16_t) - 1)) {
199 std::memcpy(mBuffer.data(), mPtr,
left);
201 std::memmove(mBuffer.data(), mPtr,
left);
203 mPtr = mBuffer.data();
209 size_t append(std::function<
size_t(uint8_t*,
size_t)> getNext)
225 std::vector<uint8_t> mBuffer;
226 uint8_t* mPtr =
nullptr;
227 uint8_t* mEnd =
nullptr;
size_t getUnusedSize() const
get filled size
size_t getOffset() const
booked capacity
void ensureFreeCapacity(size_t n)
fill n bytes with given symbol w/o checking for the size
static constexpr size_t MinCapacity
allocate buffer
void eraseFast(size_t n)
erase n bytes
void shrinkToSize(size_t sz)
direct const access to value at a given slot, w/o checking for overflow
const uint8_t * data() const
increase the buffer size
void moveUnusedToHead()
move unused data to the head and upload new chunk of data
void add(uint8_t val)
add new short to the buffer
void addFast(uint8_t val)
add new short to the buffer w/o checking for the size
void addFast(uint16_t val)
erase n bytes w/o checking for the underflow
void rewind()
move all data between the mPtr and mEnd to the head of the buffer
uint8_t operator[](size_t i) const
direct access to value at a given slot, w/o checking for overflow
void add(const uint8_t *ptr, size_t n)
add new byte to the buffer
size_t getSize() const
get offset of the current ptr from the head
PayLoadCont & operator=(const PayLoadCont &src)
uint8_t * getPtr()
direct write access
void fill(const uint8_t c, size_t n)
add n bytes to the buffer, expand if needed. no check for overlap
void add(uint16_t val)
shrink buffer to requested size, no check on over/under flow
void clear()
get unused size
uint8_t & operator[](size_t i)
read current character value from buffer w/o stepping forward
void setEnd(uint8_t *ptr)
void addFast(const uint8_t *ptr, size_t n)
add new byte to the buffer w/o checking for the size
size_t getCapacity() const
number of bytes still can accept w/o expanding the buffer
bool next(uint8_t &v)
read short value from buffer
size_t getFreeCapacity() const
make sure buffer may accept at least n bytes
bool isEmpty() const
make buffer empty w/o deallocating it
bool current(uint8_t &v) const
read character value from buffer
size_t append(std::function< size_t(uint8_t *, size_t)> getNext)
void fillFast(const uint8_t c, size_t n)
add n bytes to the buffer w/o checking for the size
void erase(size_t n)
fill n bytes with given symbol
bool next(uint16_t &v)
move current pointer to the head
void setPtr(uint8_t *ptr)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...