blob: aff593d0d6347f62dc7d5eb87469c128f7f382fb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#ifndef __SPOOLREWINDINPUTSTREAM_H
#define __SPOOLREWINDINPUTSTREAM_H
#include "RewindInputStream.hpp"
#include <iostream>
#include <fstream>
#include <vector>
class spool_streambuf : public std::streambuf
{
public:
explicit spool_streambuf( size_t bufSize = 256, size_t putBack = 1, size_t spoolBufSize = 8192 );
~spool_streambuf( );
void rewind( );
protected:
virtual std::streambuf::int_type readFromSource( ) = 0;
private:
int_type underflow( );
private:
const size_t m_putBack;
std::vector<char> m_spoolBuf;
size_t m_spoolBufPos;
size_t m_spoolBufSize;
std::fstream m_spoolFile;
enum { TO_SPOOL_MEMORY = 1, TO_SPOOL_FILE = 2, FROM_SPOOL_MEMORY = 3, FROM_SPOOL_FILE = 4 } m_state;
protected:
std::vector<char> m_buf;
char *m_base;
char *m_start;
};
class SpoolRewindInputStream : public RewindInputStream
{
public:
SpoolRewindInputStream( const URL &url );
virtual ~SpoolRewindInputStream( );
virtual void rewind( );
protected:
spool_streambuf *m_buf;
};
#endif
|