File: dltmessagematcher.h

package info (click to toggle)
dlt-viewer 2.27.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 9,196 kB
  • sloc: cpp: 31,376; ansic: 4,224; xml: 492; sh: 244; makefile: 81
file content (72 lines) | stat: -rw-r--r-- 1,641 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef DLTMESSAGEMATCHER_H
#define DLTMESSAGEMATCHER_H

#include "export_rules.h"

#include <QString>
#include <QRegularExpression>

#include <optional>
#include <variant>

class QDltMsg;

class QDLT_EXPORT DltMessageMatcher
{
public:
    using Pattern = std::variant<QString, QRegularExpression>;

    DltMessageMatcher();

    void setCaseSentivity(Qt::CaseSensitivity caseSensitivity) {
        m_caseSensitivity = caseSensitivity;
    }

    void setSearchAppId(const QString& appId) {
        m_appId = appId;
    }

    void setSearchCtxId(const QString& ctxId) {
        m_ctxId = ctxId;
    }

    void setTimestapmRange(double start, double end) {
        m_timestampRange = {start, end};
    }

    void setHeaderSearchEnabled(bool enabled) {
        m_headerSearchEnabled = enabled;
    }

    void setPayloadSearchEnabled(bool enabled) {
        m_payloadSearchEnabled = enabled;
    }

    void setMessageIdFormat(const QString& msgIdFormat) {
        m_messageIdFormat = msgIdFormat;
    }

    bool match(const QDltMsg& message, const Pattern& pattern) const;
private:
    bool matchAppId(const QString& appId) const;
    bool matchCtxId(const QString& ctxId) const;
    bool matchTimestampRange(unsigned int ts) const;
private:
    QString m_ctxId;
    QString m_appId;

    struct TimestampRange {
        double start;
        double end;
    };
    std::optional<TimestampRange> m_timestampRange;

    Qt::CaseSensitivity m_caseSensitivity{Qt::CaseInsensitive};

    bool m_headerSearchEnabled{true};
    bool m_payloadSearchEnabled{true};

    std::optional<QString> m_messageIdFormat;
};

#endif // DLTMESSAGEMATCHER_H