41 lines
571 B
C++
41 lines
571 B
C++
|
/*
|
|||
|
* buffer.cpp
|
|||
|
*
|
|||
|
* Created on: 7 сент. 2022 г.
|
|||
|
* Author: alexander
|
|||
|
*/
|
|||
|
|
|||
|
#include <buffer.hpp>
|
|||
|
#include <string.h>
|
|||
|
#include <string>
|
|||
|
|
|||
|
namespace zh
|
|||
|
{
|
|||
|
|
|||
|
Buffer::Buffer(const unsigned short int size) : _size(size)
|
|||
|
{
|
|||
|
_buffer = std::make_unique<std::byte[]>(_size);
|
|||
|
}
|
|||
|
|
|||
|
const unsigned short int Buffer::getSize() const
|
|||
|
{
|
|||
|
return _size;
|
|||
|
}
|
|||
|
|
|||
|
const std::string Buffer::getString() const
|
|||
|
{
|
|||
|
return reinterpret_cast<char*>(_buffer.get());
|
|||
|
}
|
|||
|
|
|||
|
void Buffer::clear()
|
|||
|
{
|
|||
|
bzero(_buffer.get(), _size);
|
|||
|
}
|
|||
|
|
|||
|
Buffer::operator void*()
|
|||
|
{
|
|||
|
return _buffer.get();
|
|||
|
}
|
|||
|
|
|||
|
}
|