HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Data Structures | Public Types | Public Member Functions | Static Public Attributes
hi::v1::lookahead_iterator< LookaheadCount, It, ItEnd > Class Template Reference

#include <hikogui/parser/lookahead_iterator.hpp>

Data Structures

class  proxy
 

Public Types

using value_type = std::iterator_traits<It>::value_type
 
using reference = value_type const &
 
using pointer = value_type const *
 
using difference_type = std::ptrdiff_t
 
using iterator_category = std::forward_iterator_tag
 

Public Member Functions

constexpr lookahead_iterator (lookahead_iterator const &) noexcept=delete
 
constexpr lookahead_iterator (lookahead_iterator &&) noexcept=default
 
constexpr lookahead_iteratoroperator= (lookahead_iterator const &) noexcept=delete
 
constexpr lookahead_iteratoroperator= (lookahead_iterator &&) noexcept=default
 
constexpr lookahead_iterator (It first, ItEnd last) noexcept
 
constexpr size_t size () const noexcept
 The number of entries can be looked ahead.
 
constexpr bool empty () const noexcept
 Check if the iterator is at end.
 
constexpr operator bool () const noexcept
 
constexpr bool operator== (std::default_sentinel_t) const noexcept
 
constexpr reference operator[] (size_t i) const noexcept
 Get a reference to an item at or beyond the iterator.
 
constexpr reference at (size_t i) const
 Get a reference to an item at or beyond the iterator.
 
constexpr std::optional< value_type > next (size_t i=1) const noexcept
 Get a reference to an item at or beyond the iterator.
 
constexpr reference operator* () const noexcept
 Get a reference to the value at the iterator.
 
constexpr pointer operator-> () const noexcept
 Get a pointer to the value at the iterator.
 
constexpr lookahead_iteratoroperator++ () noexcept
 Increment the iterator.
 
constexpr lookahead_iteratoroperator+= (size_t n) noexcept
 
constexpr proxy operator++ (int) noexcept
 

Static Public Attributes

static constexpr size_t max_size = LookaheadCount
 

Detailed Description

template<size_t LookaheadCount, typename It, std::sentinel_for< It > ItEnd = std::default_sentinel_t>
class hi::v1::lookahead_iterator< LookaheadCount, It, ItEnd >

Lookahead iterator.

This iterator adapter takes a forward input iterator and adapts it so that you can look ahead beyond the current position of the iterator. This is useful when writing a parser.

Member Function Documentation

◆ at()

template<size_t LookaheadCount, typename It , std::sentinel_for< It > ItEnd = std::default_sentinel_t>
constexpr reference hi::v1::lookahead_iterator< LookaheadCount, It, ItEnd >::at ( size_t i) const
inlineconstexpr

Get a reference to an item at or beyond the iterator.

Parameters
iIndex to lookahead, 0 means the current iterator, larger than zero is lookahead.
Exceptions
std::out_of_rangewhen index beyond the lookahead buffer.
Returns
A reference to the item.

◆ empty()

template<size_t LookaheadCount, typename It , std::sentinel_for< It > ItEnd = std::default_sentinel_t>
constexpr bool hi::v1::lookahead_iterator< LookaheadCount, It, ItEnd >::empty ( ) const
inlineconstexprnoexcept

Check if the iterator is at end.

Return values
trueIterator at end.

◆ next()

template<size_t LookaheadCount, typename It , std::sentinel_for< It > ItEnd = std::default_sentinel_t>
constexpr std::optional< value_type > hi::v1::lookahead_iterator< LookaheadCount, It, ItEnd >::next ( size_t i = 1) const
inlineconstexprnoexcept

Get a reference to an item at or beyond the iterator.

Parameters
iIndex to lookahead, 0 means the current iterator, larger than zero is lookahead.
Return values
std::nulloptWhen the index points beyond the lookahead buffer.
Returns
A reference to the item.

◆ operator*()

template<size_t LookaheadCount, typename It , std::sentinel_for< It > ItEnd = std::default_sentinel_t>
constexpr reference hi::v1::lookahead_iterator< LookaheadCount, It, ItEnd >::operator* ( ) const
inlineconstexprnoexcept

Get a reference to the value at the iterator.

◆ operator++()

template<size_t LookaheadCount, typename It , std::sentinel_for< It > ItEnd = std::default_sentinel_t>
constexpr lookahead_iterator & hi::v1::lookahead_iterator< LookaheadCount, It, ItEnd >::operator++ ( )
inlineconstexprnoexcept

Increment the iterator.

◆ operator->()

template<size_t LookaheadCount, typename It , std::sentinel_for< It > ItEnd = std::default_sentinel_t>
constexpr pointer hi::v1::lookahead_iterator< LookaheadCount, It, ItEnd >::operator-> ( ) const
inlineconstexprnoexcept

Get a pointer to the value at the iterator.

◆ operator[]()

template<size_t LookaheadCount, typename It , std::sentinel_for< It > ItEnd = std::default_sentinel_t>
constexpr reference hi::v1::lookahead_iterator< LookaheadCount, It, ItEnd >::operator[] ( size_t i) const
inlineconstexprnoexcept

Get a reference to an item at or beyond the iterator.

Parameters
iIndex to lookahead, 0 means the current iterator, larger than zero is lookahead.
Returns
A reference to the item.

◆ size()

template<size_t LookaheadCount, typename It , std::sentinel_for< It > ItEnd = std::default_sentinel_t>
constexpr size_t hi::v1::lookahead_iterator< LookaheadCount, It, ItEnd >::size ( ) const
inlineconstexprnoexcept

The number of entries can be looked ahead.

Returns
Number of entries that can be looked ahead, including the current entry.

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