123456789101112131415161718192021222324252627282930313233 |
- #ifndef TYPEBUFFER_H
- #define TYPEBUFFER_H
- #include "utils/Buffer.h"
- template<typename T>
- class TypedBuffer {
- Buffer data;
- public:
- TypedBuffer(int n) : data(sizeof (T) * n) {
- }
- TypedBuffer& add(const T& t) {
- data.add(t);
- return *this;
- }
- int getLength() const {
- return data.getLength() / sizeof (T);
- }
- int getByteLength() const {
- return data.getLength();
- }
- operator const T*() const {
- return reinterpret_cast<const T*>(static_cast<const char*>(data));
- }
- };
- #endif
|