~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/linebuffer.h

Merge Robert's readline/linebuffer work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
 
 
17
 
typedef struct st_line_buffer
 
16
#ifndef CLIENT_LINEBUFFER_H
 
17
#define CLIENT_LINEBUFFER_H
 
18
 
 
19
#include <vector>
 
20
 
 
21
class LineBuffer
18
22
{
19
 
  File file;
20
 
  char *buffer;                 /* The buffer itself, grown as needed. */
21
 
  char *end;                    /* Pointer at buffer end */
22
 
  char *start_of_line,*end_of_line;
23
 
  uint32_t bufread;                     /* Number of bytes to get with each read(). */
24
 
  uint32_t eof;
 
23
public:
 
24
  LineBuffer(uint32_t max_size,FILE *file);
 
25
 
 
26
  void addString(const std::string &argument);
 
27
  char *readline();
 
28
private:
 
29
  FILE *file;
 
30
  std::stringstream buffer;
 
31
  std::vector<char> line;
25
32
  uint32_t max_size;
26
 
  uint32_t read_length;         /* Length of last read string */
27
 
} LINE_BUFFER;
 
33
  bool eof;
 
34
};
28
35
 
29
 
extern LINE_BUFFER *batch_readline_init(uint32_t max_size,FILE *file);
30
 
extern LINE_BUFFER *batch_readline_command(LINE_BUFFER *buffer, char * str);
31
 
extern char *batch_readline(LINE_BUFFER *buffer);
32
 
extern void batch_readline_end(LINE_BUFFER *buffer);
 
36
#endif /* CLIENT_LINEBUFFER_H */