diff --git a/DataWriter.cpp b/DataWriter.cpp deleted file mode 100644 index 9f7036b..0000000 --- a/DataWriter.cpp +++ /dev/null @@ -1,98 +0,0 @@ -#include "DataWriter.h" -#include "Endian.h" - -#include - -using namespace ProFUSE; - -DataWriter::DataWriter(unsigned size) -{ - _size = size; - _release = true; - _offset = 0; - _buffer = new uint8_t[size]; -} - -DataWriter::DataWriter(unsigned size, void *buffer) -{ - _size = size; - _buffer = (uint8_t *)buffer; - _release = false; - _offset = 0; -} - -DataWriter::~DataWriter() -{ - if (_release && _buffer) delete[] _buffer; -} - -void DataWriter::write8(uint8_t data) -{ - _buffer[_offset] = data; - _offset += 1; -} - -void DataWriter::write(const void *data, unsigned size) -{ - std::memcpy(pointer(), data, size); - _offset += size; -} - - - -DataWriterLE::DataWriterLE(unsigned size) : - DataWriter(size) -{} - -DataWriterLE::DataWriterLE(unsigned size, void *buffer) : - DataWriter(size, buffer) -{} - - -void DataWriterLE::write16(uint16_t data) -{ - LittleEndian::Write16(pointer(), data); - _offset += 2; -} - -void DataWriterLE::write24(uint32_t data) -{ - LittleEndian::Write24(pointer(), data); - _offset += 3; -} - -void DataWriterLE::write32(uint32_t data) -{ - LittleEndian::Write32(pointer(), data); - _offset += 4; -} - - - -DataWriterBE::DataWriterBE(unsigned size) : - DataWriter(size) -{} - -DataWriterBE::DataWriterBE(unsigned size, void *buffer) : - DataWriter(size, buffer) -{} - - -void DataWriterBE::write16(uint16_t data) -{ - BigEndian::Write16(pointer(), data); - _offset += 2; -} - -void DataWriterBE::write24(uint32_t data) -{ - BigEndian::Write24(pointer(), data); - _offset += 3; -} - -void DataWriterBE::write32(uint32_t data) -{ - BigEndian::Write32(pointer(), data); - _offset += 4; -} - diff --git a/DataWriter.h b/DataWriter.h deleted file mode 100644 index 5323842..0000000 --- a/DataWriter.h +++ /dev/null @@ -1,72 +0,0 @@ - -#ifndef __DATAWRITER_H__ -#define __DATAWRITER_H__ - -#include - -namespace ProFUSE { - -class DataWriter { - -public: - - DataWriter(unsigned size); - DataWriter(unsigned size, void *data); - virtual ~DataWriter(); - - void write8(uint8_t); - virtual void write16(uint16_t) = 0; - virtual void write24(uint32_t) = 0; - virtual void write32(uint32_t) = 0; - - void write(const void *data, unsigned size); - - - void setOffset(unsigned o) { _offset = o; } - unsigned offset() const { return _offset; } - - void forward(unsigned count) { _offset += count; } - void rewind(unsigned count) { _offset -= count; } - - void *data() const { return _buffer; } - unsigned size() const { return _size; } - -protected: - - uint8_t *pointer() const { return _offset + _buffer; } - - bool _release; - unsigned _size; - - unsigned _offset; - uint8_t *_buffer; - - -}; - -class DataWriterLE : public DataWriter { -public: - DataWriterLE(unsigned); - DataWriterLE(unsigned, void *); - - virtual void write8(uint8_t); - virtual void write16(uint16_t); - virtual void write24(uint32_t); - virtual void write32(uint32_t); -}; - - -class DataWriterBE : public DataWriter { -public: - DataWriterBE(unsigned); - DataWriterBE(unsigned, void *); - - virtual void write8(uint8_t); - virtual void write16(uint16_t); - virtual void write24(uint32_t); - virtual void write32(uint32_t); -}; - -} - -#endif \ No newline at end of file