source: trunk/gsdl/src/mgpp/text/FileBuf.h@ 2468

Last change on this file since 2468 was 2468, checked in by sjboddie, 23 years ago

Fiddled about with mgpp to get it compiling on Windows under VC++ 6.0. I
still can't get it to compile under VC++ 4.2 because of some weird
behaviour in STLport.

Also tidied up a little and removed some of the old log information
that was scattered about in some of the files.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.6 KB
Line 
1/**************************************************************************
2 *
3 * FileBuf.h -- File buffer
4 * Copyright (C) 1999 Rodger McNab
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 **************************************************************************/
21
22#ifndef FILEBUF_H
23#define FILEBUF_H
24
25#define FILEBUFSIZE 65536
26
27
28class FileBuf {
29protected:
30 unsigned char buf[FILEBUFSIZE];
31 unsigned char *here;
32 unsigned char *end;
33
34 int fd;
35
36 // gets a new buffer if need be, returns true if
37 // more could be got. if true is returned the caller
38 // can assume that here != end
39 bool NextBuf ();
40
41public:
42 FileBuf ();
43
44 void SetFD (int _fd);
45
46 inline bool Get (unsigned char &c) {
47 if (here != end || NextBuf()) { c = *here++; return true; }
48 return false;
49 }
50
51 inline bool Peek (unsigned char &c) {
52 if (here != end || NextBuf()) { c = *here; return true; }
53 return false;
54 }
55
56 inline bool Next () {
57 if (here != end || NextBuf()) { here++; return true; }
58 return false;
59 }
60};
61
62
63#endif
Note: See TracBrowser for help on using the repository browser.