KompareDiff2

differencestringpair.h
1/*
2SPDX-FileCopyrightText: 2011 Dmitry Risenberg <dmitry.risenberg@gmail.com>
3
4SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#ifndef KOMPAREDIFF2_DIFFERENCESTRINGPAIR_H
8#define KOMPAREDIFF2_DIFFERENCESTRINGPAIR_H
9
10#include <QString>
11
12#include "difference.h"
13
14namespace Diff2 {
15
16class Marker;
17class DifferenceString;
18
19class DifferenceStringPair {
20public:
21 DifferenceStringPair(DifferenceString* first, DifferenceString* second)
22 : m_first(first), m_second(second),
23 m_strFirst(QLatin1Char(' ') + first->string()), m_strSecond(QLatin1Char(' ') + second->string()),
24 m_lengthFirst(m_strFirst.length()), m_lengthSecond(m_strSecond.length()),
25 m_arrayFirst(m_strFirst.unicode()), m_arraySecond(m_strSecond.unicode())
26 {
27 // Actual contents must be indented by 1
28 }
29 bool equal(unsigned int firstIndex, unsigned int secondIndex) const
30 {
31 return m_arrayFirst[firstIndex] == m_arraySecond[secondIndex];
32 }
33 unsigned int lengthFirst() const
34 {
35 return m_lengthFirst;
36 }
37 unsigned int lengthSecond() const
38 {
39 return m_lengthSecond;
40 }
41 MarkerList markerListFirst() const
42 {
43 return m_first->markerList();
44 }
45 MarkerList markerListSecond() const
46 {
47 return m_second->markerList();
48 }
49 void prependFirst(Marker* marker)
50 {
51 m_first->prepend(marker);
52 }
53 void prependSecond(Marker* marker)
54 {
55 m_second->prepend(marker);
56 }
57 bool needFineGrainedOutput(unsigned int difference) const
58 {
59 return difference <= qMax(m_lengthFirst, m_lengthSecond) / 2;
60 }
61 const static bool allowReplace = true;
62private:
63 DifferenceString* m_first;
64 DifferenceString* m_second;
65 QString m_strFirst;
66 QString m_strSecond;
67 unsigned int m_lengthFirst;
68 unsigned int m_lengthSecond;
69 const QChar* m_arrayFirst;
70 const QChar* m_arraySecond;
71};
72
73}
74
75#endif // KOMPAREDIFF2_DIFFERENCESTRINGPAIR_H
Diff2 namespace.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Apr 27 2024 22:10:24 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.