134#define DECLARE_DIFF_SOURCE_HELPERS(decl)\
135decl void ida_export diff_source_merge_region(class diff_source_t *destination, class diff_source_t *source, const diff_range_t &dr);
137#define DECLARE_DIFF_SOURCE_HELPERS(decl)
154 if ( last < r.
start )
161 void _merge_region(diff_source_t *source,
const diff_range_t &dr);
169 diff_source_t(
int id) : dbctx_id(
id) {}
171 virtual ~diff_source_t() {}
181 virtual void init_diff_source() {}
184 virtual void set_range(
const diff_range_t &r) { range = r; }
187 virtual const diff_range_t &get_range()
const {
return range; }
213 diff_source_t * )
const
230 virtual void merge_add(diff_source_t * ,
diffpos_t ) {}
237 virtual void merge_replace(diff_source_t *src,
diffpos_t dpos)
240 merge_add(src, dpos);
247 virtual void merge_region(diff_source_t *src,
const diff_range_t ®ion)
249 diff_source_merge_region(
this, src, region);
255 virtual void dump_merge_results(FILE * )
const {}
259 void test_diffpos_behavior()
const;
260 bool is_valid_position(
diffpos_t dpos)
const
262 return get_range().contains(dpos) && check_position(dpos) == dpos;
264 diff_texts_t print_diff_source(
bool with_details=
true)
const
266 return print_range(
nullptr, with_details);
274 MERGE_POLICY_USE_LOCAL,
275 MERGE_POLICY_USE_REMOTE,
276 MERGE_POLICY_POSTPONE,
305 bool merge_one_region(
size_t n, merge_policy_t merge_policy)
const;
385 diff_source_t *
src2);
409 const char *
const *headers,
413#define PSBS_DIFF_STARS 0x01
414#define PSBS_ONLY_DIFFS 0x02
441 void append(
const T &v,
size_t idx) {
part.push_back(v[idx]); }
466 void eq(
const T &v,
size_t idx)
473 void add(
const T &v,
size_t idx)
480 void sub(
const T &v,
size_t idx)
489 if ( this->
empty() || this->
back().action != wanted_action )
515 lcsdiff_t(
const T &_x,
const T &_y,
size_t _n,
size_t _m)
523 const size_t rows =
n + 1;
524 const size_t cols =
m + 1;
528 for (
size_t i=0; i < rows; ++i )
530 for (
size_t j=0; j < cols; ++j )
532 if ( i == 0 || j == 0 )
536 else if (
x[i - 1] ==
y[j - 1] )
538 table(i, j) = 1 + table(i - 1, j - 1);
542 size_t l = table(i - 1, j);
543 size_t u = table(i, j - 1);
544 table(i, j) = qmax(l, u);
558 while ( i != 0 || j != 0 )
572 else if (
x[i - 1] ==
y[j - 1] )
578 else if ( table(i - 1, j) <= table(i, j - 1) )
588 for (
auto &part :
result )
593 size_t &table(
size_t i,
size_t j)
595 const size_t idx = i * (
m + 1) + j;
635#define DECLARE_TXTDIFF_HELPERS(decl)\
636decl void ida_export txtdiff_t_diff_mod(txtdiff_t *_this);\
637decl void ida_export txtdiff_t_serialize(txtdiff_t *_this, txtdiff_printer_t &printer);
639#define DECLARE_TXTDIFF_HELPERS(decl)
642DECLARE_TXTDIFF_HELPERS(idaman)
646class txtdiff_t :
public lcsdiff_t<qstrvec_t>
656 void diff_mod() { txtdiff_t_diff_mod(
this); }
661 void serialize(txtdiff_printer_t &printer) { txtdiff_t_serialize(
this, printer); }
675 use_mod ? d.diff_mod() : d.diff();
676 for (
const auto &dl : d.result )
678 char c = dl.action ==
TDLA_EQ ?
' '
682 for (
auto &p : dl.part )
683 res->
push_back().sprnt(
"%c %s", c, p.c_str());
688 DECLARE_TXTDIFF_HELPERS(
friend)
691 void _serialize(txtdiff_printer_t &printer);
693#undef DECLARE_TXTDIFF_HELPERS
722#define DECLARE_STRDIFF_HELPERS(decl)\
723decl void ida_export strdiff_t_serialize(strdiff_t *_this, strdiff_printer_t &printer);
725#define DECLARE_STRDIFF_HELPERS(decl)
728DECLARE_STRDIFF_HELPERS(idaman)
732class strdiff_t :
public lcsdiff_t<qstring>
740 void serialize(strdiff_printer_t &printer) { strdiff_t_serialize(
this, printer); }
743 DECLARE_STRDIFF_HELPERS(
friend)
745 void _serialize(strdiff_printer_t &printer);
747#undef DECLARE_STRDIFF_HELPERS
virtual bool get_diff_regions(diff_regions_t *out) override
diff2_engine_t(diff_source_t *_src1, diff_source_t *_src2)
Definition diff3.hpp:360
bool get_diff_region(diff_region_t *out)
A 3-way difference engine.
Definition diff3.hpp:376
virtual bool get_diff_regions(diff_regions_t *out) override
diff3_engine_t(diff_source_t *base, diff_source_t *src1, diff_source_t *src2)
virtual void set_progress(diff_progress_t *p) override
Definition diff3.hpp:388
virtual ~diff3_engine_t()
Definition diff3.hpp:386
virtual void set_progress(diff_progress_t *p)
Definition diff3.hpp:342
diff_source_t * src1
Definition diff3.hpp:331
diff_source_t * src2
Definition diff3.hpp:332
virtual ~diff_engine_t()
Definition diff3.hpp:340
diff_engine_t(diff_source_t *_src1, diff_source_t *_src2)
Definition diff3.hpp:336
virtual bool get_diff_regions(diff_regions_t *out)=0
diff_progress_t * progress
not owned; may be nullptr
Definition diff3.hpp:333
friend class diff3_engine_t
Definition diff3.hpp:329
diff_result_t perform_diff()
result
Definition diff3.hpp:463
void add(const T &v, size_t idx)
vector's item should be added
Definition diff3.hpp:473
void sub(const T &v, size_t idx)
vector's item should be deleted
Definition diff3.hpp:480
void eq(const T &v, size_t idx)
vector's items are equal
Definition diff3.hpp:466
Calculate difference between two vectors.
Definition diff3.hpp:501
const size_t n
left argument size
Definition diff3.hpp:505
lcsdiff_t(const T &_x, const T &_y, size_t _n, size_t _m)
prepare LCS table
Definition diff3.hpp:515
sizevec_t lcs_table
table to store LCS for each step of the calculation
Definition diff3.hpp:507
void diff()
get a difference between two vectors RESULT will contain only TDLA_EQ, TDLA_ADD, TDLA_SUB actions
Definition diff3.hpp:553
result_t result
Definition diff3.hpp:511
const size_t m
right argument size
Definition diff3.hpp:506
const T & y
right argument
Definition diff3.hpp:504
const T & x
left argument
Definition diff3.hpp:503
lcsdiff_res_t< T > result_t
Definition diff3.hpp:510
Reimplementation of vector class from STL.
Definition pro.h:2262
bool empty(void) const
Definition pro.h:2495
const T & back(void) const
Definition pro.h:2502
qvector(void)
Definition pro.h:2374
void push_back(T &&x)
Definition pro.h:2432
size_t size(void) const
Get the number of elements in the qvector.
Definition pro.h:2494
diffpos_check_t
Definition diff3.hpp:107
@ DIFFPOS_BACKWARD
back off to the previous valid position
Definition diff3.hpp:111
@ DIFFPOS_FORWARD
advance to the next valid position
Definition diff3.hpp:110
@ DIFFPOS_CHECK
verify if the position is valid; if not, return the next valid position
Definition diff3.hpp:108
diff_result_t perform_diff3(diff_source_t *base, diff_source_t *src1, diff_source_t *src2, diff_progress_t *progress=nullptr)
Perform 3-way difference.
qvector< diff_text_t > diff_texts_t
Definition diff3.hpp:120
DECLARE_DIFF_SOURCE_HELPERS(idaman) class diff_source_t
A difference source.
Definition diff3.hpp:140
enum merge_policy_t ENUM_SIZE(uint8)
Definition diff3.hpp:271
diff_source_idx_t
standard indexes into dbctx_ids[] and similar arrays
Definition diff3.hpp:125
@ BASE_IDX
Definition diff3.hpp:129
@ LOCAL_IDX
Definition diff3.hpp:127
@ NONE_IDX
Definition diff3.hpp:126
@ REMOTE_IDX
Definition diff3.hpp:128
lcsdiff_result_action_t
diff result actions, lcsdiff_t::diff lcsdiff_t::diff_mod
Definition diff3.hpp:419
@ TDLA_MOD
updated items (new content)
Definition diff3.hpp:423
@ TDLA_SUB
removed items
Definition diff3.hpp:422
@ TDLA_ADD
added items
Definition diff3.hpp:421
@ TDLA_EQ
items are equal
Definition diff3.hpp:420
qvector< diff_region_t > diff_regions_t
Definition diff3.hpp:103
diff_action_t
Definition diff3.hpp:84
@ DIFF_USE1
use information from src1
Definition diff3.hpp:86
@ DIFF_BOTH
use information from both (conflict)
Definition diff3.hpp:88
@ DIFF_USE2
use information from src2
Definition diff3.hpp:87
@ DIFF_NONE
unknown
Definition diff3.hpp:85
DECLARE_TYPE_AS_MOVABLE(diff_range_t)
void(* diff_progress_cb_t)(diffpos_t pos, const diff_range_t &range, void *ud)
Definition diff3.hpp:309
qstrvec_t put_side_by_side(const char *const *headers, const diff_texts_t *const *linevecs, size_t n, int psbs_flags=0)
ssize_t diff_degree_t
A difference degree.
Definition diff3.hpp:80
idaman size_t n
Definition pro.h:1000
cexpr_t * e
Definition hexrays.hpp:7705
idaman int64 pos
Definition kernwin.hpp:1398
asize_t size
Definition kernwin.hpp:6701
void(idaapi *range_marker)(ea_t ea
Pointer to range marker function (for idaviews and hexviews) This pointer is initialized by setup_ran...
unsigned __int64 uint64
Definition llong.hpp:13
qvector< qstring > qstrvec_t
Definition lumina.hpp:831
qvector< size_t > sizevec_t
vector of sizes
Definition pro.h:2841
size_t diffpos_t
Definition pro.h:483
ptrdiff_t ssize_t
Signed size_t - used to check for size overflows when the counter becomes negative.
Definition pro.h:385
constexpr diffpos_t BADDIFF
Definition pro.h:484
unsigned char uint8
unsigned 8 bit value
Definition pro.h:348
_qstring< char > qstring
regular string
Definition pro.h:3771
Diff progress reporting state (shared between diff engines).
Definition diff3.hpp:315
uint64 last_ns
last notification timestamp (internal)
Definition diff3.hpp:318
void * ud
Definition diff3.hpp:317
diff_progress_t()
Definition diff3.hpp:320
diff_progress_t(diff_progress_cb_t _cb, void *_ud)
Definition diff3.hpp:321
diff_progress_cb_t cb
Definition diff3.hpp:316
A range of the difference source.
Definition diff3.hpp:30
diffpos_t end
Definition diff3.hpp:32
void set_start(diffpos_t p)
Definition diff3.hpp:37
bool contains(diffpos_t p) const
Definition diff3.hpp:36
void set_end(diffpos_t p)
Definition diff3.hpp:43
bool operator==(const diff_range_t &r) const
Definition diff3.hpp:61
int compare(const diff_range_t &r) const
Definition diff3.hpp:59
diff_range_t(diffpos_t s=0, diffpos_t e=0)
Definition diff3.hpp:33
void intersect(const diff_range_t &r)
Definition diff3.hpp:49
void clear()
Definition diff3.hpp:35
bool empty() const
Definition diff3.hpp:34
diffpos_t start
Definition diff3.hpp:31
bool operator!=(const diff_range_t &r) const
Definition diff3.hpp:62
A difference region.
Definition diff3.hpp:95
void clear()
Definition diff3.hpp:98
diff_degree_t diff_degree
Definition diff3.hpp:96
bool is_useless() const
Definition diff3.hpp:99
diff_action_t action
Definition diff3.hpp:97
A difference result.
Definition diff3.hpp:287
diff_regions_t regions
Definition diff3.hpp:290
size_t size() const
Definition diff3.hpp:294
diff_source_t * src2
Definition diff3.hpp:289
bool empty() const
Definition diff3.hpp:295
qstrvec_t print_region(const diff_region_t &b, bool with_details=true) const
qstrvec_t print_diff_result(bool with_details=true) const
diff_source_t * src1
Definition diff3.hpp:288
size_t merge_diff_sources(merge_policy_t merge_policy, size_t i1=0, size_t i2=SIZE_MAX)
merge src1 and src2 into src1.
diff_result_t(diff_source_t *s1=nullptr, diff_source_t *s2=nullptr)
Definition diff3.hpp:291
diffpos_t pos
Definition diff3.hpp:117
void reverse()
Definition diff3.hpp:455
void append(const qstring &v, size_t idx)
Definition diff3.hpp:454
qstring part
vector's items
Definition diff3.hpp:448
lcsdiff_res_part_t(lcsdiff_result_action_t _a)
Definition diff3.hpp:452
lcsdiff_result_action_t action
action for items, lcsdiff_result_action_t
Definition diff3.hpp:450
qstring x_part
previous content, only for TDLA_MOD
Definition diff3.hpp:449
difference result, stores vectors' items with action to be applied to construct Y from X
Definition diff3.hpp:434
T x_part
previous content, only for TDLA_MOD
Definition diff3.hpp:436
void append(const T &v, size_t idx)
Definition diff3.hpp:441
T part
vector's items
Definition diff3.hpp:435
void reverse()
Definition diff3.hpp:442
lcsdiff_res_part_t(lcsdiff_result_action_t _a)
Definition diff3.hpp:439
lcsdiff_result_action_t action
action for items, lcsdiff_result_action_t
Definition diff3.hpp:437
virtual void on_event(event_t ev,...)=0
strdiff_printer_t()
Definition diff3.hpp:712
virtual ~strdiff_printer_t()
Definition diff3.hpp:713
event_t
Definition diff3.hpp:700
@ del_chars
deleted chars from line X, TDLA_SUB
Definition diff3.hpp:708
@ add_chars
added chars to line from X, TDLA_ADD
Definition diff3.hpp:706
@ same_chars
the same chars, TDLA_EQ
Definition diff3.hpp:704
@ term_chars
end printing
Definition diff3.hpp:702
@ init_chars
start printing
Definition diff3.hpp:701
event_t
Definition diff3.hpp:606
@ del_line
line is removed from X, TDLA_SUB
Definition diff3.hpp:618
@ next_line
start to print next line
Definition diff3.hpp:611
@ add_line
line is added to X, TDLA_ADD
Definition diff3.hpp:616
@ mod_line
line is changed, TDLA_MOD
Definition diff3.hpp:620
@ init
start printing
Definition diff3.hpp:607
@ same_line
line is the same in X and Y, TDLA_EQ
Definition diff3.hpp:614
@ term
end printing
Definition diff3.hpp:608
txtdiff_printer_t()
Definition diff3.hpp:625
virtual ~txtdiff_printer_t()
Definition diff3.hpp:626
virtual void on_event(event_t ev,...)=0