vg
tools for working with variation graphs
|
#include <trivially_serializable.hpp>
Public Member Functions | |
TriviallySerializable ()=default | |
virtual | ~TriviallySerializable ()=default |
virtual void | dissociate ()=0 |
virtual void | serialize (const std::function< void(const void *, size_t)> &iteratee) const =0 |
virtual void | serialize (int fd)=0 |
virtual void | deserialize (int fd)=0 |
virtual void | serialize (int fd) const |
virtual void | serialize (const std::string &filename) const |
virtual void | serialize (const std::string &filename) |
virtual void | deserialize (const std::string &filename) |
virtual void | serialize (std::ostream &out) const |
virtual void | serialize (std::ostream &out) |
virtual void | deserialize (std::istream &in) |
Public Member Functions inherited from handlegraph::Serializable | |
virtual | ~Serializable ()=default |
virtual uint32_t | get_magic_number () const =0 |
Protected Member Functions | |
int | open_fd (const std::string &filename) const |
Helper to open a file descriptor with error checking. More... | |
void | close_fd (int fd) const |
Helper to close a file descriptor with error checking. More... | |
Protected Member Functions inherited from handlegraph::Serializable | |
virtual void | serialize_members (std::ostream &out) const =0 |
Underlying implementation for "serialize" method. More... | |
virtual void | deserialize_members (std::istream &in)=0 |
Underlying implementation to "deserialize" method. More... | |
Interface for objects that can use identical in-memory and serialized representations.
The representation begins with the serialized 4-byte magic number, followed by user data. Length is implicit in either stream length or file size, and can be grown.
If serialization or deserialization throws, it is safe to destroy the object, but not to do anything else with it.
Modifying a file that an object has been loaded from or saved to, either on disk or through another associated object, is undefined behavior. To prevent modifications to an object from modifying the last file loaded or saved to, use dissociate().
|
default |
Make a new TriviallySerializable. Should really only be called by constructors of inheriting types.
|
virtualdefault |
Destroy a TriviallySerializable object and any associated memory mappings.
|
protected |
Helper to close a file descriptor with error checking.
|
virtual |
Sets the contents of this object to the contents of a serialized object from a file. The serialized object must be from the same implementation of this interface as is calling deserialize(). Can only be called on an empty object. If the file is a normal writeable file, future modifications to the object will affect the file until dissociate() is called or another normal file is associated.
Reimplemented from handlegraph::Serializable.
|
pure virtual |
Sets the contents of this object to the contents of a serialized object from an open file descriptor. The serialized object must be from the same implementation of this interface as is calling deserialize(). Can only be called on an empty object If the file is a normal writeable file, future modifications to the object will affect the file until dissociate() is called or another normal file is associated.
Assumes that the file entirely belongs to this object.
|
virtual |
Sets the contents of this object to the contents of a serialized object from an istream. The serialized object must be from the same implementation of the interface as is calling deserialize(). Can only be called on an empty object. May result in a write-back link to a file opened as standard input if that stream is passed.
Reimplemented from handlegraph::Serializable.
|
pure virtual |
Break the write-back link between this object and the file it was loaded from, if any. Future modifications to the object will not affect the file, although future modifications to the file may still affect the object.
|
protected |
Helper to open a file descriptor with error checking.
|
pure virtual |
Serialize as blocks of data shown to the given function. The pointer must not be null. The blocks must include the magic number.
|
virtual |
Write the contents of this object to a named file. Makes sure to include a leading magic number. If the file is nonexistent or a normal file, future modifications to the object will affect the file until dissociate() is called or another normal file is associated.
Reimplemented from handlegraph::Serializable.
|
virtual |
Write the contents of this object to a named file. Makes sure to include a leading magic number. Does not affect any existing write-back links.
Reimplemented from handlegraph::Serializable.
|
virtual |
Write the contents of this object to an open file descriptor. Makes sure to include a leading magic number.
Assumes that the file entirely belongs to this object.
|
pure virtual |
Write the contents of this object to an open file descriptor. Makes sure to include a leading magic number. If the file is a normal file, future modifications to the object will affect the file until dissociate() is called or another normal file is associated.
Assumes that the file entirely belongs to this object.
|
virtual |
Dump the magic number and user data to the given stream. May result in a write-back link to a file opened as standard output or standard error if those streams are passed.
Reimplemented from handlegraph::Serializable.
|
virtual |
Dump the magic number and user data to the given stream. Does not affect any backing file link.
Reimplemented from handlegraph::Serializable.