#include <simpverstool.h>
Public Member Functions | |
virtual | ~simple_version_tool () |
simple_version_tool (const nstring &history_file_name, compression_algorithm_t comp_alg=compression_algorithm_not_set) | |
void | checkin (const nstring &input_file_name, const rfc822 &meta_data) |
void | checkin (const nstring &input_file_name) |
bool | list (rfc822_functor &arg) |
void | checkout (const nstring &output_file_name, const nstring &version) |
void | checkout (output::pointer os, const nstring &version) |
Private Member Functions | |
simple_version_tool () | |
simple_version_tool (const simple_version_tool &) | |
simple_version_tool & | operator= (const simple_version_tool &) |
Private Attributes | |
nstring | history_file_name |
compression_algorithm_t | compression_algorithm |
It stores all versions end-to-end in a compressed file, with RFC 882 headers between, to hold things like the version number and the content length. The trick is, it's all compressed using GNU gzip.
The idea is the same one as behind xdelta (RFC nnnn). Because all the versions are substantially similar most of the time, the compression state carries over between versions, resulting in very high compression ratios for versions later in the file.
We put the head revsion first, simply because it is accessed most often. It doesn't change the premise, or the results.
End-to-end issues:
Each version also has an Adler 32 checksum stored in the header. This lets us check that the data is valid when we extract it. The GNU gzip format also has an Adler 32 checksum in the trailer, and this is used for for confirming that previous version are still valid when we do a new checkin. The checksum in each version is because we don't always read to the end of the compressed file, ans to the checksum in the trailer is not verified.
Definition at line 58 of file simpverstool.h.
virtual simple_version_tool::~simple_version_tool | ( | ) | [virtual] |
The destructor.
simple_version_tool::simple_version_tool | ( | const nstring & | history_file_name, | |
compression_algorithm_t | comp_alg = compression_algorithm_not_set | |||
) |
The constructor.
&history_file_name | The name of the file being used to store the version history. | |
comp_alg | The compression algorithm to use. Defaults to the best available (may be slow, may use much memory). |
simple_version_tool::simple_version_tool | ( | ) | [private] |
The default constructor. Do not use.
simple_version_tool::simple_version_tool | ( | const simple_version_tool & | ) | [private] |
The copy constructor. Do not use.
The checkin method is used to add another version to the file history. It will be stored in the history file supplied to the constructor.
input_file_name | The name of the file to read for the latest version of the file. | |
meta_data | Additional information to include in the file header. |
void simple_version_tool::checkin | ( | const nstring & | input_file_name | ) |
The checkin method is used to add another version to the file history. It will be stored in the history file supplied to the constructor.
input_file_name | The name of the file to read for the latest version of the file. |
bool simple_version_tool::list | ( | rfc822_functor & | arg | ) |
The checkout method is used to extract version of the file from the history archive.
output_file_name | The name of the file in which to write for the selected version of the file. (The file name "-" understood to mean the standard output.) | |
version | The version of the file to extract. Version zero is understood to mean the head revision (the most recently checked in version). |
void simple_version_tool::checkout | ( | output::pointer | os, | |
const nstring & | version | |||
) |
The checkout method is used to extract version of the file from the history archive.
os | The output stream on which the selected file version is to be written. | |
version | The version of the file to extract. Version zero is understood to mean the head revision (the most recently checked in version). |
simple_version_tool& simple_version_tool::operator= | ( | const simple_version_tool & | ) | [private] |
The assignment operator. Do not use.
The &history_file_name instance variable is used to remember the name of the file being used to store the version history.
Definition at line 146 of file simpverstool.h.
The compression algorithm
Definition at line 151 of file simpverstool.h.