summaryrefslogtreecommitdiff
path: root/arduino_libs/ByteBuffer/.svn/text-base/ByteBuffer.h.svn-base
blob: b100c2fb790f0fb2309aaf7d9d2dec71043052a7 (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
  ByteBuffer.h - A circular buffer implementation for Arduino
  Created by Sigurdur Orn, July 19, 2010.
 */
#ifndef ByteBuffer_h
#define ByteBuffer_h

#include "WProgram.h"

class ByteBuffer
{
public:
	ByteBuffer();

	void init(unsigned int buf_size);
	
	void clear();
	int getSize();
	int getCapacity();

	int putInFront(byte in);
	int put(byte in);

	byte get();
	byte getFromBack();

	byte peek(unsigned int index);
	
	int putIntInFront(int in);
	int putInt(int in);

	int putLongInFront(long in);
	int putLong(long in);

	int getInt();
	int getIntFromBack();

	long getLong();	
	long getLongFromBack();	

	int putFloatInFront(float in);
	int putFloat(float in);

	float getFloat();	
	float getFloatFromBack();	

private:
	byte* data;
	byte* float_bytes;

	unsigned int capacity;
	unsigned int position;
	unsigned int length;
};

#endif