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::npzstringwriter Class Reference

Class which handles writing of an NPZ to an in-memory string stream. More...

#include <npy.h>

Public Member Functions

 npzstringwriter (compression_method_t compression=compression_method_t::STORED, endian_t endianness=npy::endian_t::NATIVE)
 Constructor.
 
 ~npzstringwriter ()
 Destructor. This will call npy::npzstringwriter::close, if it has not been called already.
 
std::string str () const
 Returns the contents of the string stream as a string.
 
void close ()
 Writes the directory and end-matter of the NPZ 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 to an in-memory string stream.

Constructor & Destructor Documentation

◆ npzstringwriter()

npy::npzstringwriter::npzstringwriter ( compression_method_t  compression = compression_method_t::STORED,
endian_t  endianness = npy::endian_t::NATIVE 
)

Constructor.

Parameters
compressionhow the entries should be compressed
endiannessthe endianness to use in writing the entries

◆ ~npzstringwriter()

npy::npzstringwriter::~npzstringwriter ( )

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

Member Function Documentation

◆ close()

void npy::npzstringwriter::close ( )

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

◆ str()

std::string npy::npzstringwriter::str ( ) const

Returns the contents of the string stream as a string.

Returns
the state of the in-memory stream

◆ write()

template<typename T >
void npy::npzstringwriter::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: