wex v26.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:
Inheritance graph

Public Types

enum class  diff_t { FIRST , OTHER , LAST , UNKNOWN }
 Type for this diff. More...

Public Member Functions

 unified_diff (std::string input=std::string())
 Constructor.
virtual ~unified_diff ()=default
 Destructor.
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 during parsing.
const std::string & input () const
 Returns input.
bool is_first () const
 Returns true if this is the first diff of a hunk.
bool is_last () const
 Returns true if this is the last diff of a hunk.
bool parse ()
 Parses the input.
const pathpath_from () const
 Returns path from.
const pathpath_to () const
 Returns path to.
int range_from_start () const
 Returns start number for the from file.
int range_from_count () const
 Returns count number for the from file.
int range_to_start () const
 Returns start number for the to file.
int range_to_count () const
 Returns count number for the to file.
const std::vector< std::string > & text_added () const
 Returns text added.
const std::vector< std::string > & text_removed () const
 Returns text removed.
void trace (const std::string &text) const
 Logs this diff as trace logging.
diff_t type () const
 Returns the difference type.
void type_from (const unified_diff &org)
 Copies type from org.

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).

Member Enumeration Documentation

◆ diff_t

Type for this diff.

Enumerator
FIRST 

the first diff from input

OTHER 

other diffs from input

LAST 

the last diff from input

UNKNOWN 

no diff found

Constructor & Destructor Documentation

◆ unified_diff()

wex::factory::unified_diff::unified_diff ( 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.