Pegmatite
|
An Input that wraps a std::istream. More...
#include <parser.hh>
Public Member Functions | |
bool | fillBuffer (Index start, Index &length, char32_t *&) override |
Fill in the buffer with the next range. More... | |
Index | size () const override |
Returns the size of the buffer. | |
Public Member Functions inherited from pegmatite::Input | |
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 Member Functions | |
static StreamInput | Create (const std::string &name, std::istream &) |
Create a StreamInput from a std::istream. More... | |
Additional Inherited Members | |
Public Types inherited from pegmatite::Input | |
typedef size_t | Index |
The type of indexes into the buffer. | |
Static Public Attributes inherited from pegmatite::Input | |
static const Index | npos = static_cast<Index>(-1) |
Protected Member Functions inherited from pegmatite::Input | |
virtual | ~Input () |
Virtual destructor. | |
Input (const Input &) | |
Copy constructor. | |
Static Protected Attributes inherited from pegmatite::Input | |
static const std::size_t | static_buffer_size = 512 |
Size for the static buffer. More... | |
An Input that wraps a std::istream.
|
static |
Create a StreamInput from a std::istream.
The stream (which may start at any position) must be seekable. The StreamInput object will share the referenced std::istream, advancing its position until parsing is complete. Premature stream closure will cause parsing errors.
|
overridevirtual |
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.
Implements pegmatite::Input.