1#ifndef SOURCEMETA_CORE_DIFF_H_
2#define SOURCEMETA_CORE_DIFF_H_
4#ifndef SOURCEMETA_CORE_DIFF_EXPORT
5#include <sourcemeta/core/diff_export.h>
24namespace sourcemeta::core {
36 enum class Mode : std::uint8_t {
66 enum class Type : std::uint8_t {
86 auto operator==(
const Operation &)
const noexcept ->
bool =
default;
118 std::function<void(std::ostream &stream,
LineType type,
119 std::string_view prefix, std::string_view content)>;
166SOURCEMETA_CORE_DIFF_EXPORT
167auto diff(
const std::string_view original,
const std::string_view modified,
207SOURCEMETA_CORE_DIFF_EXPORT
bool original_ends_with_newline
Whether the original input ended with a line terminator.
Definition diff.h:138
std::vector< std::string_view > original
The tokens of the original input.
Definition diff.h:132
std::vector< std::string_view > modified
The tokens of the modified input.
Definition diff.h:134
bool modified_ends_with_newline
Whether the modified input ended with a line terminator.
Definition diff.h:140
Algorithm
The strategy used to locate the common subsequences of two inputs.
Definition diff.h:42
@ Myers
Definition diff.h:47
std::vector< Operation > operations
The transformations that turn the original input into the modified one.
Definition diff.h:136
Format
The textual serialisation used to render a set of differences.
Definition diff.h:51
@ Unified
Definition diff.h:54
Mode
The granularity at which inputs are compared.
Definition diff.h:36
@ Line
Compare newline-delimited lines.
Definition diff.h:38
SOURCEMETA_CORE_DIFF_EXPORT auto diff(const std::string_view original, const std::string_view modified, const Diff::Mode mode, const Diff::Algorithm algorithm) -> Diff
SOURCEMETA_CORE_DIFF_EXPORT auto stringify(const Diff &document, std::ostream &stream, const Diff::Format format, const Diff::FormatOptions &options={}) -> void