next up previous contents index
Next: Class IOLexerStack Up: Lexer Specification Previous: Class LexerBuffer

Class IOLexerBuffer

Class IOLexerBuffer  is a derived class of LexerBuffer. It automatically manages an internal buffer and receives input from an istream. It is defined in the file <AD/automata/iolexerbuf.h>

This class provides the following additional features: Constructor IOLexerBuffer(istream&) ties the input to a stream. If the default constructor is used, then it automatically ties the input to the stream cin. The method set_stream can be used to set the stream to some other input.

class IOLexerBuffer : public LexerBuffer {
   size_t    buffer_size;  // size of the buffer
   istream * input;        // input stream
public:
   IOLexerBuffer();
   IOLexerBuffer(istream&);
   virtual ~IOLexerBuffer();
   virtual void set_stream (istream&);
};

By default, class IOLexerBuffer reads new data from the input stream using a line buffering discipline. This mechanism is suitable for interactive, but for other applications it may be more efficient to use block buffered input. The protected method read_buffer controls this reading behavior; it is called whenever the data in the string buffer has been consumed and new input is needed from the stream. It is passed the position of the buffer and its remaining capacity, and it returns the number of new characters that are read. Subclasses can redefine this method.

protected:
   virtual size_t read_buffer(char *, size_t);



Allen Leung
Mon Apr 7 14:33:55 EDT 1997