TypedBuffer.h 515 B

123456789101112131415161718192021222324252627282930313233
  1. #ifndef TYPEBUFFER_H
  2. #define TYPEBUFFER_H
  3. #include "data/List.h"
  4. template<typename T>
  5. class TypedBuffer {
  6. List<T> data;
  7. public:
  8. TypedBuffer& add(const T& t) {
  9. data.add(t);
  10. return *this;
  11. }
  12. int getLength() const {
  13. return data.getLength();
  14. }
  15. int getByteLength() const {
  16. return data.getLength() * static_cast<int>(sizeof(T));
  17. }
  18. operator const T*() const {
  19. return data.begin();
  20. }
  21. void clear() {
  22. data.clear();
  23. }
  24. };
  25. #endif