HighFive 2.7.1
HighFive - Header-only C++ HDF5 interface
Loading...
Searching...
No Matches
H5DataSet_misc.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c), 2017, Adrien Devresse <adrien.devresse@epfl.ch>
3 *
4 * Distributed under the Boost Software License, Version 1.0.
5 * (See accompanying file LICENSE_1_0.txt or copy at
6 * http://www.boost.org/LICENSE_1_0.txt)
7 *
8 */
9#pragma once
10
11#include <algorithm>
12#include <functional>
13#include <numeric>
14#include <sstream>
15#include <string>
16
17#include <H5Dpublic.h>
18#include <H5Ppublic.h>
19
20#include "H5Utils.hpp"
21
22namespace HighFive {
23
24inline uint64_t DataSet::getStorageSize() const {
25 return H5Dget_storage_size(_hid);
26}
27
29 return DataType(H5Dget_type(_hid));
30}
31
33 DataSpace space;
34 if ((space._hid = H5Dget_space(_hid)) < 0) {
35 HDF5ErrMapper::ToException<DataSetException>("Unable to get DataSpace out of DataSet");
36 }
37 return space;
38}
39
41 return getSpace();
42}
43
44inline uint64_t DataSet::getOffset() const {
45 uint64_t addr = H5Dget_offset(_hid);
46 if (addr == HADDR_UNDEF) {
47 HDF5ErrMapper::ToException<DataSetException>("Cannot get offset of DataSet.");
48 }
49 return addr;
50}
51
52inline void DataSet::resize(const std::vector<size_t>& dims) {
53 const size_t numDimensions = getSpace().getDimensions().size();
54 if (dims.size() != numDimensions) {
55 HDF5ErrMapper::ToException<DataSetException>("Invalid dataspace dimensions, got " +
56 std::to_string(dims.size()) + " expected " +
57 std::to_string(numDimensions));
58 }
59
60 std::vector<hsize_t> real_dims(dims.begin(), dims.end());
61
62 if (H5Dset_extent(getId(), real_dims.data()) < 0) {
63 HDF5ErrMapper::ToException<DataSetException>("Could not resize dataset.");
64 }
65}
66
67} // namespace HighFive
DataSpace getMemSpace() const
getMemSpace
Definition H5DataSet_misc.hpp:40
void resize(const std::vector< size_t > &dims)
Change the size of the dataset.
Definition H5DataSet_misc.hpp:52
DataType getDataType() const
getDataType
Definition H5DataSet_misc.hpp:28
uint64_t getOffset() const
getOffset
Definition H5DataSet_misc.hpp:44
uint64_t getStorageSize() const
getStorageSize
Definition H5DataSet_misc.hpp:24
DataSpace getSpace() const
getSpace
Definition H5DataSet_misc.hpp:32
Class representing the space (dimensions) of a dataset.
Definition H5DataSpace.hpp:25
std::vector< size_t > getDimensions() const
getDimensions
Definition H5Dataspace_misc.hpp:102
HDF5 Data Type.
Definition H5DataType.hpp:54
hid_t getId() const noexcept
getId
Definition H5Object_misc.hpp:65
hid_t _hid
Definition H5Object.hpp:105
Definition H5_definitions.hpp:15
static void ToException(const std::string &prefix_msg)
Definition H5Exception_misc.hpp:42