8#ifndef KOMPAREDIFF2_PARSERBASE_H
9#define KOMPAREDIFF2_PARSERBASE_H
12#include "difference.h"
15#include <QRegularExpression>
30 ParserBase(
const ModelList *list,
const QStringList &diff);
31 virtual ~ParserBase();
33 static QString escapePath(QString path);
34 static QString unescapePath(QString path);
39 return determineFormat();
42 DiffModelList *parse(
bool *malformed =
nullptr);
45 virtual bool parseContextDiffHeader();
46 virtual bool parseEdDiffHeader();
47 virtual bool parseNormalDiffHeader();
48 virtual bool parseRCSDiffHeader();
49 virtual bool parseUnifiedDiffHeader();
51 virtual bool parseContextHunkHeader();
52 virtual bool parseEdHunkHeader();
53 virtual bool parseNormalHunkHeader();
54 virtual bool parseRCSHunkHeader();
55 virtual bool parseUnifiedHunkHeader();
57 virtual bool parseContextHunkBody();
58 virtual bool parseEdHunkBody();
59 virtual bool parseNormalHunkBody();
60 virtual bool parseRCSHunkBody();
61 virtual bool parseUnifiedHunkBody();
63 virtual DiffModelList *parseContext();
64 virtual DiffModelList *parseEd();
65 virtual DiffModelList *parseNormal();
66 virtual DiffModelList *parseRCS();
67 virtual DiffModelList *parseUnified();
70 bool matchesUnifiedHunkLine(
const QString &line)
const;
71 void checkHeader(
const QRegularExpression &header);
75 virtual Format determineFormat();
79 QRegularExpression m_contextDiffHeader1;
80 QRegularExpression m_contextDiffHeader2;
82 QRegularExpression m_contextHunkHeader1;
83 QRegularExpression m_contextHunkHeader2;
84 QRegularExpression m_contextHunkHeader3;
85 QRegularExpressionMatch m_contextHunkHeader1Match;
86 QRegularExpressionMatch m_contextHunkHeader2Match;
88 QRegularExpression m_contextHunkBodyRemoved;
89 QRegularExpression m_contextHunkBodyAdded;
90 QRegularExpression m_contextHunkBodyChanged;
91 QRegularExpression m_contextHunkBodyContext;
92 QRegularExpression m_contextHunkBodyLine;
95 QRegularExpression m_normalDiffHeader;
97 QRegularExpression m_normalHunkHeaderAdded;
98 QRegularExpression m_normalHunkHeaderRemoved;
99 QRegularExpression m_normalHunkHeaderChanged;
100 QRegularExpressionMatch m_normalHunkHeaderAddedMatch;
101 QRegularExpressionMatch m_normalHunkHeaderRemovedMatch;
102 QRegularExpressionMatch m_normalHunkHeaderChangedMatch;
104 QRegularExpression m_normalHunkBodyRemoved;
105 QRegularExpression m_normalHunkBodyAdded;
106 QRegularExpression m_normalHunkBodyDivider;
108 Difference::Type m_normalDiffType;
111 QRegularExpression m_rcsDiffHeader;
114 QRegularExpression m_unifiedDiffHeader1;
115 QRegularExpression m_unifiedDiffHeader2;
117 QRegularExpression m_unifiedHunkHeader;
118 QRegularExpressionMatch m_unifiedHunkHeaderMatch;
121 const QStringList &m_diffLines;
122 DiffModel *m_currentModel =
nullptr;
123 DiffModelList *m_models =
nullptr;
126 bool m_singleFileDiff =
false;
127 bool m_malformed =
false;
130 const ModelList *m_list;
A model describing the differences between two files.