1#ifndef VITROIO_SDK_BUFFER_H
2#define VITROIO_SDK_BUFFER_H
33 if( (buff_ =
new (nothrow) uint8_t[
size]) ){
34 availableSize_ =
size;
37 memset(buff_, defaultValue,
size);
57 return availableSize_;
67 return workingSize_ - usedSize_;
72 if(
size > availableSize_){
77 usedSize_ = (usedSize_ > workingSize_) ? workingSize_ : usedSize_;
87 const uint8_t*
get()
const
92 uint32_t
set(uint8_t* data, uint32_t
size)
96 memcpy(buff_ + freeOffset_, data, bytesToSet);
97 usedSize_ += bytesToSet;
98 freeOffset_ += bytesToSet;
103 void clear(uint32_t newSize = 0, uint8_t defaultValue = 0)
107 memset(buff_, defaultValue, availableSize_);
117 return (usedSize_ == workingSize_) ? true :
false;
120 operator bool()
const
127 uint32_t availableSize_;
128 uint32_t workingSize_;
130 uint32_t freeOffset_;
const uint8_t * get() const
Definition: buffer.h:87
void free()
Definition: buffer.h:43
uint32_t freeSize() const
Definition: buffer.h:65
bool isFull() const
Definition: buffer.h:115
uint32_t set(uint8_t *data, uint32_t size)
Definition: buffer.h:92
bool isEmpty() const
Definition: buffer.h:110
bool alloc(uint32_t size, uint8_t defaultValue=0)
Definition: buffer.h:31
uint32_t size() const
Definition: buffer.h:60
uint8_t * get()
Definition: buffer.h:82
bool resize(uint32_t size)
Definition: buffer.h:70
uint32_t availableSize() const
Definition: buffer.h:55
~Buffer()
Definition: buffer.h:26
Buffer()
Definition: buffer.h:18
void clear(uint32_t newSize=0, uint8_t defaultValue=0)
Definition: buffer.h:103
The namespace contains all of components of vitro-shard-sdk and components based on the sdk....
Definition: can_layer.h:9