Pegmatite
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Attributes | List of all members
pegmatite::Input Class Referenceabstract

Abstract superclass for indexing into a buffer with arbitrary storage. More...

#include <parser.hh>

Inheritance diagram for pegmatite::Input:
pegmatite::AsciiFileInput pegmatite::IteratorInput< T > pegmatite::StreamInput pegmatite::StringInput pegmatite::UnicodeVectorInput

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

pegmatite::Input::Input ( const std::string &  name)
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.

Parameters
nameuser-meaningful input name (typically a filename)

Member Function Documentation

virtual bool pegmatite::Input::fillBuffer ( Index  start,
Index length,
char32_t *&  b 
)
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.

char32_t pegmatite::Input::operator[] ( Index  n)
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.

Member Data Documentation

const std::size_t pegmatite::Input::static_buffer_size = 512
staticprotected

Size for the static buffer.

Note that changing this will change the ABI, so do not change it in shared library builds!


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