Control Surface
main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
src
MIDI_Parsers
BufferPuller.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <AH/STL/vector>
// std::vector
4
#include <Settings/NamespaceSettings.hpp>
5
6
BEGIN_CS_NAMESPACE
7
12
template
<
class
T = u
int
8_t>
13
class
BufferPuller_
{
14
public
:
15
BufferPuller_
(
const
T *
buffer
,
size_t
length)
16
:
buffer
(
buffer
),
end
(
buffer
+ length) {}
17
22
bool
pull
(T &output) {
23
if
(
buffer
!=
end
) {
24
output = *
buffer
++;
25
return
true
;
26
}
27
return
false
;
28
}
29
30
private
:
31
const
T *
buffer
;
32
const
T *
const
end
;
33
};
34
35
template
<
class
T>
36
BufferPuller_<T>
BufferPuller
(
const
T *buffer,
size_t
length) {
37
return
{buffer, length};
38
}
39
template
<
class
T>
40
BufferPuller_<T>
BufferPuller
(
const
std::vector<T> &buffer) {
41
return
{buffer.data(), buffer.size()};
42
}
43
template
<
class
T,
size_t
N>
44
BufferPuller_<T>
BufferPuller
(
const
T (&buffer)[N]) {
45
return
{buffer, N};
46
}
47
48
END_CS_NAMESPACE
BufferPuller
BufferPuller_< T > BufferPuller(const T *buffer, size_t length)
Definition
BufferPuller.hpp:36
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition
Settings/NamespaceSettings.hpp:14
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition
Settings/NamespaceSettings.hpp:11
BufferPuller_
Helper to pull bytes or other objects out of a buffer.
Definition
BufferPuller.hpp:13
BufferPuller_::BufferPuller_
BufferPuller_(const T *buffer, size_t length)
Definition
BufferPuller.hpp:15
BufferPuller_::end
const T *const end
Definition
BufferPuller.hpp:32
BufferPuller_::pull
bool pull(T &output)
Pull a value out of the buffer.
Definition
BufferPuller.hpp:22
BufferPuller_::buffer
const T * buffer
Definition
BufferPuller.hpp:31
Generated by
1.10.0