blob: 9040c7ad9dd195e484d8e8e3e800c9048e9d28f1 (
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
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef CONFIGURABLESCOPE_H
#define CONFIGURABLESCOPE_H
#include <textstream.h>
#include <configurabletypeentry.h>
/// Enclose a scope within preprocessor conditions for configurable entries
class ConfigurableScope
{
public:
explicit ConfigurableScope(TextStream &s, const ConfigurableTypeEntryCPtr &t) :
m_stream(s),
m_hasConfigCondition(t->hasConfigCondition())
{
if (m_hasConfigCondition)
m_stream << t->configCondition() << '\n';
}
~ConfigurableScope()
{
if (m_hasConfigCondition)
m_stream << "#endif\n";
}
private:
TextStream &m_stream;
const bool m_hasConfigCondition;
};
#endif // CONFIGURABLESCOPE_H
|