From c9fa963e71258c5adfb71cf1996cd1bcb33df0bb Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 26 Feb 2023 08:54:17 +0100 Subject: Start with copy of whiteboard --- diff.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 diff.h (limited to 'diff.h') diff --git a/diff.h b/diff.h new file mode 100644 index 0000000..5c2c335 --- /dev/null +++ b/diff.h @@ -0,0 +1,37 @@ +#pragma once + +#include + +#include + +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); +} -- cgit v1.2.3