geekbrains_network_programming/lesson_03/source/buffer.cpp

41 lines
571 B
C++
Raw Normal View History

2022-09-07 12:43:34 +00:00
/*
* 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();
}
}