MADNESS 0.10.1
madness::archive::BufferOutputArchive Class Reference

Wraps an archive around a memory buffer for output. More...

#include <buffer_archive.h>

Inheritance diagram for madness::archive::BufferOutputArchive:
Collaboration diagram for madness::archive::BufferOutputArchive:

Public Member Functions

 BufferOutputArchive ()
 Default constructor; the buffer will only count data.
 BufferOutputArchive (void *ptr, std::size_t nbyte)
 Constructor that assigns a buffer.
void close ()
 Close the archive.
bool count_only () const
 Determine if this buffer is used for counting.
void flush ()
 Flush the archive.
void open (std::size_t)
 Open a buffer with a specific size.
std::size_t size () const
 Return the amount of data stored (counted) in the buffer.
template<typename T>
std::enable_if< madness::is_trivially_serializable< T >::value, void >::type store (const T *t, long n) const
 Stores (counts) data into the memory buffer.
Public Member Functions inherited from madness::archive::BaseArchive
 BaseArchive ()

Private Attributes

bool countonly
 Current output location.
std::size_t i
const std::size_t nbyte
 Buffer size.
unsigned char *const ptr
 The memory buffer.

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 memory buffer for output.

Note
Type checking is disabled for efficiency.
Exceptions
madness::MadnessExceptionin case of buffer overflow.

The default constructor can also be used to count stuff.

Constructor & Destructor Documentation

◆ BufferOutputArchive() [1/2]

madness::archive::BufferOutputArchive::BufferOutputArchive ( )
inline

Default constructor; the buffer will only count data.

References countonly, i, nbyte, and ptr.

◆ BufferOutputArchive() [2/2]

madness::archive::BufferOutputArchive::BufferOutputArchive ( void * ptr,
std::size_t nbyte )
inline

Constructor that assigns a buffer.

Parameters
[in]ptrPointer to the buffer.
[in]nbyteSize of the buffer.

References countonly, i, nbyte, and ptr.

Member Function Documentation

◆ close()

void madness::archive::BufferOutputArchive::close ( )
inline

Close the archive.

Referenced by main().

◆ count_only()

bool madness::archive::BufferOutputArchive::count_only ( ) const
inline

Determine if this buffer is used for counting.

Returns
True if this buffer is only used for counting.

References countonly.

◆ flush()

void madness::archive::BufferOutputArchive::flush ( )
inline

Flush the archive.

◆ open()

void madness::archive::BufferOutputArchive::open ( std::size_t )
inline

Open a buffer with a specific size.

◆ size()

std::size_t madness::archive::BufferOutputArchive::size ( ) const
inline

◆ store()

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

Stores (counts) data into the memory buffer.

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

Template Parameters
TType of the data to be stored (counted).
Parameters
[in]tPointer to the data to be stored (counted).
[in]nSize of data to be stored (counted).

References countonly, i, m, MADNESS_ASSERT, MADNESS_PRAGMA_GCC, nbyte, madness::pop(), madness::print(), and ptr.

Referenced by test0().

Member Data Documentation

◆ countonly

bool madness::archive::BufferOutputArchive::countonly
private

Current output location.

If true just count, don't copy.

Referenced by BufferOutputArchive(), BufferOutputArchive(), count_only(), and store().

◆ i

std::size_t madness::archive::BufferOutputArchive::i
mutableprivate

◆ nbyte

const std::size_t madness::archive::BufferOutputArchive::nbyte
private

Buffer size.

Referenced by BufferOutputArchive(), BufferOutputArchive(), and store().

◆ ptr

unsigned char* const madness::archive::BufferOutputArchive::ptr
private

The memory buffer.

Referenced by BufferOutputArchive(), BufferOutputArchive(), and store().


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