P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::Util::AsEnumerator< T, S > Class Template Referencefinal

Casts each element. More...

#include <enumerator.h>

Inheritance diagram for P4::Util::AsEnumerator< T, S >:
[legend]

Public Member Functions

 AsEnumerator (Enumerator< T > *input)
 
getCurrent () const override
 Get current element in the collection.
 
bool moveNext () override
 
void reset () override
 Move back to the beginning of the collection.
 
std::string toString () const
 
- Public Member Functions inherited from P4::Util::Enumerator< S >
bool any ()
 True if the enumerator has at least one element.
 
Enumerator< S > * as ()
 Cast to an enumerator of S objects.
 
EnumeratorHandle< S > begin ()
 
virtual Enumerator< S > * concat (Enumerator< S > *other)
 Append all elements of other after all elements of this.
 
uint64_t count ()
 Enumerate all elements and return the count.
 
EnumeratorHandle< S > end ()
 
Enumerator< std::invoke_result_t< Mapper, S > > * map (Mapper map)
 Apply specified function to all elements of this enumerator.
 
next ()
 Next element; throws if there are no elements.
 
nextOrDefault ()
 Next element, or the default value if none exists.
 
single ()
 The only next element; throws if the enumerator does not have exactly 1 element.
 
singleOrDefault ()
 
const char * stateName () const
 
std::vector< S > toVector ()
 
Enumerator< S > * where (Filter filter)
 Return an enumerator returning all elements that pass the filter.
 

Protected Attributes

Enumerator< T > * input
 
- Protected Attributes inherited from P4::Util::Enumerator< S >
EnumeratorState state
 

Additional Inherited Members

- Public Types inherited from P4::Util::Enumerator< S >
using value_type
 
- Static Public Member Functions inherited from P4::Util::Enumerator< S >
static Enumerator< S > * concatAll (Enumerator< Enumerator< S > * > *inputs)
 Concatenate all these collections into a single one.
 
static Enumerator< typename Container::value_type > * createEnumerator (const Container &data)
 
static Enumerator< typename Iter::value_type > * createEnumerator (Iter begin, Iter end)
 
static Enumerator< typename Iter::value_type > * createEnumerator (iterator_range< Iter > range)
 
static Enumerator< S > * emptyEnumerator ()
 
- Static Protected Attributes inherited from P4::Util::Enumerator< S >
static std::vector< S > emptyVector
 

Detailed Description

template<typename T, typename S>
class P4::Util::AsEnumerator< T, S >

Casts each element.

Member Function Documentation

◆ getCurrent()

template<typename T , typename S >
S P4::Util::AsEnumerator< T, S >::getCurrent ( ) const
inlineoverridevirtual

Get current element in the collection.

Implements P4::Util::Enumerator< S >.

◆ moveNext()

template<typename T , typename S >
bool P4::Util::AsEnumerator< T, S >::moveNext ( )
inlineoverridevirtual

Move to next element in the collection; return false if the next element does not exist

Implements P4::Util::Enumerator< S >.

◆ reset()

template<typename T , typename S >
void P4::Util::AsEnumerator< T, S >::reset ( )
inlineoverridevirtual

Move back to the beginning of the collection.

Reimplemented from P4::Util::Enumerator< S >.