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

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

#include <binary_fstream_archive.h>

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

Public Member Functions

 BinaryFstreamOutputArchive (const char *filename=nullptr, std::ios_base::openmode mode=std::ios_base::binary|std::ios_base::out|std::ios_base::trunc)
 Default constructor.
 
 BinaryFstreamOutputArchive (const std::string name, std::ios_base::openmode mode=std::ios_base::binary|std::ios_base::out|std::ios_base::trunc)
 
void close ()
 Close the filestream.
 
void flush ()
 Flush the filestream.
 
void open (const char *filename, std::ios_base::openmode mode=std::ios_base::binary|std::ios_base::out|std::ios_base::trunc)
 Open the filestream.
 
template<class T >
std::enable_if< is_trivially_serializable< T >::value, void >::type store (const T *t, long n) const
 Write to the filestream.
 
- Public Member Functions inherited from madness::archive::BaseArchive
 BaseArchive ()
 

Private Attributes

std::shared_ptr< char > iobuf
 Buffer.
 
std::ofstream os
 The filestream.
 

Static Private Attributes

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

Additional Inherited Members

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

Detailed Description

Wraps an archive around a binary filestream for output.

Constructor & Destructor Documentation

◆ BinaryFstreamOutputArchive() [1/2]

madness::archive::BinaryFstreamOutputArchive::BinaryFstreamOutputArchive ( const char *  filename = nullptr,
std::ios_base::openmode  mode = std::ios_base::binary | std::ios_base::out | std::ios_base::trunc 
)

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 write to.
[in]modeI/O attributes for opening the file.

References madness::filename, and open().

◆ BinaryFstreamOutputArchive() [2/2]

madness::archive::BinaryFstreamOutputArchive::BinaryFstreamOutputArchive ( const std::string  name,
std::ios_base::openmode  mode = std::ios_base::binary | std::ios_base::out | std::ios_base::trunc 
)
inline

Member Function Documentation

◆ close()

void madness::archive::BinaryFstreamOutputArchive::close ( )

Close the filestream.

References iobuf, and os.

Referenced by main(), and test12().

◆ flush()

void madness::archive::BinaryFstreamOutputArchive::flush ( )

Flush the filestream.

References os.

◆ open()

void madness::archive::BinaryFstreamOutputArchive::open ( const char *  filename,
std::ios_base::openmode  mode = std::ios_base::binary | std::ios_base::out | std::ios_base::trunc 
)

Open the filestream.

Parameters
[in]filenameThe name of the file.
[in]modeI/O attributes for opening the file.

References ARCHIVE_COOKIE, madness::filename, iobuf, IOBUFSIZE, os, and store().

Referenced by BinaryFstreamOutputArchive().

◆ store()

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

Write to the filestream.

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

Template Parameters
TThe type of data to be written.
Parameters
[in]tLocation of the data to be written.
[in]nThe number of data items to be written.

References os, and T().

Referenced by open().

Member Data Documentation

◆ iobuf

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

Buffer.

Referenced by close(), and open().

◆ IOBUFSIZE

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

Buffer size.

Referenced by open().

◆ os

std::ofstream madness::archive::BinaryFstreamOutputArchive::os
mutableprivate

The filestream.

Referenced by close(), flush(), open(), and store().


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