summaryrefslogtreecommitdiffstats
path: root/src/tools/tracegen/helpers.h
blob: ea6db016a6c0ddb98933e1b9aa515f89dc06b804 (plain)
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
// Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Rafael Roquetto <rafael.roquetto@kdab.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#ifndef HELPERS_H
#define HELPERS_H

#include "provider.h"

#include <qlist.h>
#include <qstring.h>
#include <qtextstream.h>

enum ParamType {
    LTTNG,
    ETW,
    CTF
};

QString typeToTypeName(const QString &type);
QString includeGuard(const QString &filename);
QString formatFunctionSignature(const QList<Tracepoint::Argument> &args);
QString formatParameterList(const Provider &provider, const QList<Tracepoint::Argument> &args, const QList<Tracepoint::Field> &fields, ParamType type);

void writeCommonPrologue(QTextStream &stream);

template <typename T>
static QString aggregateListValues(int value, const QList<T> &list)
{
    QStringList values;
    for (const T &l : list) {
        if (l.value == value)
            values << l.name;
    }
    return values.join(QLatin1Char('_'));
}

#endif // HELPERS_H