summaryrefslogtreecommitdiff
path: root/lib/Buffer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Buffer.cc')
-rw-r--r--lib/Buffer.cc22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/Buffer.cc b/lib/Buffer.cc
index 2c2c955..e8335d9 100644
--- a/lib/Buffer.cc
+++ b/lib/Buffer.cc
@@ -3,7 +3,7 @@
#include "General.h"
#include "config.h"
-Buffer::Buffer() : Handle(-1), buffer(0), realsiz(0), bufsiz(0), ptr(0) { }
+Buffer::Buffer() : Handle(-1), buffer(0), zero(0), realsiz(0), bufsiz(0), ptr(0) { }
Buffer::~Buffer() {
free(buffer);
@@ -75,3 +75,23 @@ Buffer Buffer::operator=(const Buffer & b) {
bool Buffer::CanWatch() {
return false;
}
+
+ssize_t Buffer::GetSize() {
+ return realsiz;
+}
+
+char Buffer::operator[](size_t p) const {
+ if (p >= realsiz) {
+ return 0;
+ } else {
+ return buffer[ptr + p];
+ }
+}
+
+char & Buffer::operator[](size_t p) {
+ if (p >= realsiz) {
+ return zero;
+ } else {
+ return buffer[ptr + p];
+ }
+}