TRIQS/h5
2.0.0
C++ interface to HDF5
Toggle main menu visibility
Loading...
Searching...
No Matches
file.hpp
Go to the documentation of this file.
1
// Copyright (c) 2019-2024 Simons Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0.txt
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
//
15
// Authors: Thomas Hahn, Olivier Parcollet, Nils Wentzell
16
21
22
#ifndef LIBH5_FILE_HPP
23
#define LIBH5_FILE_HPP
24
25
#include "
./object.hpp
"
26
27
#include <cstddef>
28
#include <span>
29
#include <string>
30
#include <vector>
31
32
namespace
h5 {
33
43
class
file
:
public
object
{
44
public
:
51
file
();
52
69
file
(
const
char
*
name
,
char
mode);
70
75
file
(std::string
const
&
name
,
char
mode) :
file
(
name
.c_str(), mode) {}
76
78
[[nodiscard]] std::string
name
()
const
;
79
81
void
flush
();
82
83
private
:
84
// Constructor to create a buffered memory file with an initial file image of a given size.
85
file
(
const
std::byte *buf,
size_t
size);
86
87
public
:
92
file
(std::span<std::byte>
const
&buf) :
file
(buf.data(), buf.size()) {}
93
98
file
(std::vector<std::byte>
const
&buf) :
file
(buf.data(), buf.size()) {}
99
101
[[nodiscard]] std::vector<std::byte>
as_buffer
()
const
;
102
};
103
104
}
// namespace h5
105
106
#endif
// LIBH5_FILE_HPP
h5::file::name
std::string name() const
Get the name of the file.
Definition
file.cpp:71
h5::file::file
file(std::span< std::byte > const &buf)
Constructor to create a buffered memory file from a byte buffer.
Definition
file.hpp:92
h5::file::as_buffer
std::vector< std::byte > as_buffer() const
Get a copy of the associated byte buffer.
Definition
file.cpp:123
h5::file::file
file(std::string const &name, char mode)
Constructor to open an existing file or to create a new file on disk.
Definition
file.hpp:75
h5::file::flush
void flush()
Flush the file by calling H5Fflush.
Definition
file.cpp:85
h5::file::file
file(std::vector< std::byte > const &buf)
Constructor to create a buffered memory file from a byte buffer.
Definition
file.hpp:98
h5::file::file
file()
Default constructor creates a buffered memory file.
Definition
file.cpp:91
h5::object::object
object(hid_t id=0)
Construct a new h5::object for a given HDF5 ID by taking ownership, i.e. without increasing the refer...
Definition
object.hpp:71
object.hpp
Provides a generic handle for HDF5 objects.
h5
file.hpp
Generated by
1.17.0