1 /* |
1 /* |
2 * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. |
2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
70 int linenum() const { return _linenum; } |
71 int linenum() const { return _linenum; } |
71 void set_linenum(int line) { _linenum = line; } |
72 void set_linenum(int line) { _linenum = line; } |
72 |
73 |
73 // This converts a pointer into the buffer to a file offset. It only works |
74 // 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 // when the pointer is valid (i.e. just obtained from getline()). |
75 int getoff(const char *s) { return _bufoff+(int)(s-_buf); } |
76 long getoff(const char* s) { return _bufoff + (s - _buf); } |
76 }; |
77 }; |
77 |
78 |
78 //------------------------------FileBuffRegion--------------------------------- |
79 //------------------------------FileBuffRegion--------------------------------- |
79 // A buffer region is really a region of some file, specified as a linked list |
80 // 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 // of offsets and lengths. These regions can be merged; overlapping regions |
93 ~FileBuffRegion(); |
94 ~FileBuffRegion(); |
94 |
95 |
95 FileBuffRegion *copy(); // Deep copy |
96 FileBuffRegion *copy(); // Deep copy |
96 FileBuffRegion *merge(FileBuffRegion*); // Merge 2 regions; delete input |
97 FileBuffRegion *merge(FileBuffRegion*); // Merge 2 regions; delete input |
97 |
98 |
98 // void print(std::ostream&); |
|
99 // friend std::ostream& operator<< (std::ostream&, FileBuffRegion&); |
|
100 void print(ostream&); |
99 void print(ostream&); |
101 friend ostream& operator<< (ostream&, FileBuffRegion&); |
100 friend ostream& operator<< (ostream&, FileBuffRegion&); |
102 }; |
101 }; |