Turi Create  4.0
turi::iarchive Class Reference

The serialization input archive object which, provided with a reference to an istream, will read from the istream, providing deserialization capabilities. More...

#include <core/storage/serialization/iarchive.hpp>

Public Member Functions

 iarchive (std::istream &instream)
 
char read_char ()
 Directly reads a single character from the input stream.
 
void read (char *c, size_t l)
 
template<typename T >
void read_into (T &c)
 
bool fail ()
 Returns true if the underlying stream is in a failure state.
 

Detailed Description

The serialization input archive object which, provided with a reference to an istream, will read from the istream, providing deserialization capabilities.

Given a source of serialized bytes (written by an turi::oarchive), in the form of a standard input stream, you can construct an iarchive object by:

// where strm is an istream object
turi::iarchive iarc(strm);

For instance, to deserialize from a file,

std::ifstream fin("inputfile.bin");
turi::iarchive iarc(fin);

Once the iarc object is constructed, Serializable objects can be read from it using the >> stream operator.

iarc >> a >> b >> c;

Alternatively, data can be directly read from the stream using the iarchive::read() and iarchive::read_char() functions.

For more usage details, see serialization

The iarchive object should not be used once the associated stream object is closed or is destroyed.

To use this class, include core/storage/serialization/serialization_includes.hpp

Definition at line 60 of file iarchive.hpp.

Constructor & Destructor Documentation

◆ iarchive()

turi::iarchive::iarchive ( std::istream &  instream)
inline

Constructs an iarchive object. Takes a reference to a generic std::istream object and associates the archive with it. Reads from the archive will read from the assiciated input stream.

Definition at line 75 of file iarchive.hpp.

Member Function Documentation

◆ read()

void turi::iarchive::read ( char *  c,
size_t  l 
)
inline

Directly reads a sequence of "len" bytes from the input stream into the location pointed to by "c"

Definition at line 103 of file iarchive.hpp.

◆ read_into()

template<typename T >
void turi::iarchive::read_into ( T &  c)
inline

Directly reads a sequence of "len" bytes from the input stream into the location pointed to by "c"

Definition at line 118 of file iarchive.hpp.


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