| 1527 | */ |
| 1528 | public: |
| 1529 | static string_t diff_toDelta(const Diffs &diffs) { |
| 1530 | string_t text; |
| 1531 | for (typename Diffs::const_iterator cur_diff = diffs.begin(); cur_diff != diffs.end(); ++cur_diff) { |
| 1532 | switch ((*cur_diff).operation) { |
| 1533 | case INSERT: { |
| 1534 | text += traits::from_wchar(L'+'); |
| 1535 | append_percent_encoded(text, (*cur_diff).text); |
| 1536 | text += traits::from_wchar(L'\t'); |
| 1537 | break; |
| 1538 | } |
| 1539 | case DELETE: |
| 1540 | text += traits::from_wchar(L'-') + to_string((*cur_diff).text.length()) + traits::from_wchar(L'\t'); |
| 1541 | break; |
| 1542 | case EQUAL: |
| 1543 | text += traits::from_wchar(L'=') + to_string((*cur_diff).text.length()) + traits::from_wchar(L'\t'); |
| 1544 | break; |
| 1545 | } |
| 1546 | } |
| 1547 | if (!text.empty()) { |
| 1548 | // Strip off trailing tab character. |
| 1549 | text = text.substr(0, text.length() - 1); |
| 1550 | } |
| 1551 | return text; |
| 1552 | } |
| 1553 | |
| 1554 | /** |
| 1555 | * Given the original text1, and an encoded string which describes the |