GraphLab: Distributed Graph-Parallel API  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
graphlab::oarchive Class Reference

The serialization output archive object which, provided with a reference to an ostream, will write to the ostream, providing serialization capabilities. More...

#include <graphlab/serialization/oarchive.hpp>

List of all members.

Public Member Functions

 oarchive (std::ostream &outstream)
 constructor. Takes a generic std::ostream object
void expand_buf (size_t s)
void write (const char *c, std::streamsize s)
template<typename T >
void direct_assign (const T &t)
void advance (size_t s)
bool fail ()
 Returns true if the underlying stream is in a failure state.

Public Attributes

std::ostream * out
char * buf
size_t off
size_t len

Detailed Description

The serialization output archive object which, provided with a reference to an ostream, will write to the ostream, providing serialization capabilities.

Given a standard output stream, you can construct an oarchive object by:

// where strm is an ostream object
graphlab::oarchive oarc(strm);

For instance, to serialize to a file,

std::ofstream fout("outputfile.bin");
graphlab::oarchive oarc(fout);

Once the oarc object is constructed, Serializable objects can be written to it using the << stream operator.

oarc << a << b << c;

Alternatively, data can be directly written to the stream using the oarchive::write() function.

Written data can be deserialized using graphlab::iarchive. For more usage details, see Serialization

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

The oarc object does not flush the associated stream, and the user may need to manually flush the associated stream to clear any stream buffers. For instance, while the std::stringstream may be used for both output and input, it is necessary to flush the stream before all bytes written to the stringstream are available for input.

To use this class, include graphlab/serialization/serialization_includes.hpp

Definition at line 86 of file oarchive.hpp.


Member Function Documentation

void graphlab::oarchive::write ( const char *  c,
std::streamsize  s 
)
inline

Directly writes "s" bytes from the memory location pointed to by "c" into the stream.

Definition at line 108 of file oarchive.hpp.


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