monotone

monotone Mtn Source Tree

Root/src/xdelta.hh

1// Copyright (C) 2002 Graydon Hoare <graydon@pobox.com>
2//
3// This program is made available under the GNU GPL version 2.0 or
4// greater. See the accompanying file COPYING for details.
5//
6// This program is distributed WITHOUT ANY WARRANTY; without even the
7// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8// PURPOSE.
9
10#ifndef __XDELTA_HH__
11#define __XDELTA_HH__
12
13#include <boost/shared_ptr.hpp>
14#include "vocab.hh"
15
16void
17compute_delta(std::string const & a,
18 std::string const & b,
19 std::string & delta);
20
21void
22apply_delta(std::string const & a,
23 std::string const & delta,
24 std::string & b);
25
26
27// diffing and patching
28
29void diff(data const & olddata,
30 data const & newdata,
31 delta & del);
32
33void patch(data const & olddata,
34 delta const & del,
35 data & newdata);
36
37
38struct delta_applicator
39{
40 virtual ~delta_applicator () {}
41 virtual void begin(std::string const & base) = 0;
42 virtual void next() = 0;
43 virtual void finish(std::string & out) = 0;
44
45 virtual void copy(std::string::size_type pos, std::string::size_type len) = 0;
46 virtual void insert(std::string const & str) = 0;
47};
48
49boost::shared_ptr<delta_applicator> new_simple_applicator();
50boost::shared_ptr<delta_applicator> new_piecewise_applicator();
51
52void apply_delta(boost::shared_ptr<delta_applicator> da,
53 std::string const & delta);
54
55u64 measure_delta_target_size(std::string const & delta);
56void invert_xdelta(std::string const & old_str,
57 std::string const & delta,
58 std::string & delta_inverse);
59
60#endif // __XDELTA_HH__
61
62// Local Variables:
63// mode: C++
64// fill-column: 76
65// c-file-style: "gnu"
66// indent-tabs-mode: nil
67// End:
68// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status