   streambuffer
  Hi!I will now show you my streambuffer and i do this, because i want to improve my code.Later the streambuffer should be used for things like compression,...#ifndef _STREAMBUFFER_H_#define _STREAMBUFFER_H_#include <vector>namespace Tools{// ==================================templateclass streambuffer{public:// const/destrstreambuffer(): m_capacity(0), m_consumed(0), m_pos(0){}streambuffer(size_t Size) : m_consumed(0), m_pos(0){ Allocate(Size); }~streambuffer(){ /*Reset();*/ }#pragma ToDo("Copy Constructor")#pragma ToDo("Assignment")// access operatorsinline void __fastcall Seek (size_t pos){ m_pos = pos; }// getinline size_t __fastcall GetConsumed() const{ return m_consumed; }inline size_t __fastcall GetCapacity() const{ return m_capacity; }inline T __fastcall GetBufferElement(int index) const{ if (!m_buffer.empty()) { return m_buffer[index]; } else { return (T)0; } }inline bool __fastcall IsValid() const{ if (!m_buffer.empty()) { return true; } else { return false; } }// ==================================inline T* GetBuffer() const{#pragma ToDo("Better way to do this? - Memleak?")T* temp = new T[m_consumed + 1];// set to 0memset(temp,0, m_consumed + 1);// copy vector elements into temp bufferfor (int i = 0; i < m_consumed; ++i){temp = m_buffer;}// temp ends with a 0return temp;}// ==================================inline void Allocate(size_t Size){m_buffer.resize(m_capacity + Size);m_capacity += Size;}// ==================================inline bool Read(T* output, size_t size, size_t StartPos = -1){if (StartPos != -1){Seek(StartPos);}for (unsigned int i = 0; i < size; ++i){if (m_pos < GetCapacity()){output = GetBufferElement(m_pos);++m_pos;}else{output = (T)0;}}return true;}// ==================================inline void Trim(){std::vector<T> temp = m_buffer;// clear bufferm_buffer.clear();for (int i = 0; i < m_consumed; ++i){m_buffer.push_back(temp);}}// ==================================inline void AddBuffer(T* Buffer, size_t Size){// must we reallocate some new space?if (m_capacity - m_consumed < Size){Allocate(Size);}for (long i = 0; i < Size; ++i){m_buffer = Buffer;}m_consumed += Size;}// ==================================inline void Reset(){if (m_consumed != 0) { m_buffer.clear();}m_capacity = 0;m_consumed = 0;m_pos = 0;}protected:std::vector<T>m_buffer;size_tm_capacity;size_tm_consumed;size_tm_pos;};}#endif /*_STREAMBUFFER_H_*/ </pre> It would be nice if someone looks at the code and gives me improvements.Thanks, Christian  </i>  
  Why not std::stringstream? 