1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QMLDOMCOMPARE_P_H
5#define QMLDOMCOMPARE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qqmldom_global.h"
19#include "qqmldomitem_p.h"
20
21#include <memory>
22
23QT_BEGIN_NAMESPACE
24
25namespace QQmlJS {
26namespace Dom {
27
28bool domCompare(
29 DomItem &i1, DomItem &i2, function_ref<bool(Path, DomItem &, DomItem &)> change,
30 function_ref<bool(DomItem &, const PathEls::PathComponent &, DomItem &)> filter = noFilter,
31 Path p = Path());
32
33enum DomCompareStrList { FirstDiff, AllDiffs };
34
35QMLDOM_EXPORT QStringList domCompareStrList(
36 DomItem &i1, DomItem &i2,
37 function_ref<bool(DomItem &, const PathEls::PathComponent &, DomItem &) const> filter = noFilter,
38 DomCompareStrList stopAtFirstDiff = DomCompareStrList::FirstDiff);
39
40inline QStringList domCompareStrList(
41 MutableDomItem &i1, DomItem &i2,
42 function_ref<bool(DomItem &, const PathEls::PathComponent &, DomItem &) const> filter = noFilter,
43 DomCompareStrList stopAtFirstDiff = DomCompareStrList::FirstDiff)
44{
45 DomItem ii1 = i1.item();
46 return domCompareStrList(i1&: ii1, i2, filter, stopAtFirstDiff);
47}
48
49inline QStringList domCompareStrList(
50 DomItem &i1, MutableDomItem &i2,
51 function_ref<bool(DomItem &, const PathEls::PathComponent &, DomItem &) const> filter = noFilter,
52 DomCompareStrList stopAtFirstDiff = DomCompareStrList::FirstDiff)
53{
54 DomItem ii2 = i2.item();
55 return domCompareStrList(i1, i2&: ii2, filter, stopAtFirstDiff);
56}
57
58inline QStringList domCompareStrList(
59 MutableDomItem &i1, MutableDomItem &i2,
60 function_ref<bool(DomItem &, const PathEls::PathComponent &, DomItem &) const> filter = noFilter,
61 DomCompareStrList stopAtFirstDiff = DomCompareStrList::FirstDiff)
62{
63 DomItem ii1 = i1.item();
64 DomItem ii2 = i2.item();
65 return domCompareStrList(i1&: ii1, i2&: ii2, filter, stopAtFirstDiff);
66}
67
68} // end namespace Dom
69} // end namespace QQmlJS
70
71QT_END_NAMESPACE
72#endif // QMLDOMCOMPARE_P_H
73

source code of qtdeclarative/src/qmldom/qqmldomcompare_p.h