MADNESS  0.10.1
Public Member Functions | Private Attributes | Static Private Attributes | List of all members
madness::archive::BinaryFstreamInputArchive Class Reference

Wraps an archive around a binary filestream for input. More...

#include <binary_fstream_archive.h>

Inheritance diagram for madness::archive::BinaryFstreamInputArchive:
Inheritance graph
[legend]
Collaboration diagram for madness::archive::BinaryFstreamInputArchive:
Collaboration graph
[legend]

Public Member Functions

 BinaryFstreamInputArchive (const char *filename=nullptr, std::ios_base::openmode mode=std::ios_base::binary|std::ios_base::in)
 Default constructor. More...
 
 BinaryFstreamInputArchive (const std::string name, std::ios_base::openmode mode=std::ios_base::binary|std::ios_base::in)
 Default constructor. More...
 
void close ()
 Close the filestream. More...
 
template<class T >
std::enable_if< is_trivially_serializable< T >::value, void >::type load (T *t, long n) const
 Load from the filestream. More...
 
void open (const char *filename, std::ios_base::openmode mode=std::ios_base::binary|std::ios_base::in)
 Open the filestream. More...
 
- Public Member Functions inherited from madness::archive::BaseArchive
 BaseArchive ()
 

Private Attributes

std::shared_ptr< char > iobuf
 Buffer. More...
 
std::ifstream is
 The filestream. More...
 

Static Private Attributes

static const std::size_t IOBUFSIZE = 4*1024*1024
 Buffer size. More...
 

Additional Inherited Members

- Public Types inherited from madness::archive::BaseInputArchive
using is_loading = std::true_type
 Type used by Boost.Serialization to determine if this object is an input archive. More...
 
- Public Types inherited from madness::archive::BaseArchive
using is_loading = std::false_type
 Type used by Boost.Serialization to determine if this object is an input archive. More...
 
using is_saving = std::false_type
 Type used by Boost.Serialization to determine if this object is an output archive. More...
 
- Static Public Attributes inherited from madness::archive::BaseInputArchive
static constexpr bool is_input_archive = true
 Flag to determine if this object is an input archive. More...
 
- Static Public Attributes inherited from madness::archive::BaseArchive
static constexpr bool is_archive = true
 Flag to determine if this object is an archive. More...
 
static constexpr bool is_input_archive = false
 Flag to determine if this object is an input archive. More...
 
static constexpr bool is_output_archive = false
 Flag to determine if this object is an output archive. More...
 
static constexpr bool is_parallel_archive = false
 Flag to determine if this object is a parallel archive. More...
 

Detailed Description

Wraps an archive around a binary filestream for input.

Constructor & Destructor Documentation

◆ BinaryFstreamInputArchive() [1/2]

madness::archive::BinaryFstreamInputArchive::BinaryFstreamInputArchive ( const char *  filename = nullptr,
std::ios_base::openmode  mode = std::ios_base::binary | std::ios_base::in 
)

Default constructor.

The filename and open modes are optional here; they can be specified later by calling open().

Parameters
[in]filenameName of the file to read from.
[in]modeI/O attributes for opening the file.

References madness::filename, and open().

◆ BinaryFstreamInputArchive() [2/2]

madness::archive::BinaryFstreamInputArchive::BinaryFstreamInputArchive ( const std::string  name,
std::ios_base::openmode  mode = std::ios_base::binary | std::ios_base::in 
)
inline

Default constructor.

The filename and open modes are optional here; they can be specified later by calling open().

Parameters
[in]filenameName of the file to read from.
[in]modeI/O attributes for opening the file.

Member Function Documentation

◆ close()

void madness::archive::BinaryFstreamInputArchive::close ( )

Close the filestream.

References iobuf, and is.

Referenced by main().

◆ load()

template<class T >
std::enable_if< is_trivially_serializable<T>::value, void >::type madness::archive::BinaryFstreamInputArchive::load ( T t,
long  n 
) const
inline

Load from the filestream.

The function only appears (due to enable_if) if T is serializable.

Template Parameters
TThe type of data to be read.
Parameters
[out]tWhere to put the loaded data.
[in]nThe number of data items to be loaded.

References is, and T().

Referenced by open().

◆ open()

void madness::archive::BinaryFstreamInputArchive::open ( const char *  filename,
std::ios_base::openmode  mode = std::ios_base::binary | std::ios_base::in 
)

Open the filestream.

Parameters
[in]filenameName of the file to read from.
[in]modeI/O attributes for opening the file.

References ARCHIVE_COOKIE, madness::filename, iobuf, IOBUFSIZE, is, load(), and MADNESS_EXCEPTION.

Referenced by BinaryFstreamInputArchive().

Member Data Documentation

◆ iobuf

std::shared_ptr<char> madness::archive::BinaryFstreamInputArchive::iobuf
private

Buffer.

Referenced by close(), and open().

◆ IOBUFSIZE

const std::size_t madness::archive::BinaryFstreamInputArchive::IOBUFSIZE = 4*1024*1024
staticprivate

Buffer size.

Referenced by open().

◆ is

std::ifstream madness::archive::BinaryFstreamInputArchive::is
mutableprivate

The filestream.

Referenced by close(), load(), and open().


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