wex v25.04.0
wex::factory::unified_diff Class Reference

Offers a class that parses a unified diff string and report diffs for a derived class. More...

#include <wex/factory/unified-diff.h>

Inheritance diagram for wex::factory::unified_diff:

Public Member Functions

 unified_diff (const std::string &input=std::string())
 Constructor.
 
virtual bool report_diff ()
 Virtual interface.
 
virtual void report_diff_finish ()
 The last diff has been generated, we are finished.
 
size_t differences () const
 Returns number of differences found duing parsing.
 
bool is_first () const
 Returns true if this is the first diff of a chunk.
 
bool is_last () const
 Returns true if this is the last diff of a chunk.
 
bool parse ()
 Parses the input.
 
const auto & path_from () const
 Returns path from.
 
const auto & path_to () const
 Returns path to.
 
const auto & range_from_start () const
 Returns start number for the from file.
 
const auto & range_from_count () const
 Returns count number for the from file.
 
const auto & range_to_start () const
 Returns start number for the to file.
 
const auto & range_to_count () const
 Returns count number for the to file.
 
const auto & text_added () const
 Returns text added.
 
const auto & text_removed () const
 Returns text removed.
 

Detailed Description

Offers a class that parses a unified diff string and report diffs for a derived class.

Context is not expected, you have to create a diff using -U0 (no context).

Constructor & Destructor Documentation

◆ unified_diff()

wex::factory::unified_diff::unified_diff ( const std::string & input = std::string())

Constructor.

Parameters
inputProvide input, that is conform unified diff format output.

Member Function Documentation

◆ parse()

bool wex::factory::unified_diff::parse ( )

Parses the input.

This routine invokes report_diff methods. Returns false on error during parsing.

◆ report_diff()

virtual bool wex::factory::unified_diff::report_diff ( )
inlinevirtual

Virtual interface.

Do something with a diff, and update diff.