16 #ifndef SERIALBOX_CORE_STORAGEVIEW_H 17 #define SERIALBOX_CORE_STORAGEVIEW_H 40 const std::vector<int>&
strides);
43 StorageView(
void* originPtr,
TypeID type, std::vector<int>&& dims, std::vector<int>&& strides);
78 return (T*)(originPtr_);
82 return (T*)(originPtr_);
96 const std::vector<int>&
dims() const noexcept {
return dims_; }
99 const std::vector<int>&
strides() const noexcept {
return strides_; }
137 std::size_t
size()
const noexcept;
145 std::vector<int> dims_;
146 std::vector<int> strides_;
Byte * originPtr() noexcept
Get raw data pointer.
friend std::ostream & operator<<(std::ostream &stream, const StorageView &s)
Convert to stream.
std::size_t sizeInBytes() const noexcept
Size of the allocated, sliced data (without padding) in Bytes.
T * originPtrAs() noexcept
Get data pointer as type T of the origin of the data.
static int sizeOf(TypeID id)
Get size of the type.
Represent a mutable view to a multi-dimensional storage.
bool operator!=(const StorageView &right) const noexcept
Test for inequality.
void setSlice(Slice slice)
Set the slice of the StorageView
TypeID type() const noexcept
Get type.
Namespace of the serialbox library.
TypeID
Type-id of types recognized by serialbox.
char Byte
Represent a byte i.e sizeof(Byte) == 1.
StorageView & operator=(const StorageView &other)=default
Copy assignment.
const std::vector< int > & dims() const noexcept
Get dimensions.
Non-mutable forward iterator to access the data of a StorageView.
Slice & getSlice() noexcept
Get the slice of the StorageView
bool isMemCopyable() const noexcept
Return true if the storage is contiguous in memory (i.e no padding) and is column-major ordered...
StorageViewIterator end() noexcept
Iterator to the end of the data.
std::size_t size() const noexcept
Size of the allocated, sliced data (without padding)
StorageViewIterator begin() noexcept
Iterator to the beginning of the data.
const std::vector< int > & strides() const noexcept
Get strides.
StorageView(void *originPtr, TypeID type, const std::vector< int > &dims, const std::vector< int > &strides)
Construct StorageView.
bool operator==(const StorageView &right) const noexcept
Test for equality.
Specification of the slice indices which is used for partial loading of serialized data...
void swap(StorageView &other) noexcept
Swap with other.
Mutable forward iterator to access the data of a StorageView.
int bytesPerElement() const noexcept
Get bytes per element.