-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBufferInputOutputStream.h
More file actions
31 lines (24 loc) · 894 Bytes
/
BufferInputOutputStream.h
File metadata and controls
31 lines (24 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
* BufferInputOutputStream.h
*
* Created on: Jan 18, 2016
* Author: sabeyruw
*/
#ifndef BUFFERINPUTOUTPUTSTREAM_H_
#define BUFFERINPUTOUTPUTSTREAM_H_
#include "ObjectInputStream.h"
#include "ObjectOutputStream.h"
//
#include <string.h>
class BufferInputOutputStream : public ObjectInputStream, public ObjectOutputStream
{
public:
unsigned char* buffer;
int bufferLocation;
BufferInputOutputStream(unsigned char* buffer) : buffer(buffer), bufferLocation(0) {}
virtual ~BufferInputOutputStream() {}
void read(unsigned char* destination, const int& size) { memcpy(destination, buffer + bufferLocation, size); bufferLocation += size; }
void write(const unsigned char* source, const int& size) { memcpy(buffer + bufferLocation, source, size); bufferLocation += size; }
void reset() { bufferLocation = 0; }
};
#endif /* BUFFERINPUTOUTPUTSTREAM_H_ */