37 template<
typename Stream>
39 : m_stream(f), m_begin(NULL), m_end(NULL), m_current(NULL),
42 m_begin =
new char[m_buffer_size];
51 template<
typename Stream>
64 template<
typename Stream>
67 return m_end - m_current;
76 template<
typename Stream>
79 if ( n <= remaining() )
82 unsigned int r = remaining();
85 if ( m_current + n > m_begin + m_buffer_size )
88 if (n <= m_buffer_size)
89 std::copy(m_current, m_end, m_begin);
94 char* new_buffer =
new char[m_buffer_size];
96 std::copy(m_current, m_end, new_buffer);
100 m_begin = new_buffer;
104 m_end = m_current + r;
107 m_stream.read( m_end, n-r );
108 m_end += m_stream.gcount();
117 template<
typename Stream>
127 template<
typename Stream>
130 assert( remaining() >= 1 );
132 char result = *m_current;
144 template<
typename Stream>
147 while ( (n != 0) && !!(*
this) )
149 if ( n > remaining() )
150 read_more(m_buffer_size);
152 unsigned int len = std::min(n, remaining());
154 std::copy( m_current, m_current + len, buf );
168 template<
typename Stream>
171 assert( m_current + n <= m_end );
182 template<
typename Stream>
185 m_stream.seekg( m_current - m_end, std::ios_base::cur );
194 template<
typename Stream>
197 return m_stream || (remaining() > 0);