geekbrains_network_programming/lesson_03/source/buffer.cpp

41 lines
571 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* 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();
}
}