30 #ifndef LIB_DIFF_LIST_DIFF_APPLICATION_H 31 #define LIB_DIFF_LIST_DIFF_APPLICATION_H 62 template<
typename E,
typename...ARGS>
66 using Vec = vector<E,ARGS...>;
67 using Iter =
typename Vec::iterator;
76 return pos_ == orig_.end();
80 __expect_in_target (E
const& elm,
Literal oper)
84 "no (further) elements in target sequence") % oper % elm
85 , LERR_(DIFF_CONFLICT));
88 "found element %s on current target position instead")
90 , LERR_(DIFF_CONFLICT));
94 __expect_further_elements (E
const& elm)
97 throw error::State(
_Fmt(
"Premature end of target sequence, still expecting element %s; " 98 "unable to apply diff further.") % elm
99 , LERR_(DIFF_CONFLICT));
103 __expect_found (E
const& elm, Iter
const& targetPos)
105 if (targetPos == orig_.end())
107 "element %s in the remainder of the target.") % elm
108 , LERR_(DIFF_CONFLICT));
115 ins (E
const& elm)
override 121 del (E
const& elm)
override 123 __expect_in_target(elm,
"remove");
128 pick (E
const& elm)
override 130 __expect_in_target(elm,
"pick");
131 seq_.push_back (move(*pos_));
136 skip (E
const& elm)
override 138 __expect_further_elements (elm);
143 find (E
const& elm)
override 145 __expect_further_elements (elm);
146 Iter found = std::find(pos_, orig_.end(), elm);
147 __expect_found (elm, found);
148 seq_.push_back (move(*found));
159 initDiffApplication()
162 seq_.reserve (orig_.size() * 120 / 100);
163 pos_ = orig_.begin();
167 completeDiffApplication()
169 if (not end_of_target())
170 throw error::State(
_Fmt(
"Not all source data consumed after diff application. " 171 "Element %s waiting to be consumed") % *pos_
172 , LERR_(DIFF_STRUCTURE));
A token language to represent changes in a list of elements.
Interpreter interface to define the operations ("verbs"), which describe differences or changes in a ...
inline string literal This is a marker type to indicate that
A front-end for using printf-style formatting.
Implementation namespace for support and library code.
Derived specific exceptions within Lumiera's exception hierarchy.
Extension point: define how a specific diff language can be applied to elements in a concrete contain...