Serialbox  2.2.0
Data serialization library and tools for C/C++, Python and Fortran
serialbox::StorageViewIteratorBase< ValueType > Class Template Reference

Forward iterator to access the data of a StorageView. More...

#include <StorageViewIterator.h>

Public Types

Typedefs
using value_type = ValueType
 
using diffrence_type = std::ptrdiff_t
 
using pointer = value_type *
 
using refrence = value_type &
 
using iterator = StorageViewIteratorBase< ValueType >
 
using iterator_category = std::forward_iterator_tag
 

Public Member Functions

int bytesPerElement () noexcept
 Get bytes per element.
 
value_type * ptr () noexcept
 Get current data pointer.
 
template<class T >
match_cv_qualifier< value_type, T >::type & as () noexcept
 Interpret current data pointer as type ´T´
 
template<class T >
match_cv_qualifier< value_type, T >::type & as () const noexcept
 
const std::vector< int > & index () const noexcept
 Get current index position in the data.
 
Constructors
 StorageViewIteratorBase (const iterator &)=default
 Copy constructor.
 
 StorageViewIteratorBase (iterator &&)=default
 Move constructor.
 
 StorageViewIteratorBase (value_type *originPtr, int bytesPerElement, const std::vector< int > &dims, const std::vector< int > &strides, const Slice &slice, bool beginning)
 Construct iterator at specific location in the data. More...
 

Protected Member Functions

int computeCurrentIndex () const noexcept
 Compute the current linear index in the data according to the index vector.
 

Protected Attributes

value_type * curPtr_
 
std::vector< int > index_
 
bool end_
 
value_type * originPtr_
 
std::vector< int > dims_
 
std::vector< int > strides_
 
int bytesPerElement_
 
Slice slice_
 

Operators

iteratoroperator= (const iterator &)=default
 Copy assignment.
 
iteratoroperator= (iterator &&)=default
 Move assignment.
 
bool operator== (const iterator &right) const noexcept
 Test for equality.
 
bool operator!= (const iterator &right) const noexcept
 Test for inequality.
 
iteratoroperator++ () noexcept
 Pre-increment.
 
refrence operator* () noexcept
 Derefrence.
 
void swap (iterator &other) noexcept
 Swap with other.
 
std::ostream & operator<< (std::ostream &stream, const iterator &it)
 Convert to stream.
 

Detailed Description

template<class ValueType>
class serialbox::StorageViewIteratorBase< ValueType >

Forward iterator to access the data of a StorageView.

The data is accessed in column-major order using operator++ (pre-increment).

Definition at line 34 of file StorageViewIterator.h.

Constructor & Destructor Documentation

◆ StorageViewIteratorBase()

template<class ValueType>
serialbox::StorageViewIteratorBase< ValueType >::StorageViewIteratorBase ( value_type *  originPtr,
int  bytesPerElement,
const std::vector< int > &  dims,
const std::vector< int > &  strides,
const Slice slice,
bool  beginning 
)
inline

Construct iterator at specific location in the data.

Parameters
originPtrOrigin pointer of the associated StorageView
bytesPerElementNumber of bytes of the underlying data-type
dimsVector of dimensions
stridesVector of strides
sliceSlice of the data
beginningIndicate whether the iterator has reached the end

Definition at line 64 of file StorageViewIterator.h.


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