libnpy 2.0.0
Lightweight C++ library for reading and writing NPY and NPZ files
Loading...
Searching...
No Matches
Public Member Functions | List of all members
npy::npzfilewriter Class Reference

Class which handles writing of an NPZ archive to disk. More...

#include <npy.h>

Public Member Functions

 npzfilewriter (const std::string &path, compression_method_t compression=compression_method_t::STORED, endian_t endianness=npy::endian_t::NATIVE)
 Constructor.
 
 npzfilewriter (const char *path, compression_method_t compression=compression_method_t::STORED, endian_t endianness=npy::endian_t::NATIVE)
 Constructor.
 
 npzfilewriter (const std::filesystem::path &path, compression_method_t compression=compression_method_t::STORED, endian_t endianness=npy::endian_t::NATIVE)
 Constructor.
 
 ~npzfilewriter ()
 Destructor. This will call npy::npzfilewriter::close, if it has not been called already.
 
bool is_open () const
 Returns whether the NPZ file is open.
 
void close ()
 Writes the directory and end-matter of the NPZ file, and closes the file. Further writes will fail.
 
template<typename T >
void write (const std::string &filename, const T &tensor)
 Write a tensor to the NPZ archive.
 

Detailed Description

Class which handles writing of an NPZ archive to disk.

Constructor & Destructor Documentation

◆ npzfilewriter() [1/3]

npy::npzfilewriter::npzfilewriter ( const std::string &  path,
compression_method_t  compression = compression_method_t::STORED,
endian_t  endianness = npy::endian_t::NATIVE 
)

Constructor.

Parameters
pathpath to the output NPZ file
compressionhow the entries should be compressed
endiannessthe endianness to use in writing the entries

◆ npzfilewriter() [2/3]

npy::npzfilewriter::npzfilewriter ( const char *  path,
compression_method_t  compression = compression_method_t::STORED,
endian_t  endianness = npy::endian_t::NATIVE 
)

Constructor.

Parameters
pathpath to the output NPZ file
compressionhow the entries should be compressed
endiannessthe endianness to use in writing the entries

◆ npzfilewriter() [3/3]

npy::npzfilewriter::npzfilewriter ( const std::filesystem::path &  path,
compression_method_t  compression = compression_method_t::STORED,
endian_t  endianness = npy::endian_t::NATIVE 
)

Constructor.

Parameters
pathpath to the output NPZ file
compressionhow the entries should be compressed
endiannessthe endianness to use in writing the entries

◆ ~npzfilewriter()

npy::npzfilewriter::~npzfilewriter ( )

Destructor. This will call npy::npzfilewriter::close, if it has not been called already.

Member Function Documentation

◆ close()

void npy::npzfilewriter::close ( )

Writes the directory and end-matter of the NPZ file, and closes the file. Further writes will fail.

◆ is_open()

bool npy::npzfilewriter::is_open ( ) const

Returns whether the NPZ file is open.

◆ write()

template<typename T >
void npy::npzfilewriter::write ( const std::string &  filename,
const T &  tensor 
)
inline

Write a tensor to the NPZ archive.

Template Parameters
Tthe tensor type
Parameters
filenamethe name of the file in the archive
tensorthe tensor to write

The documentation for this class was generated from the following file: