]>
git.saurik.com Git - apple/security.git/blob - libsecurity_codesigning/antlr2/src/InputBuffer.cpp
1 /* ANTLR Translator Generator
2 * Project led by Terence Parr at http://www.jGuru.com
3 * Software rights: http://www.antlr.org/license.html
5 * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/src/InputBuffer.cpp#2 $
8 #include "antlr/config.hpp"
9 #include "antlr/InputBuffer.hpp"
11 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
15 /** Ensure that the character buffer is sufficiently full */
16 void InputBuffer::fill(unsigned int amount
)
19 // Fill the buffer sufficiently to hold needed characters
20 while (queue
.entries() < amount
+ markerOffset
)
22 // Append the next character
23 queue
.append(getChar());
27 /** get the current lookahead characters as a string
28 * @warning it may treat 0 and EOF values wrong
30 ANTLR_USE_NAMESPACE(std
)string
InputBuffer::getLAChars( void ) const
32 ANTLR_USE_NAMESPACE(std
)string ret
;
34 for(unsigned int i
= markerOffset
; i
< queue
.entries(); i
++)
35 ret
+= queue
.elementAt(i
);
40 /** get the current marked characters as a string
41 * @warning it may treat 0 and EOF values wrong
43 ANTLR_USE_NAMESPACE(std
)string
InputBuffer::getMarkedChars( void ) const
45 ANTLR_USE_NAMESPACE(std
)string ret
;
47 for(unsigned int i
= 0; i
< markerOffset
; i
++)
48 ret
+= queue
.elementAt(i
);
53 /** Return an integer marker that can be used to rewind the buffer to
56 unsigned int InputBuffer::mark()
63 /** Rewind the character buffer to a marker.
64 * @param mark Marker returned previously from mark()
66 void InputBuffer::rewind(unsigned int mark
)
73 unsigned int InputBuffer::entries() const
75 //assert(queue.entries() >= markerOffset);
76 return (unsigned int)queue
.entries() - markerOffset
;
79 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE