]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/TianoTools/Pccts/h/BufFileInput.cpp
1 // FILE: BufFileInput.cpp
2 // AUTHOR: Alexey Demakov (AVD) demakov@kazbek.ispras.ru
3 // CREATION: 26-JAN-1998
4 // DESCRIPTION: File Input Stream with lookahead for Scanner.
5 // See file BufFileInput.h for details
9 // 22-Jun-1998 assert.h -> PCCTS_ASSERT_H
10 // string.h -> PCCTS_STRING_H
12 // 28-May-1998 Add virtual destructor to release buffer.
14 // Add dummy definition for ANTLRTokenType
15 // to allow compilation without knowing
18 // Manfred Kogler (km@cast.uni-linz.ac.at)
21 // 20-Jul-1998 MR14a - Reorder initialization list for ctor.
24 enum ANTLRTokenType
{TER_HATES_CPP
=0, SO_DO_OTHERS
=9999 };
27 #include "pccts_assert.h"
28 #include "pccts_string.h"
32 #include "BufFileInput.h"
34 BufFileInput::BufFileInput( FILE *f
, int buf_size
)
36 buf( new int[buf_size
] ),
43 BufFileInput::~BufFileInput()
48 int BufFileInput::nextChar( void )
52 // get char from buffer
57 start
++; start
%= size
;
63 int c
= getc( input
);
67 // if EOF - put it in the buffer as indicator
75 int BufFileInput::lookahead( char* s
)
79 assert( 0 < l
&& l
<= size
);
83 int c
= getc( input
);
85 buf
[ (start
+len
) % size
] = c
;
89 if( c
== EOF
) return 0;
92 for( int i
= 0; i
< l
; i
++ )
94 if( s
[i
] != buf
[ (start
+i
) % size
] ) return 0;
99 // End of file BufFileInput.cpp