monotone

monotone Mtn Source Tree

Root/piece_table.hh

1// -*- mode: C++; c-file-style: "gnu"; indent-tabs-mode: nil -*-
2// copyright (C) 2002, 2003, 2004 graydon hoare <graydon@pobox.com>
3// copyright (C) 2005 christof petig <christof@petig-baender.de>
4// all rights reserved.
5// licensed to the public under the terms of the GNU GPL (>= 2)
6// see the file COPYING for details
7
8#include <string>
9#include <vector>
10
11// piece table stuff
12
13/*
14 * this code efficiently constructs a new revision of a file by breaking
15 * it into lines and applying a rcs diff
16 */
17
18struct
19piece
20{
21 piece(std::string::size_type p, std::string::size_type l, unsigned long id) :
22 pos(p), len(l), string_id(id) {}
23 std::string::size_type pos;
24 std::string::size_type len;
25 unsigned long string_id;
26 std::string operator*() const;
27
28 typedef std::vector<piece> piece_table;
29
30 struct piece_store;
31 static piece_store global_pieces;
32
33 static void index_deltatext(std::string const & dt, piece_table & pieces);
34 static void build_string(piece_table const & pieces, std::string & out);
35 static void apply_diff(piece_table const & source_lines,
36 piece_table & dest_lines,
37 std::string const & deltatext);
38
39 // free allocated storage (invalidates all existing pieces)
40 static void reset();
41};
42

Archive Download this file

Branches

Tags

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