Optibits
Loading...
Searching...
No Matches
include
Optibits
Buffer.hpp
1
#pragma once
2
3
#include <cstdint>
4
#include <functional>
5
#include <string>
6
#include <vector>
7
8
9
namespace
Optibits
10
{
11
12
class
Buffer
13
{
14
void
* m_buffer;
15
std::size_t m_size;
16
std::function<void(
void
*)> m_purger;
17
18
public
:
19
20
Buffer
() =
default
;
21
26
Buffer
(
void
* buffer, std::size_t size, std::function<
void
(
void
*)> purger);
27
Buffer
(
Buffer
&& other)
noexcept
;
28
Buffer
& operator=(
Buffer
&& other)
noexcept
;
29
~Buffer
();
30
33
explicit
Buffer
(std::size_t size);
34
37
explicit
Buffer
(std::vector<std::uint8_t>&& vector)
noexcept
;
38
41
Buffer
(
const
Buffer
& other);
42
46
Buffer
& operator=(
const
Buffer
& other);
47
49
void
drop
();
50
51
const
std::uint8_t* data()
const
{
return
static_cast<
const
std::uint8_t*
>
(m_buffer); }
52
std::uint8_t* data() {
return
static_cast<
std::uint8_t*
>
(m_buffer); }
53
std::size_t size()
const
{
return
m_size; }
54
};
55
59
Buffer
loadFile(
const
std::string& filename);
60
64
void
saveFile(
const
Buffer
& buffer,
const
std::string& filename);
65
66
}
Optibits::Buffer
Definition
Buffer.hpp:13
Optibits::Buffer::drop
void drop()
Drops the members of the buffer. (Basically resets them)
Definition
Buffer.cpp:16
Generated by
1.12.0