Serialbox  2.2.0
Data serialization library and tools for C/C++, Python and Fortran
serialbox::Slice Class Reference

Specification of the slice indices which is used for partial loading of serialized data. More...

#include <Slice.h>

Classes

struct  Empty
 

Public Member Functions

 Slice (int start=0, int stop=-1, int step=1) noexcept
 Initialize the slice of the first dimension. More...
 
 Slice (Empty)
 
 Slice (const Slice &)=default
 
 Slice (Slice &&)=default
 
Sliceoperator= (const Slice &)=default
 
Sliceoperator= (Slice &&)=default
 
Sliceoperator() (int start=0, int stop=-1, int step=1) noexcept
 Append a slice to the i-th dimension where i is the current size() of the sliceTriples vector. More...
 
bool empty () const noexcept
 Check if slice is empty.
 
void swap (Slice &other) noexcept
 Swap with other
 
std::vector< SliceTriple > & sliceTriples () noexcept
 Get slice triples.
 
const std::vector< SliceTriple > & sliceTriples () const noexcept
 

Detailed Description

Specification of the slice indices which is used for partial loading of serialized data.

The syntax follows closely the slicing syntax used in Python, the equivalent of [start1:stop1:step1, ... ,startN:stopN:stepN] is Slice(start1, stop1, step1) ... (startN, stopN, stepN) with one notable exception: The full dimension [:] is represented as Slice(0, -1) this means [:-1] corresponds to Slice(0, -2).

Consider the follwoing examples:

Python C++
[5] Slice(5, 6)
[:] Slice(0, -1, 1) or Slice()
[0:3, 0:3] Slice(0, 3)(0, 3)
[1:10:2] Slice(1, 10, 2)
[:, 1:5:2, 1:-2] Slice()(1, 5, 2)(1, -3)

Definition at line 53 of file Slice.h.

Constructor & Destructor Documentation

◆ Slice()

serialbox::Slice::Slice ( int  start = 0,
int  stop = -1,
int  step = 1 
)
inlinenoexcept

Initialize the slice of the first dimension.

The default arguments correspond to the full dimension (i.e no slicing in the first dimension).

The python equivalent would be [start:stop:step].

Parameters
startStarting index of the slice
stopStopping index of the slice (index stop is not included)
stepStep of the slice

Definition at line 67 of file Slice.h.

Member Function Documentation

◆ operator()()

Slice& serialbox::Slice::operator() ( int  start = 0,
int  stop = -1,
int  step = 1 
)
inlinenoexcept

Append a slice to the i-th dimension where i is the current size() of the sliceTriples vector.

The default arguments correspond to the full dimension (i.e no slicing in the i-th dimension).

The python equivalent would be [start:stop:step].

Parameters
startStarting index of the slice
stopStopping index of the slice (index stop is not included)
stepStep of the slice

Definition at line 91 of file Slice.h.


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