HighFive 2.9.0
HighFive - Header-only C++ HDF5 interface
Loading...
Searching...
No Matches
HighFive::DataSpace Class Reference

Class representing the space (dimensions) of a DataSet. More...

#include <H5DataSpace.hpp>

Inheritance diagram for HighFive::DataSpace:
Collaboration diagram for HighFive::DataSpace:

Public Types

enum  DataspaceType { dataspace_scalar , dataspace_null }
 An enum to create scalar and null DataSpace with DataSpace::DataSpace(DataspaceType dtype). More...
 

Public Member Functions

 DataSpace (const std::vector< size_t > &dims)
 Create a DataSpace of N-dimensions from a std::vector<size_t>.
 
template<size_t N>
 DataSpace (const std::array< size_t, N > &dims)
 Create a DataSpace of N-dimensions from a std::array<size_t, N>.
 
 DataSpace (const std::initializer_list< size_t > &dims)
 Create a DataSpace of N-dimensions from an initializer list.
 
template<typename... Args>
 DataSpace (size_t dim1, Args... dims)
 Create a DataSpace of N-dimensions from direct values.
 
template<typename IT , typename = typename std::enable_if<!std::is_integral<IT>::value, IT>::type>
 DataSpace (const IT begin, const IT end)
 Create a DataSpace from a pair of iterators.
 
 DataSpace (const std::vector< size_t > &dims, const std::vector< size_t > &maxdims)
 Create a resizable N-dimensional DataSpace.
 
 DataSpace (DataspaceType space_type)
 Create a scalar or a null DataSpace.
 
DataSpace clone () const
 Create a copy of the DataSpace which will have different id.
 
size_t getNumberDimensions () const
 Returns the number of dimensions of a DataSpace.
 
std::vector< size_t > getDimensions () const
 Returns the size of the dataset in each dimension.
 
size_t getElementCount () const
 Return the number of elements in this DataSpace.
 
std::vector< size_t > getMaxDimensions () const
 Returns the maximum size of the dataset in each dimension.
 
- Public Member Functions inherited from HighFive::Object
 Object (Object &&other) noexcept
 
 ~Object ()
 
bool isValid () const noexcept
 isValid
 
hid_t getId () const noexcept
 getId
 
ObjectInfo getInfo () const
 Retrieve several infos about the current object (address, dates, etc)
 
ObjectType getType () const
 Gets the fundamental type of the object (dataset, group, etc)
 
bool operator== (const Object &other) const noexcept
 

Static Public Member Functions

static DataSpace Scalar ()
 Create a scalar DataSpace.
 
static DataSpace Null ()
 Create a null DataSpace.
 
template<typename T >
static DataSpace From (const T &value)
 Automatically deduce the DataSpace from a container/value.
 
template<std::size_t N, std::size_t Width>
static DataSpace FromCharArrayStrings (const char(&string_array)[N][Width])
 Create a DataSpace from a value of type string array.
 

Static Public Attributes

static const ObjectType type = ObjectType::DataSpace
 
static const size_t UNLIMITED = SIZE_MAX
 Magic value to specify that a DataSpace can grow without limit.
 

Protected Member Functions

 DataSpace ()=default
 
- Protected Member Functions inherited from HighFive::Object
 Object ()
 
 Object (const Object &other)
 
 Object (hid_t)
 
Objectoperator= (const Object &other)
 

Friends

class Attribute
 
class File
 
class DataSet
 

Additional Inherited Members

- Protected Attributes inherited from HighFive::Object
hid_t _hid
 

Detailed Description

Class representing the space (dimensions) of a DataSet.

// Create a DataSpace of dimension 1 x 2 x 3
DataSpace dspace(1, 2, 3);
std::cout << dspace.getElementCount() << std::endl; // Print 1 * 2 * 3 = 6
std::cout << dspace.getNumberDimensions() << std::endl; // Print 3
std::vector<size_t> dims = dspace.getDimensions(); // dims is {1, 2, 3}
Class representing the space (dimensions) of a DataSet.
Definition H5DataSpace.hpp:31

Member Enumeration Documentation

◆ DataspaceType

An enum to create scalar and null DataSpace with DataSpace::DataSpace(DataspaceType dtype).

This enum is needed otherwise we will not be able to distringuish between both with normal constructors. Both have a dimension of 0.

Since
1.3
Enumerator
dataspace_scalar 

Value to create scalar DataSpace.

dataspace_null 

Value to create null DataSpace.

Constructor & Destructor Documentation

◆ DataSpace() [1/8]

HighFive::DataSpace::DataSpace ( const std::vector< size_t > & dims)
inlineexplicit

Create a DataSpace of N-dimensions from a std::vector<size_t>.

Parameters
dimsDimensions of the new DataSpace
// Create a DataSpace with 2 dimensions: 1 and 3
DataSpace(std::vector<size_t>{1, 3});
Since
1.0

◆ DataSpace() [2/8]

template<size_t N>
HighFive::DataSpace::DataSpace ( const std::array< size_t, N > & dims)
inlineexplicit

Create a DataSpace of N-dimensions from a std::array<size_t, N>.

Parameters
dimsDimensions of the new DataSpace
// Create a DataSpace with 2 dimensions: 1 and 3
DataSpace(std::array<size_t, 2>{1, 3});
Since
2.3

◆ DataSpace() [3/8]

HighFive::DataSpace::DataSpace ( const std::initializer_list< size_t > & dims)
inline

Create a DataSpace of N-dimensions from an initializer list.

Parameters
dimsDimensions of the new DataSpace
// Create a DataSpace with 2 dimensions: 1 and 3
DataSpace{1, 3};
Since
2.1

◆ DataSpace() [4/8]

template<typename... Args>
HighFive::DataSpace::DataSpace ( size_t dim1,
Args... dims )
inlineexplicit

Create a DataSpace of N-dimensions from direct values.

Parameters
dim1The first dimension
dimsThe following dimensions
// Create a DataSpace with 2 dimensions: 1 and 3
DataSpace(1, 3);
Since
2.1

◆ DataSpace() [5/8]

template<class IT , typename >
HighFive::DataSpace::DataSpace ( const IT begin,
const IT end )
inline

Create a DataSpace from a pair of iterators.

Parameters
beginThe beginning of the container
endThe end of the container
// Create a DataSpace with 2 dimensions: 1 and 3
std::vector<int> v{1, 3};
DataSpace(v.begin(), v.end());
Since
2.0

◆ DataSpace() [6/8]

HighFive::DataSpace::DataSpace ( const std::vector< size_t > & dims,
const std::vector< size_t > & maxdims )
inlineexplicit

Create a resizable N-dimensional DataSpace.

Parameters
dimsInitial size of dataspace
maxdimsMaximum size of the dataspace
// Create a DataSpace with 2 dimensions: 1 and 3.
// It can later be resized up to a maximum of 10 x 10
DataSpace(std::vector<size_t>{1, 3}, std::vector<size_t>{10, 10});
See also
UNLIMITED for a DataSpace that can be resized without limit.
Since
2.0

◆ DataSpace() [7/8]

HighFive::DataSpace::DataSpace ( DataSpace::DataspaceType space_type)
inlineexplicit

Create a scalar or a null DataSpace.

This overload enables creating scalar or null data spaces, both have dimension 0.

Parameters
space_typeThe value from the enum
@ dataspace_scalar
Value to create scalar DataSpace.
Definition H5DataSpace.hpp:49
Attention
Avoid braced intialization in these cases, i.e.
// This is not a scalar dataset:
Since
1.3

◆ DataSpace() [8/8]

HighFive::DataSpace::DataSpace ( )
protecteddefault

Member Function Documentation

◆ clone()

DataSpace HighFive::DataSpace::clone ( ) const
inline

Create a copy of the DataSpace which will have different id.

DataSpace dspace1(1, 3);
auto dspace2 = dspace.clone();
Since
1.0

◆ From()

template<typename T >
DataSpace HighFive::DataSpace::From ( const T & value)
inlinestatic

Automatically deduce the DataSpace from a container/value.

Certain containers and scalar values are fully supported by HighFive. For these containers, HighFive can deduce the dimensions from value.

double d = 42.0;
std::vector<std::vector<int>> v = {{4, 5, 6}, {7, 8, 9}};
DataSpace::From(v); // A DataSpace of dimensions 2, 3.
DataSpace::From(d); // A scalar dataspace.
static DataSpace From(const T &value)
Automatically deduce the DataSpace from a container/value.
Definition H5Dataspace_misc.hpp:122
Since
1.0

◆ FromCharArrayStrings()

template<std::size_t N, std::size_t Width>
DataSpace HighFive::DataSpace::FromCharArrayStrings ( const char(&) string_array[N][Width])
inlinestatic

Create a DataSpace from a value of type string array.

Parameters
string_arrayAn C-array of C-string (null-terminated).
char string_array[2][10] = {"123456789", "abcdefghi"};
auto dspace = DataSpace::FromCharArrayStrings(string_array); // dspace is a DataSpace of
dimensions 2
static DataSpace FromCharArrayStrings(const char(&string_array)[N][Width])
Create a DataSpace from a value of type string array.
Definition H5Dataspace_misc.hpp:128
Since
2.2

◆ getDimensions()

std::vector< size_t > HighFive::DataSpace::getDimensions ( ) const
inline

Returns the size of the dataset in each dimension.

For zero-dimensional datasets (e.g. scalar or null datasets) an empty vector is returned.

DataSpace dspace(1, 3);
auto dims = dspace.getDimensions(); // returns {1, 3}
See also
DataSpace::getMaxDimensions
Since
1.0

◆ getElementCount()

size_t HighFive::DataSpace::getElementCount ( ) const
inline

Return the number of elements in this DataSpace.

DataSpace dspace(1, 3);
size_t elementcount = dspace.getElementCount(); // return 1 x 3 = 3
Since
2.1

◆ getMaxDimensions()

std::vector< size_t > HighFive::DataSpace::getMaxDimensions ( ) const
inline

Returns the maximum size of the dataset in each dimension.

This is the maximum size a dataset can be extended to, which may be different from the current size of the dataset.

DataSpace dspace(std::vector<size_t>{1, 3}, std::vector<size_t>{UNLIMITED, 10});
dspace.getMaxDimensions(); // Return {UNLIMITED, 10}
std::vector< size_t > getMaxDimensions() const
Returns the maximum size of the dataset in each dimension.
Definition H5Dataspace_misc.hpp:110
static const size_t UNLIMITED
Magic value to specify that a DataSpace can grow without limit.
Definition H5DataSpace.hpp:41
See also
DataSpace::getDimensions
Since
2.0

◆ getNumberDimensions()

size_t HighFive::DataSpace::getNumberDimensions ( ) const
inline

Returns the number of dimensions of a DataSpace.

DataSpace dspace(1, 3);
size_t number_of_dim = dspace.getNumberDimensions(); // returns 2
Since
1.0

◆ Null()

DataSpace HighFive::DataSpace::Null ( )
inlinestatic

Create a null DataSpace.

auto dataspace = DataSpace::Null();
static DataSpace Null()
Create a null DataSpace.
Definition H5Dataspace_misc.hpp:49
Since
2.9

◆ Scalar()

DataSpace HighFive::DataSpace::Scalar ( )
inlinestatic

Create a scalar DataSpace.

auto dataspace = DataSpace::Scalar();
static DataSpace Scalar()
Create a scalar DataSpace.
Definition H5Dataspace_misc.hpp:45
Since
2.9

Friends And Related Symbol Documentation

◆ Attribute

friend class Attribute
friend

◆ DataSet

friend class DataSet
friend

◆ File

friend class File
friend

Member Data Documentation

◆ type

const ObjectType HighFive::DataSpace::type = ObjectType::DataSpace
static

◆ UNLIMITED

const size_t HighFive::DataSpace::UNLIMITED = SIZE_MAX
static

Magic value to specify that a DataSpace can grow without limit.

This value should be used with DataSpace::DataSpace(const std::vector<size_t>& dims, const std::vector<size_t>& maxdims);

Since
2.0

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