1 | // Copyright (C) 2022 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 QCANDBCFILEPARSER_H |
5 | #define QCANDBCFILEPARSER_H |
6 | |
7 | #include <QtCore/QList> |
8 | |
9 | #include <QtSerialBus/qcancommondefinitions.h> |
10 | #include <QtSerialBus/qtserialbusglobal.h> |
11 | |
12 | #include <memory> |
13 | |
14 | QT_BEGIN_NAMESPACE |
15 | |
16 | class QCanDbcFileParserPrivate; |
17 | class QCanMessageDescription; |
18 | class QCanUniqueIdDescription; |
19 | |
20 | class QCanDbcFileParser |
21 | { |
22 | public: |
23 | enum class Error : quint8 { |
24 | None = 0, |
25 | FileReading, |
26 | Parsing |
27 | }; |
28 | |
29 | // The DBC protocol uses unsigned_integer to describe the supported values. |
30 | // Do we need to use QVariant instead of quint32? Or qint64 for better BC |
31 | // guarantees? |
32 | using ValueDescriptions = QHash<quint32, QString>; |
33 | using SignalValueDescriptions = QHash<QString, ValueDescriptions>; |
34 | using MessageValueDescriptions = QHash<QtCanBus::UniqueId, SignalValueDescriptions>; |
35 | |
36 | Q_SERIALBUS_EXPORT QCanDbcFileParser(); |
37 | Q_SERIALBUS_EXPORT ~QCanDbcFileParser(); |
38 | |
39 | Q_SERIALBUS_EXPORT bool parse(const QString &fileName); |
40 | Q_SERIALBUS_EXPORT bool parse(const QStringList &fileNames); |
41 | |
42 | Q_SERIALBUS_EXPORT QList<QCanMessageDescription> messageDescriptions() const; |
43 | Q_SERIALBUS_EXPORT MessageValueDescriptions messageValueDescriptions() const; |
44 | |
45 | Q_SERIALBUS_EXPORT Error error() const; |
46 | Q_SERIALBUS_EXPORT QString errorString() const; |
47 | Q_SERIALBUS_EXPORT QStringList warnings() const; |
48 | |
49 | Q_SERIALBUS_EXPORT static QCanUniqueIdDescription uniqueIdDescription(); |
50 | |
51 | private: |
52 | std::unique_ptr<QCanDbcFileParserPrivate> d; |
53 | friend class QCanDbcFileParserPrivate; |
54 | |
55 | Q_DISABLE_COPY_MOVE(QCanDbcFileParser) |
56 | }; |
57 | |
58 | QT_END_NAMESPACE |
59 | |
60 | #endif // QCANDBCFILEPARSER_H |
61 |