OpenMD 3.0
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
antlr::CharInputBuffer Class Reference

CharInputBuffer.hpp provides an InputBuffer for plain character arrays (buffers). More...

#include <CharInputBuffer.hpp>

+ Inheritance diagram for antlr::CharInputBuffer:

Public Member Functions

 CharInputBuffer (unsigned char *buf, size_t size, bool owner=false)
 Construct a CharInputBuffer.hpp object with a char* buffer of 'size' if 'owner' is true, then the buffer will be delete[]-ed on destruction.
 
 ~CharInputBuffer (void)
 Destructor.
 
virtual void reset (void)
 Reset the CharInputBuffer to initial state Called from LexerInputState::reset.
 
virtual int getChar (void)
 Override this in subclasses to get the next character.
 
- Public Member Functions inherited from antlr::InputBuffer
 InputBuffer ()
 Create a character buffer.
 
void commit (void)
 This method updates the state of the input buffer so that the text matched since the most recent mark() is no longer held by the buffer.
 
virtual void consume ()
 Mark another character for deferred consumption.
 
virtual void fill (unsigned int amount)
 Ensure that the character buffer is sufficiently full.
 
virtual int LA (unsigned int i)
 Get a lookahead character.
 
virtual unsigned int mark ()
 Return an integer marker that can be used to rewind the buffer to its current state.
 
virtual bool isMarked () const
 Are there any marks active in the InputBuffer.
 
virtual void rewind (unsigned int mark)
 Rewind the character buffer to a marker.
 
virtual unsigned int entries () const
 Get the number of non-consumed characters.
 
std::string getLAChars () const
 get the current lookahead characters as a string
 
std::string getMarkedChars () const
 get the current marked characters as a string
 

Protected Attributes

unsigned char * buffer
 the buffer with data
 
unsigned char * ptr
 position ptr into the buffer
 
unsigned char * end
 end sentry for buffer
 
bool delete_buffer
 flag signifying if we have to delete the buffer
 
- Protected Attributes inherited from antlr::InputBuffer
unsigned int nMarkers
 
unsigned int markerOffset
 
unsigned int numToConsume
 
CircularQueue< int > queue
 

Additional Inherited Members

- Protected Member Functions inherited from antlr::InputBuffer
void syncConsume ()
 Sync up deferred consumption.
 

Detailed Description

CharInputBuffer.hpp provides an InputBuffer for plain character arrays (buffers).

Definition at line 26 of file CharInputBuffer.hpp.

Constructor & Destructor Documentation

◆ CharInputBuffer()

antlr::CharInputBuffer::CharInputBuffer ( unsigned char * buf,
size_t size,
bool owner = false )
inline

Construct a CharInputBuffer.hpp object with a char* buffer of 'size' if 'owner' is true, then the buffer will be delete[]-ed on destruction.

Note
it is assumed the buffer was allocated with new[]!

Definition at line 33 of file CharInputBuffer.hpp.

◆ ~CharInputBuffer()

antlr::CharInputBuffer::~CharInputBuffer ( void )
inline

Destructor.

Note
If you're using malloced data, then you probably need to change this destructor. Or better use this class as template for your own.

Definition at line 45 of file CharInputBuffer.hpp.

References buffer, and delete_buffer.

Member Function Documentation

◆ getChar()

virtual int antlr::CharInputBuffer::getChar ( void )
inlinevirtual

Override this in subclasses to get the next character.

Implements antlr::InputBuffer.

Definition at line 61 of file CharInputBuffer.hpp.

References end, and ptr.

◆ reset()

virtual void antlr::CharInputBuffer::reset ( void )
inlinevirtual

Reset the CharInputBuffer to initial state Called from LexerInputState::reset.

See also
LexerInputState

Reimplemented from antlr::InputBuffer.

Definition at line 55 of file CharInputBuffer.hpp.

References buffer, ptr, and antlr::InputBuffer::reset().

Member Data Documentation

◆ buffer

unsigned char* antlr::CharInputBuffer::buffer
protected

the buffer with data

Definition at line 67 of file CharInputBuffer.hpp.

Referenced by reset(), and ~CharInputBuffer().

◆ delete_buffer

bool antlr::CharInputBuffer::delete_buffer
protected

flag signifying if we have to delete the buffer

Definition at line 70 of file CharInputBuffer.hpp.

Referenced by ~CharInputBuffer().

◆ end

unsigned char* antlr::CharInputBuffer::end
protected

end sentry for buffer

Definition at line 69 of file CharInputBuffer.hpp.

Referenced by getChar().

◆ ptr

unsigned char* antlr::CharInputBuffer::ptr
protected

position ptr into the buffer

Definition at line 68 of file CharInputBuffer.hpp.

Referenced by getChar(), and reset().


The documentation for this class was generated from the following file: