MADNESS  0.10.1
Public Member Functions | Private Attributes | List of all members
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:
Inheritance graph
[legend]
Collaboration diagram for madness::archive::BufferOutputArchive:
Collaboration graph
[legend]

Public Member Functions

 BufferOutputArchive ()
 Default constructor; the buffer will only count data. More...
 
 BufferOutputArchive (void *ptr, std::size_t nbyte)
 Constructor that assigns a buffer. More...
 
void close ()
 Close the archive. More...
 
bool count_only () const
 Determine if this buffer is used for counting. More...
 
void flush ()
 Flush the archive. More...
 
void open (std::size_t)
 Open a buffer with a specific size. More...
 
std::size_t size () const
 Return the amount of data stored (counted) in the buffer. More...
 
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. More...
 
- Public Member Functions inherited from madness::archive::BaseArchive
 BaseArchive ()
 

Private Attributes

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

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. 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::BaseOutputArchive
static constexpr bool is_output_archive = true
 Flag to determine if this object is an output 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 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.

◆ 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.

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(), ptr, and T().

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 count_only(), and store().

◆ i

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

Referenced by size(), and store().

◆ nbyte

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

Buffer size.

Referenced by store().

◆ ptr

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

The memory buffer.

Referenced by store().


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