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

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

#include <buffer_archive.h>

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

Public Member Functions

 BufferInputArchive (const void *ptr, std::size_t nbyte)
 Constructor that assigns a buffer. More...
 
void close ()
 Close the archive. More...
 
template<class T >
std::enable_if< madness::is_trivially_serializable< T >::value, void >::type load (T *t, long n) const
 Reads data from the memory buffer. More...
 
std::size_t nbyte_avail () const
 Get the amount of space yet to be read from the buffer. More...
 
void open ()
 Open the archive. More...
 
void rewind () const
 Reset the read location to the beginning of the buffer. More...
 
- Public Member Functions inherited from madness::archive::BaseArchive
 BaseArchive ()
 

Private Attributes

std::size_t i
 Current input location. More...
 
const std::size_t nbyte
 Buffer size. More...
 
const unsigned char *const ptr
 The memory buffer. 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 memory buffer for input.

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

Constructor & Destructor Documentation

◆ BufferInputArchive()

madness::archive::BufferInputArchive::BufferInputArchive ( const 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::BufferInputArchive::close ( )
inline

Close the archive.

Referenced by main().

◆ load()

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

Reads data from the memory buffer.

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

Template Parameters
TType of the data to be read.
Parameters
[out]tWhere to store the read data.
[in]nSize of data to be read.

References i, m, MADNESS_ASSERT, nbyte, ptr, and T().

Referenced by test0().

◆ nbyte_avail()

std::size_t madness::archive::BufferInputArchive::nbyte_avail ( ) const
inline

Get the amount of space yet to be read from the buffer.

Returns
The amount of space yet to be read from the buffer.

References i, and nbyte.

◆ open()

void madness::archive::BufferInputArchive::open ( )
inline

Open the archive.

◆ rewind()

void madness::archive::BufferInputArchive::rewind ( ) const
inline

Reset the read location to the beginning of the buffer.

References i.

Member Data Documentation

◆ i

std::size_t madness::archive::BufferInputArchive::i
mutableprivate

Current input location.

Referenced by load(), nbyte_avail(), and rewind().

◆ nbyte

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

Buffer size.

Referenced by load(), and nbyte_avail().

◆ ptr

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

The memory buffer.

Referenced by load().


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