summaryrefslogtreecommitdiffhomepage
path: root/diff.h
blob: 5c2c33585ee158426801fc95fdcc302b801c6125 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once

#include <string>

#include <boost/property_tree/ptree.hpp>

class Diff
{
public:
 Diff();
 Diff(const std::string& old_version, const std::string& new_version);
 void create(const std::string& old_version, const std::string& new_version);

 Diff(const boost::property_tree::ptree& ptree);
 void create(const boost::property_tree::ptree& ptree);

 Diff(const std::string& xml);
 void create(const std::string& xml);

 std::string apply(const std::string& old_version) const;

 bool empty() const;

 boost::property_tree::ptree get_structure() const;
 std::string get_xml() const;

private:
 // diff replaces space from m_pos0 (inclusive) to m_pos1 (exclusive) with m_data
 size_t m_pos0{};
 size_t m_pos1{};
 std::string m_data;
};

extern "C" {
 const char* diff_create(const char* old_version, const char* new_version);
 const char* diff_apply(const char* old_version, const char* diff);
}