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

#include <hikogui/lookahead_iterator.hpp>

Public Types

using iterator = Iterator
 
using value_type = iterator_type::value_type
 
using reference = iterator_type::reference
 
using const_reference = iterator_type::const_reference
 
using pointer = iterator_type::pointer
 
using const_pointer = iterator_type::const_pointer
 

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 (forward_of< Iterator > auto &&it) 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 &) const noexcept
 
const_reference operator[] (size_t i) const noexcept
 Get a reference to an item at or beyond the iterator.
 
const_reference at (size_t i) const
 Get a reference to an item at or beyond the iterator.
 
std::optional< value_type > next (size_t i=1) const noexcept
 Get a reference to an item at or beyond the iterator.
 
const_reference operator* () const noexcept
 Get a reference to the value at the iterator.
 
const_pointer operator-> () const noexcept
 Get a pointer to the value at the iterator.
 
lookahead_iteratoroperator++ () noexcept
 Increment the iterator.
 

Static Public Attributes

static constexpr size_t max_size = LookaheadCount + 1
 

Detailed Description

template<size_t LookaheadCount, typename Iterator>
class hi::v1::lookahead_iterator< LookaheadCount, Iterator >

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 Iterator >
const_reference hi::v1::lookahead_iterator< LookaheadCount, Iterator >::at ( size_t i) const
inline

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 Iterator >
constexpr bool hi::v1::lookahead_iterator< LookaheadCount, Iterator >::empty ( ) const
inlineconstexprnoexcept

Check if the iterator is at end.

Return values
trueIterator at end.

◆ next()

template<size_t LookaheadCount, typename Iterator >
std::optional< value_type > hi::v1::lookahead_iterator< LookaheadCount, Iterator >::next ( size_t i = 1) const
inlinenoexcept

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 Iterator >
const_reference hi::v1::lookahead_iterator< LookaheadCount, Iterator >::operator* ( ) const
inlinenoexcept

Get a reference to the value at the iterator.

◆ operator++()

template<size_t LookaheadCount, typename Iterator >
lookahead_iterator & hi::v1::lookahead_iterator< LookaheadCount, Iterator >::operator++ ( )
inlinenoexcept

Increment the iterator.

◆ operator->()

template<size_t LookaheadCount, typename Iterator >
const_pointer hi::v1::lookahead_iterator< LookaheadCount, Iterator >::operator-> ( ) const
inlinenoexcept

Get a pointer to the value at the iterator.

◆ operator[]()

template<size_t LookaheadCount, typename Iterator >
const_reference hi::v1::lookahead_iterator< LookaheadCount, Iterator >::operator[] ( size_t i) const
inlinenoexcept

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 Iterator >
constexpr size_t hi::v1::lookahead_iterator< LookaheadCount, Iterator >::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: