~ubuntu-branches/ubuntu/maverick/aspectc++/maverick

« back to all changes in this revision

Viewing changes to Puma/gen-release/step1/inc/Puma/ScanBuffer.h

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-04-10 17:40:52 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080410174052-xdnsm7oi8hauyyf1
Tags: 1.0pre4~svn.20080409+dfsg-3
Fix another missing include, this time in Ag++/StdSystem.cc

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#ifndef __scan_buffer_h__
20
20
#define __scan_buffer_h__
21
21
 
 
22
#include <iostream>
 
23
using namespace std;
 
24
 
22
25
namespace Puma {
23
26
 
24
 
 
25
27
class ScanBuffer {
26
28
public:
27
 
  typedef enum { STATE_END, STATE_ERROR, STATE_OK } State;
 
29
  typedef enum { STATE_NEW, STATE_END, STATE_ERROR, STATE_OK } State;
 
30
 
 
31
private:
 
32
  int _token;      // start position of current token
 
33
  int _pos;        // current position (in token; _pos >= _token && pos < filled)
 
34
  char *_buffer;   // token to the buffer that contains all input characters
 
35
  int  _buff_size; // size of the input buffer
 
36
  State _state;
 
37
 
 
38
public:  
 
39
  ScanBuffer () : _state (STATE_NEW) {}
 
40
 
 
41
  // init buffer to directly scan from a string
 
42
  void init (const char *str, int l = 0);
28
43
  
29
 
  virtual ~ScanBuffer () {}
30
 
 
31
 
  virtual char next () = 0;
32
 
  virtual char *token () = 0;
33
 
  virtual int len () const = 0;
34
 
  virtual void reset () = 0;
35
 
  virtual void retry () = 0; 
36
 
  virtual void accept (int len) = 0;
37
 
  virtual void more (int len) = 0;
38
 
  virtual State state () const = 0;
 
44
  char next () { return _buffer[_pos++]; }
 
45
  char lookahead () { return _buffer[_pos]; }
 
46
  char *token () const { return _buffer + _token; }
 
47
  int len () const { return _pos - _token; }
 
48
  void reset () { _token = _pos = 0; }
 
49
  void retry () { _pos = _token; } 
 
50
  void accept (int len) {
 
51
    _token += len;
 
52
    _pos = _token;
 
53
  }
 
54
  void more (int len) { _pos = _token + len; }
 
55
  State state () {
 
56
    if (_state == STATE_OK && _pos >= _buff_size)
 
57
      return STATE_END;
 
58
    return _state;
 
59
  }
39
60
};
40
61
 
41
62