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

Class handling reading of an NPZ from an in-memory string stream. More...

#include <npy.h>

Public Member Functions

 npzstringreader (const std::string &bytes)
 Constructor.
 
 npzstringreader (std::string &&bytes)
 Constructor.
 
const std::vector< std::string > & keys () const
 The keys of the tensors in the NPZ.
 
bool contains (const std::string &filename)
 Returns whether this NPZ contains the specified tensor.
 
header_info peek (const std::string &filename)
 Returns the header for a specified tensor.
 
template<typename T >
read (const std::string &filename)
 Read a tensor from the archive.
 
template<typename T , template< typename > class TENSOR>
TENSOR< T > read (const std::string &filename)
 

Detailed Description

Class handling reading of an NPZ from an in-memory string stream.

Constructor & Destructor Documentation

◆ npzstringreader() [1/2]

npy::npzstringreader::npzstringreader ( const std::string &  bytes)

Constructor.

Parameters
bytesthe contents of the stream

◆ npzstringreader() [2/2]

npy::npzstringreader::npzstringreader ( std::string &&  bytes)

Constructor.

Parameters
bytesthe contents of the stream

Member Function Documentation

◆ contains()

bool npy::npzstringreader::contains ( const std::string &  filename)

Returns whether this NPZ contains the specified tensor.

Parameters
filenamethe name of the tensor in the archive
Returns
whether the tensor is in the archive

◆ keys()

const std::vector< std::string > & npy::npzstringreader::keys ( ) const

The keys of the tensors in the NPZ.

◆ peek()

header_info npy::npzstringreader::peek ( const std::string &  filename)

Returns the header for a specified tensor.

Parameters
filenamethe name of the tensor in the archive
Returns
the header for the tensor

◆ read() [1/2]

template<typename T >
T npy::npzstringreader::read ( const std::string &  filename)
inline

Read a tensor from the archive.

This method will throw an exception if the tensor does not exist, or if the data type of the tensor does not match the template type.

Template Parameters
Tthe tensor type
Parameters
filenamethe name of the tensor in the archive
Returns
an instance of T read from the archive
See also
npy::tensor

◆ read() [2/2]

template<typename T , template< typename > class TENSOR>
TENSOR< T > npy::npzstringreader::read ( const std::string &  filename)
inline

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