aboutsummaryrefslogtreecommitdiff
path: root/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/kconfig_compiler/KConfigCodeGeneratorBase.cpp')
-rw-r--r--src/kconfig_compiler/KConfigCodeGeneratorBase.cpp64
1 files changed, 29 insertions, 35 deletions
diff --git a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp
index 574aeff4..5a110b2e 100644
--- a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp
+++ b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp
@@ -34,13 +34,7 @@
#include <ostream>
#include <QDebug>
-using std::endl;
-
-namespace
-{
-QTextStream cout(stdout);
-QTextStream cerr(stderr);
-}
+#include <iostream>
KConfigCodeGeneratorBase::KConfigCodeGeneratorBase(
const QString &inputFile,
@@ -52,7 +46,7 @@ KConfigCodeGeneratorBase::KConfigCodeGeneratorBase(
{
m_file.setFileName(m_fileName);
if (!m_file.open(QIODevice::WriteOnly)) {
- cerr << "Can not open '" << m_fileName << "for writing." << endl;
+ std::cerr << "Can not open '" << qPrintable(m_fileName) << "for writing." << std::endl;
exit(1);
}
m_stream.setDevice(&m_file);
@@ -106,7 +100,7 @@ QString KConfigCodeGeneratorBase::whitespace() const
void KConfigCodeGeneratorBase::startScope()
{
m_stream << whitespace() << QLatin1Char('{');
- m_stream << endl;
+ m_stream << '\n';
indent();
}
@@ -117,23 +111,23 @@ void KConfigCodeGeneratorBase::endScope(ScopeFinalizer finalizer)
if (finalizer == ScopeFinalizer::Semicolon) {
m_stream << ';';
}
- m_stream << endl;
+ m_stream << '\n';
}
void KConfigCodeGeneratorBase::start()
{
const QString m_fileName = QFileInfo(m_inputFile).fileName();
- m_stream << "// This file is generated by kconfig_compiler_kf5 from " << m_fileName << ".kcfg" << "." << endl;
- m_stream << "// All changes you do to this file will be lost." << endl;
+ m_stream << "// This file is generated by kconfig_compiler_kf5 from " << m_fileName << ".kcfg" << ".\n";
+ m_stream << "// All changes you do to this file will be lost.\n";
}
void KConfigCodeGeneratorBase::addHeaders(const QStringList &headerList)
{
for (auto include : qAsConst(headerList)) {
if (include.startsWith(QLatin1Char('"'))) {
- m_stream << "#include " << include << endl;
+ m_stream << "#include " << include << '\n';
} else {
- m_stream << "#include <" << include << ">" << endl;
+ m_stream << "#include <" << include << ">\n";
}
}
}
@@ -144,9 +138,9 @@ void KConfigCodeGeneratorBase::beginNamespaces()
{
if (!m_cfg.nameSpace.isEmpty()) {
for (const QString &ns : m_cfg.nameSpace.split(QStringLiteral("::"))) {
- m_stream << "namespace " << ns << " {" << endl;
+ m_stream << "namespace " << ns << " {\n";
}
- m_stream << endl;
+ m_stream << '\n';
}
}
@@ -155,10 +149,10 @@ void KConfigCodeGeneratorBase::beginNamespaces()
void KConfigCodeGeneratorBase::endNamespaces()
{
if (!m_cfg.nameSpace.isEmpty()) {
- m_stream << endl;
+ m_stream << '\n';
const int namespaceCount = m_cfg.nameSpace.count(QStringLiteral("::")) + 1;
for (int i = 0; i < namespaceCount; ++i) {
- m_stream << "}" << endl;
+ m_stream << "}\n";
}
}
}
@@ -185,7 +179,7 @@ QString KConfigCodeGeneratorBase::memberAccessorBody(const CfgEntry *e, bool glo
if (useEnumType) {
out << ")";
}
- out << ";" << endl;
+ out << ";\n";
return result;
}
@@ -233,23 +227,23 @@ void KConfigCodeGeneratorBase::memberMutatorBody(const CfgEntry *e)
// HACK: Don't open '{' manually, use startScope / endScope to automatically handle whitespace indentation.
if (!e->min.isEmpty()) {
if (e->min != QLatin1String("0") || !isUnsigned(t)) { // skip writing "if uint<0" (#187579)
- m_stream << whitespace() << "if (v < " << e->min << ")" << endl;
- m_stream << whitespace() << "{" << endl;
+ m_stream << whitespace() << "if (v < " << e->min << ")\n";
+ m_stream << whitespace() << "{\n";
m_stream << whitespace(); addDebugMethod(m_stream, m_cfg, n);
- m_stream << ": value \" << v << \" is less than the minimum value of " << e->min << "\";" << endl;
- m_stream << whitespace() << " v = " << e->min << ";" << endl;
- m_stream << whitespace() << "}" << endl;
+ m_stream << ": value \" << v << \" is less than the minimum value of " << e->min << "\";\n";
+ m_stream << whitespace() << " v = " << e->min << ";\n";
+ m_stream << whitespace() << "}\n";
}
}
if (!e->max.isEmpty()) {
- m_stream << endl;
- m_stream << whitespace() << "if (v > " << e->max << ")" << endl;
- m_stream << whitespace() << "{" << endl;
+ m_stream << '\n';
+ m_stream << whitespace() << "if (v > " << e->max << ")\n";
+ m_stream << whitespace() << "{\n";
m_stream << whitespace(); addDebugMethod(m_stream, m_cfg, n);
- m_stream << ": value \" << v << \" is greater than the maximum value of " << e->max << "\";" << endl;
- m_stream << whitespace() << " v = " << e->max << ";" << endl;
- m_stream << whitespace() << "}" << endl << endl;
+ m_stream << ": value \" << v << \" is greater than the maximum value of " << e->max << "\";\n";
+ m_stream << whitespace() << " v = " << e->max << ";\n";
+ m_stream << whitespace() << "}\n\n";
}
const QString varExpression = m_this + varPath(n, m_cfg) + (e->param.isEmpty() ? QString() : QStringLiteral("[i]"));
@@ -259,19 +253,19 @@ void KConfigCodeGeneratorBase::memberMutatorBody(const CfgEntry *e)
// m_this call creates an `if (someTest ...) that's just to long to throw over the code.
createIfSetLogic(e, varExpression);
- m_stream << (hasBody ? " {" : "") << endl;
- m_stream << whitespace() << " " << varExpression << " = v;" << endl;
+ m_stream << (hasBody ? " {" : "") << '\n';
+ m_stream << whitespace() << " " << varExpression << " = v;\n";
const auto listSignal = e->signalList;
for (const Signal &signal : qAsConst(listSignal)) {
if (signal.modify) {
- m_stream << whitespace() << " Q_EMIT " << m_this << signal.name << "();" << endl;
+ m_stream << whitespace() << " Q_EMIT " << m_this << signal.name << "();\n";
} else {
m_stream << whitespace() << " " << m_this << varPath(QStringLiteral("settingsChanged"), m_cfg)
- << " |= " << signalEnumName(signal.name) << ";" << endl;
+ << " |= " << signalEnumName(signal.name) << ";\n";
}
}
if (hasBody) {
- m_stream << whitespace() << "}" << endl;
+ m_stream << whitespace() << "}\n";
}
}