Pegmatite
|
Abstract superclass for indexing into a buffer with arbitrary storage. More...
#include <parser.hh>
Classes | |
class | iterator |
Iterator, refers back into the input stream. More... | |
Public Types | |
typedef size_t | Index |
The type of indexes into the buffer. | |
Public Member Functions | |
iterator | begin () |
Returns an iterator for the start of the input. | |
iterator | end () |
Returns an iterator for the end of the input. | |
const std::string & | name () const |
Returns a user-meaningful name (typically a filename). | |
char32_t | operator[] (Index n) |
Fetch the character at the specified index. More... | |
Input (const std::string &name) | |
Default constructor, sets the buffer start to be after the buffer end, so that the first request will trigger a fetch from the underlying storage. More... | |
Static Public Attributes | |
static const Index | npos = static_cast<Index>(-1) |
Protected Member Functions | |
virtual bool | fillBuffer (Index start, Index &length, char32_t *&b)=0 |
Fill in the buffer with the next range. More... | |
virtual Index | size () const =0 |
Returns the size of the buffer. | |
virtual | ~Input () |
Virtual destructor. | |
Input (const Input &) | |
Copy constructor. | |
Static Protected Attributes | |
static const std::size_t | static_buffer_size = 512 |
Size for the static buffer. More... | |
Abstract superclass for indexing into a buffer with arbitrary storage.
The class holds a private buffer of characters and requests that the subclass fill it in, or provide direct access to the underlying storage if it is in the correct format.
|
inline |
Default constructor, sets the buffer start to be after the buffer end, so that the first request will trigger a fetch from the underlying storage.
name | user-meaningful input name (typically a filename) |
|
protectedpure virtual |
Fill in the buffer with the next range.
This is called when the current cached buffer does not contain the range. The function returns true if it can provide at least one character from the index specified by start. The length of the buffer passed in via the last parameter is provided as the second argument.
Implementations of this function may either fill in the provided buffer, reducing the value passed by the second parameter if there are not enough characters available to satisfy it, or set the third parameter to refer to their underlying storage.
Implemented in pegmatite::IteratorInput< T >, pegmatite::StringInput, pegmatite::StreamInput, pegmatite::AsciiFileInput, and pegmatite::UnicodeVectorInput.
|
inline |
Fetch the character at the specified index.
This is intended to be inlined and returns the character from the cached buffer if possible, falling back to the (non-inlined) slow path if not.
|
staticprotected |
Size for the static buffer.
Note that changing this will change the ABI, so do not change it in shared library builds!