diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-01-23 10:18:17 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-01-23 10:51:26 +0100 |
commit | e12c679b8cc8a263507c556cb24819dc0d5559b9 (patch) | |
tree | 8f2cd06710d15ca64a4a86c1ce52bc975ec3f2b0 /src/Buffer.h | |
parent | d82422fbb3d9d34a0566197245376548ce3ef14e (diff) | |
parent | 94c1f63b6fd07d74f3325274dd19fd6beaf53965 (diff) | |
download | dabmod-e12c679b8cc8a263507c556cb24819dc0d5559b9.tar.gz dabmod-e12c679b8cc8a263507c556cb24819dc0d5559b9.tar.bz2 dabmod-e12c679b8cc8a263507c556cb24819dc0d5559b9.zip |
Merge raspine's ZeroMQ RC and UHD staticdelay
Merge raspine/master pull request, fix indentation, code style, and two
minor conflicts in:
doc/example.ini
src/DabMod.cpp
Diffstat (limited to 'src/Buffer.h')
-rw-r--r-- | src/Buffer.h | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/src/Buffer.h b/src/Buffer.h index b1a5d93..4bb157b 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -29,28 +29,47 @@ #include <unistd.h> - +/* Buffer is a container for a byte array, that is memcpy'ed + * on assignment and by the copy-constructor. + * + * The allocation/freeing of the data is handled internally. + */ class Buffer { -protected: - size_t len; - size_t size; - void *data; + protected: + /* Current length of the data in the Buffer */ + size_t len; -public: - Buffer(const Buffer& copy); - Buffer(size_t len = 0, const void *data = NULL); - ~Buffer(); + /* Allocated size of the Buffer */ + size_t size; - Buffer &operator=(const Buffer ©); - Buffer &operator+=(const Buffer ©); + /* Pointer to the data. Memory allocation is entirely + * handled by setLength. + */ + void *data; - void setLength(size_t len); - void setData(const void *data, size_t len); - void appendData(const void *data, size_t len); + public: + Buffer(const Buffer& copy); + Buffer(size_t len = 0, const void *data = NULL); + ~Buffer(); - size_t getLength(); - void *getData(); -}; + /* Resize the buffer, reallocate memory if needed */ + void setLength(size_t len); + + /* Replace the data in the Buffer by the new data given. + * Reallocates memory if needed. + */ + void setData(const void *data, size_t len); + Buffer &operator=(const Buffer ©); + /* Concatenate the current data with the new data given. + * Reallocates memory if needed. + */ + void appendData(const void *data, size_t len); + Buffer &operator+=(const Buffer ©); + + size_t getLength() const { return len; } + void *getData() const { return data; } +}; #endif // BUFFER_H + |