ext
HighFive
src
examples
create_dataset_double.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 <iostream>
10
#include <string>
11
#include <vector>
12
13
#include <
highfive/H5DataSet.hpp
>
14
#include <
highfive/H5DataSpace.hpp
>
15
#include <
highfive/H5File.hpp
>
16
17
const
std::string
FILE_NAME
(
"create_dataset_example.h5"
);
18
const
std::string
DATASET_NAME
(
"dset"
);
19
20
// Create a dataset name "dset" of double 4x6
21
//
22
int
main
(
void
) {
23
using namespace
HighFive
;
24
try
{
25
// Create a new file using the default property lists.
26
File
file
(
FILE_NAME
,
File::ReadWrite
|
File::Create
|
File::Truncate
);
27
28
// Define the size of our dataset: 2x6
29
std::vector<size_t> dims(2);
30
dims[0] = 2;
31
dims[1] = 6;
32
33
// Create the dataset
34
DataSet
dataset =
35
file
.createDataSet<
double
>(
DATASET_NAME
,
DataSpace
(dims));
36
37
double
data[2][6] = {{1.1, 2.2, 3.3, 4.4, 5.5, 6.6},
38
{11.11, 12.12, 13.13, 14.14, 15.15, 16.16}};
39
40
// write it
41
dataset.
write
(data);
42
43
}
catch
(
Exception
& err) {
44
// catch and print any HDF5 error
45
std::cerr << err.
what
() << std::endl;
46
}
47
48
return
0;
// successfully terminated
49
}
FILE_NAME
const std::string FILE_NAME("create_dataset_example.h5")
main
int main(void)
Definition:
create_dataset_double.cpp:22
H5File.hpp
H5DataSet.hpp
H5DataSpace.hpp
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
DATASET_NAME
const std::string DATASET_NAME("dset")
HighFive::File
File class.
Definition:
H5File.hpp:25
file
FILE * file
Definition:
arithmeticencoder.cpp:77
HighFive::DataSpace
Definition:
H5DataSpace.hpp:30
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:23