jigdo API
serialize.hh File Reference
Convert objects into byte streams and vice versa. More...
#include <bstream.hh>
#include <config.h>
Go to the source code of this file.
Classes | |
class | SerialIstreamIterator |
Slight variation (and simplification) of std::istream_iterator and std::ostream_iterator. More... | |
class | SerialOstreamIterator |
Functions | |
template<class Object, class Iterator> | |
Iterator | serialize (const Object &o, Iterator i) |
Store serialized object via iterator. | |
template<class Object, class ConstIterator> | |
ConstIterator | unserialize (Object &o, ConstIterator i) |
Assign the contents of the byte stream pointed to by i to the object. | |
template<class Object> | |
size_t | serialSizeOf (const Object &o) |
Return number of bytes needed by this object when serialized. | |
Numeric types - append the number of bytes to use (e.g.
4 for 32-bit) | |
template<class NumType, class Iterator> | |
Iterator | serialize1 (NumType x, Iterator i) |
template<class NumType, class ConstIterator> | |
ConstIterator | unserialize1 (NumType &x, ConstIterator i) |
template<class NumType, class Iterator> | |
Iterator | serialize2 (NumType x, Iterator i) |
template<class NumType, class ConstIterator> | |
ConstIterator | unserialize2 (NumType &x, ConstIterator i) |
template<class NumType, class Iterator> | |
Iterator | serialize4 (NumType x, Iterator i) |
template<class NumType, class ConstIterator> | |
ConstIterator | unserialize4 (NumType &x, ConstIterator i) |
template<class NumType, class Iterator> | |
Iterator | serialize6 (NumType x, Iterator i) |
template<class NumType, class ConstIterator> | |
ConstIterator | unserialize6 (NumType &x, ConstIterator i) |
template<class NumType, class Iterator> | |
Iterator | serialize8 (NumType x, Iterator i) |
template<class NumType, class ConstIterator> | |
ConstIterator | unserialize8 (NumType &x, ConstIterator i) |
Detailed Description
Convert objects into byte streams and vice versa.Classes that support serialization should implement the indicated member functions; serialize(), unserialize() and serialSizeOf(). It is assumed that 'byte' has been typdef'd to an unsigned type which represents one byte.
MyClass { template<class Iterator> inline Iterator serialize(Iterator i) const; template<class ConstIterator> inline ConstIterator unserialize(ConstIterator i); inline size_t serialSizeOf() const; };
Function Documentation
Iterator serialize | ( | const Object & | o, | |
Iterator | i | |||
) | [inline] |
Store serialized object via iterator.
The iterator could be byte* or vector<byte>::iterator or SerialOstreamIterator - anything in which you can store bytes. There must be enough room to store serialSizeOf() bytes, implementers of serialize() need not check this.
The implementation of serialize() must both modify i and return its value after the last modification.
Referenced by FilePart::SerializeCacheEntry::operator()().
Iterator serialize1 | ( | NumType | x, | |
Iterator | i | |||
) | [inline] |
Iterator serialize2 | ( | NumType | x, | |
Iterator | i | |||
) | [inline] |
Iterator serialize4 | ( | NumType | x, | |
Iterator | i | |||
) | [inline] |
Iterator serialize6 | ( | NumType | x, | |
Iterator | i | |||
) | [inline] |
Iterator serialize8 | ( | NumType | x, | |
Iterator | i | |||
) | [inline] |
size_t serialSizeOf | ( | const Object & | o | ) | [inline] |
Return number of bytes needed by this object when serialized.
If a whole tree of objects is serialized, this may include the accumulated serialized sizes of the child objects, too.
ConstIterator unserialize | ( | Object & | o, | |
ConstIterator | i | |||
) | [inline] |
Assign the contents of the byte stream pointed to by i to the object.
template<class Object, class ConstIterator>
Referenced by JigdoDescVec::get().
ConstIterator unserialize1 | ( | NumType & | x, | |
ConstIterator | i | |||
) | [inline] |
ConstIterator unserialize2 | ( | NumType & | x, | |
ConstIterator | i | |||
) | [inline] |
ConstIterator unserialize4 | ( | NumType & | x, | |
ConstIterator | i | |||
) | [inline] |
ConstIterator unserialize6 | ( | NumType & | x, | |
ConstIterator | i | |||
) | [inline] |
Referenced by CacheFile::find(), CacheFile::findName(), JigdoDescVec::get(), Zibstream::read(), and JigdoDesc::seekFromEnd().
ConstIterator unserialize8 | ( | NumType & | x, | |
ConstIterator | i | |||
) | [inline] |
Generated on Tue Sep 23 14:27:42 2008 for jigdo by
