ext
HighFive
src
examples
select_partial_dataset_cpp11.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (c), 2017, Adrien Devresse
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
#include <functional>
10
#include <iostream>
11
#include <string>
12
#include <vector>
13
14
#include <
highfive/H5File.hpp
>
15
#include <
highfive/H5DataSet.hpp
>
16
#include <
highfive/H5DataSpace.hpp
>
17
18
const
std::string
FILE_NAME
(
"select_partial_example.h5"
);
19
const
std::string
DATASET_NAME
(
"dset"
);
20
21
// Create a dataset name "dset" of double 4x6
22
//
23
int
main
(
void
) {
24
using namespace
HighFive
;
25
try
{
26
// Create a new file using the default property lists.
27
File
file
(
FILE_NAME
,
File::ReadWrite
|
File::Create
|
File::Truncate
);
28
29
// we have some example values in a 2D vector 2x5
30
std::vector<std::vector<double>>
values
= {
31
{1.0, 2.0, 4.0, 8.0, 16.0}, {32.0, 64.0, 128.0, 256.0, 512.0}};
32
33
// let's create a dataset of this size
34
DataSet
dataset =
35
file
.createDataSet<
double
>(
DATASET_NAME
,
DataSpace::From
(
values
));
36
// and write them
37
dataset.
write
(
values
);
38
39
// now we read back 2x2 values after an offset of 0x2
40
std::vector<std::vector<double>> result;
41
dataset.
select
({0, 2}, {2, 2}).read(result);
42
43
// we print out 4 values
44
for
(
auto
i : result) {
45
for
(
auto
j : i) {
46
std::cout <<
" "
<< j;
47
}
48
std::cout <<
"\n"
;
49
}
50
51
}
catch
(
Exception
& err) {
52
// catch and print any HDF5 error
53
std::cerr << err.
what
() << std::endl;
54
}
55
56
return
0;
// successfully terminated
57
}
DATASET_NAME
const std::string DATASET_NAME("dset")
H5File.hpp
HighFive::DataSpace::From
static DataSpace From(const ScalarValue &scalar_value)
Definition:
H5Dataspace_misc.hpp:130
H5DataSet.hpp
H5DataSpace.hpp
HighFive::SliceTraits::select
Selection select(const std::vector< size_t > &offset, const std::vector< size_t > &count, const std::vector< size_t > &stride=std::vector< size_t >()) const
Definition:
H5Slice_traits_misc.hpp:66
HighFive::SliceTraits::write
void write(const T &buffer)
Definition:
H5Slice_traits_misc.hpp:210
HighFive::File::Create
static const int Create
Open flag: Create non existing file.
Definition:
H5File.hpp:40
scripts.create_png.values
values
Definition:
create_png.py:26
main
int main(void)
Definition:
select_partial_dataset_cpp11.cpp:23
HighFive::File
File class.
Definition:
H5File.hpp:25
file
FILE * file
Definition:
arithmeticencoder.cpp:77
FILE_NAME
const std::string FILE_NAME("select_partial_example.h5")
HighFive::Exception::what
const char * what() const override
get the current exception error message
Definition:
H5Exception.hpp:34
HighFive::Exception
Basic HighFive Exception class.
Definition:
H5Exception.hpp:23
HighFive::File::ReadWrite
static const int ReadWrite
Open flag: Read Write access.
Definition:
H5File.hpp:32
HighFive::DataSet
Definition:
H5DataSet.hpp:27
HighFive::File::Truncate
static const int Truncate
Open flag: Truncate a file if already existing.
Definition:
H5File.hpp:34
HighFive
Definition:
H5Annotate_traits.hpp:14
lvr2
Author(s): Thomas Wiemann
, Sebastian Pütz
, Alexander Mock
, Lars Kiesow
, Lukas Kalbertodt
, Tristan Igelbrink
, Johan M. von Behren
, Dominik Feldschnieders
, Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:25