increase version number to 0.1
[ecparse.git] / GrowingBuffer.h
1 /**
2  * © 2008 by David ‘Bombe’ Roden <bombe@pterodactylus.net>
3  */
4
5 #pragma once
6
7 /**
8  * A buffer that will grow to accomodate the data being put into it.
9  */
10 class GrowingBuffer {
11
12 public:
13
14         /**
15          * Empty constructor. Creates a buffer with a default size of 1024 bytes.
16          *
17          * @param initialSize The initial size of the buffer in bytes
18          */
19         GrowingBuffer(size_t initialSize = 1024);
20
21         /**
22          * Destructor. Frees all used resources.
23          */
24         ~GrowingBuffer();
25
26         size_t getPosition();
27         size_t getLimit();
28         size_t getSize();
29         size_t getRemaining();
30
31         /**
32          * Sets the position of the buffer. The next {@link read(void*, size_t)} or
33          * {@link write(const void*, size_t)} operation will be applied at the new
34          * position.
35          *
36          * @param position The position to seek to
37          */
38         void seek(size_t position);
39         void* read(void* buffer, size_t length);
40         void write(const void* buffer, size_t length);
41         void cut();
42         void truncate();
43         void clear();
44         void resize(double factor = 1.0);
45
46         size_t indexOf(char c, size_t start = 0);
47
48 private:
49         void* data;
50         size_t size;
51         size_t limit;
52         size_t position;
53
54 };
55