jigdo API

RsyncSum Class Reference

A 32 bit checksum with the special property that you do not need to recalculate the checksum when data is added to the front/end of the checksummed area, or removed from it. More...

#include <rsyncsum.hh>

List of all members.


Public Member Functions

 RsyncSum ()
 Initialises the checksum with zero.
 RsyncSum (const byte *mem, size_t len)
 Initialises with the checksum of a memory area.
bool operator== (const RsyncSum &x) const
 Compare two RsyncSum objects.
bool operator!= (const RsyncSum &x) const
bool operator< (const RsyncSum &x) const
bool operator> (const RsyncSum &x) const
bool operator<= (const RsyncSum &x) const
bool operator>= (const RsyncSum &x) const
RsyncSumaddBack (const byte *mem, size_t len)
 Append memory area to end of area covered by the checksum.
RsyncSumaddBack (byte x)
 Append one byte at end of area covered by the checksum.
RsyncSumaddBackNtimes (byte x, size_t n)
 Append the same byte n times at end of area covered by the checksum.
RsyncSumremoveFront (const byte *mem, size_t len, size_t areaSize)
 Remove memory area from start of area covered by the checksum.
RsyncSumremoveFront (byte x, size_t areaSize)
 Remove one byte from start of area covered by checksum.
uint32 get () const
 Read stored checksum.
RsyncSumreset ()
 Reset to initial state.
bool empty () const
 Check whether sum is zero.

Detailed Description

A 32 bit checksum with the special property that you do not need to recalculate the checksum when data is added to the front/end of the checksummed area, or removed from it.

Currently only adding to the end and removing from the front is supported. Adding to the end is very slightly faster.

Many thanks to Andrew Tridgell and Paul Mackerras for the algorithm - NB none of rsync's code is used.

Unless described otherwise, if a method returns an RsyncSum&, then this is a reference to the object itself, to allow chaining of calls, e.g. obj.addBack(x).addBack(y)


Constructor & Destructor Documentation

RsyncSum::RsyncSum (  )  [inline]

Initialises the checksum with zero.

RsyncSum::RsyncSum ( const byte *  mem,
size_t  len 
) [inline]

Initialises with the checksum of a memory area.

References addBack().


Member Function Documentation

bool RsyncSum::operator== ( const RsyncSum x  )  const [inline]

Compare two RsyncSum objects.

References get().

bool RsyncSum::operator!= ( const RsyncSum x  )  const [inline]

References get().

bool RsyncSum::operator< ( const RsyncSum x  )  const [inline]

References get().

bool RsyncSum::operator> ( const RsyncSum x  )  const [inline]

References get().

bool RsyncSum::operator<= ( const RsyncSum x  )  const [inline]

References get().

bool RsyncSum::operator>= ( const RsyncSum x  )  const [inline]

References get().

RsyncSum & RsyncSum::addBack ( const byte *  mem,
size_t  len 
)

Append memory area to end of area covered by the checksum.

Referenced by main(), and RsyncSum().

RsyncSum & RsyncSum::addBack ( byte  x  )  [inline]

Append one byte at end of area covered by the checksum.

RsyncSum & RsyncSum::addBackNtimes ( byte  x,
size_t  n 
) [inline]

Append the same byte n times at end of area covered by the checksum.

(addBack() is not overloaded for this in order to avoid confusion with removeFront(byte, size_t), which has the same signature, but only removes one byte.)

RsyncSum & RsyncSum::removeFront ( const byte *  mem,
size_t  len,
size_t  areaSize 
)

Remove memory area from start of area covered by the checksum.

Parameters:
mem Data to remove
len Number of bytes to remove from area, so it will cover area-len bytes after call
areaSize Size covered by area before call (necessary for calculcations)

References get().

Referenced by main().

RsyncSum & RsyncSum::removeFront ( byte  x,
size_t  areaSize 
) [inline]

Remove one byte from start of area covered by checksum.

uint32 RsyncSum::get (  )  const [inline]

RsyncSum& RsyncSum::reset (  )  [inline]

Reset to initial state.

Referenced by main().

bool RsyncSum::empty (  )  const [inline]

Check whether sum is zero.


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

Generated on Tue Sep 23 14:27:43 2008 for jigdo by  doxygen 1.5.6