51
52 int _err; // Error flag for file seek/read operations
53 long _filepos; // Current offset from start of file
54 int _linenum;
55
56 ArchDesc& _AD; // Reference to Architecture Description
57
58 // Error reporting function
59 void file_error(int flag, int linenum, const char *fmt, ...);
60
61 public:
62 const BufferedFile *_fp; // File to be buffered
63
64 FileBuff(BufferedFile *fp, ArchDesc& archDesc); // Constructor
65 ~FileBuff(); // Destructor
66
67 // This returns a pointer to the start of the current line in the buffer,
68 // and increments bufeol and filepos to point at the end of that line.
69 char *get_line(void);
70 int linenum() const { return _linenum; }
71
72 // This converts a pointer into the buffer to a file offset. It only works
73 // when the pointer is valid (i.e. just obtained from getline()).
74 int getoff(const char *s) { return _bufoff+(int)(s-_buf); }
75 };
76
77 //------------------------------FileBuffRegion---------------------------------
78 // A buffer region is really a region of some file, specified as a linked list
79 // of offsets and lengths. These regions can be merged; overlapping regions
80 // will coalesce.
81 class FileBuffRegion {
82 public: // Workaround dev-studio friend/private bug
83 FileBuffRegion *_next; // Linked list of regions sorted by offset.
84 private:
85 FileBuff *_bfr; // The Buffer of the file
86 int _offset, _length; // The file area
87 int _sol; // Start of line where the file area starts
88 int _line; // First line of region
89
90 public:
|
51
52 int _err; // Error flag for file seek/read operations
53 long _filepos; // Current offset from start of file
54 int _linenum;
55
56 ArchDesc& _AD; // Reference to Architecture Description
57
58 // Error reporting function
59 void file_error(int flag, int linenum, const char *fmt, ...);
60
61 public:
62 const BufferedFile *_fp; // File to be buffered
63
64 FileBuff(BufferedFile *fp, ArchDesc& archDesc); // Constructor
65 ~FileBuff(); // Destructor
66
67 // This returns a pointer to the start of the current line in the buffer,
68 // and increments bufeol and filepos to point at the end of that line.
69 char *get_line(void);
70 int linenum() const { return _linenum; }
71 void set_linenum(int line) { _linenum = line; }
72
73 // This converts a pointer into the buffer to a file offset. It only works
74 // when the pointer is valid (i.e. just obtained from getline()).
75 int getoff(const char *s) { return _bufoff+(int)(s-_buf); }
76 };
77
78 //------------------------------FileBuffRegion---------------------------------
79 // A buffer region is really a region of some file, specified as a linked list
80 // of offsets and lengths. These regions can be merged; overlapping regions
81 // will coalesce.
82 class FileBuffRegion {
83 public: // Workaround dev-studio friend/private bug
84 FileBuffRegion *_next; // Linked list of regions sorted by offset.
85 private:
86 FileBuff *_bfr; // The Buffer of the file
87 int _offset, _length; // The file area
88 int _sol; // Start of line where the file area starts
89 int _line; // First line of region
90
91 public:
|