mirror of
https://github.com/CHN-beta/nixos.git
synced 2026-01-12 04:39:23 +08:00
packages.biu: fix
This commit is contained in:
@@ -14,7 +14,7 @@ namespace biu
|
||||
class Hdf5file
|
||||
{
|
||||
public:
|
||||
Hdf5file(std::string filename, bool readonly = false);
|
||||
Hdf5file(std::string filename, bool truncate = false);
|
||||
template <typename T> Hdf5file& read(std::string name, T& object);
|
||||
template <typename T> T read(std::string name);
|
||||
template <typename T> Hdf5file& write(std::string name, const T& object);
|
||||
|
||||
@@ -2,12 +2,11 @@
|
||||
|
||||
namespace biu::hdf5
|
||||
{
|
||||
Hdf5file::Hdf5file(std::string filename, bool readonly)
|
||||
Hdf5file::Hdf5file(std::string filename, bool truncate)
|
||||
: File_
|
||||
(
|
||||
filename,
|
||||
readonly ? HighFive::File::ReadOnly
|
||||
: HighFive::File::ReadWrite | HighFive::File::Create | HighFive::File::Truncate
|
||||
({ using _ = HighFive::File; truncate ? _::ReadWrite | _::Create | _::Truncate : _::ReadOnly; })
|
||||
)
|
||||
{}
|
||||
HighFive::CompoundType detail_::create_phonopy_complex()
|
||||
|
||||
@@ -3,5 +3,10 @@
|
||||
int main()
|
||||
{
|
||||
using namespace biu::literals;
|
||||
biu::Hdf5file("test.h5").write("test", 42);
|
||||
// create file and write data
|
||||
biu::Hdf5file("test.h5", true).write("test", 42);
|
||||
// read data
|
||||
assert(biu::Hdf5file("test.h5").read<int>("test") == 42);
|
||||
// trucate data
|
||||
biu::Hdf5file("test.h5", true).write("test", std::vector{1, 2, 3});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user