summaryrefslogtreecommitdiffstats
path: root/src/Buffer.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Buffer.hpp')
-rw-r--r--src/Buffer.hpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Buffer.hpp b/src/Buffer.hpp
index 9af622d..c7fa9c7 100644
--- a/src/Buffer.hpp
+++ b/src/Buffer.hpp
@@ -27,6 +27,7 @@
#pragma once
#include <cstdint>
+#include <cstring>
#include <stdexcept>
#include <string>
@@ -58,6 +59,15 @@ public:
len -= n;
return std::string(reinterpret_cast<const char *>(data - n), n);
}
+
+ void getData(void *buf, size_t n) {
+ if (n > len)
+ throw std::runtime_error("Buffer::get(): buffer underrun");
+
+ data += n;
+ len -= n;
+ std::memcpy(buf, data - n, n);
+ }
};
}