aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/generator/generator.h
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-03-11 15:54:30 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-03-13 20:32:03 +0000
commit638545a9cc2c72eea34cfba6cb2bd847f31ca80a (patch)
treee4a3f23a3f7685de2ea4e45ba875780d2e6c6c18 /sources/shiboken2/generator/generator.h
parent9c5de3ed310d63a2021d062013ad9779d33028d0 (diff)
shiboken: Make the indentor helper class more flexible
Move it to a separate header and turn it into a non-type template with a tabWidth parameter to make it possible to use it with arbitrary tab widths. Turn it into a non-type template taking the tab width. Change-Id: Ib2b6a7379ce66d1a22e73b4cb6a4a9a9b457014d Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken2/generator/generator.h')
-rw-r--r--sources/shiboken2/generator/generator.h38
1 files changed, 1 insertions, 37 deletions
diff --git a/sources/shiboken2/generator/generator.h b/sources/shiboken2/generator/generator.h
index cdf6d89b3..04840427f 100644
--- a/sources/shiboken2/generator/generator.h
+++ b/sources/shiboken2/generator/generator.h
@@ -29,6 +29,7 @@
#ifndef GENERATOR_H
#define GENERATOR_H
+#include "indentor.h"
#include <abstractmetalang_typedefs.h>
#include <typedatabase_typedefs.h>
#include <dependency.h>
@@ -54,7 +55,6 @@ QT_END_NAMESPACE
class PrimitiveTypeEntry;
class ContainerTypeEntry;
-class Indentor;
QTextStream& formatCode(QTextStream &s, const QString& code, Indentor &indentor);
void verifyDirectoryFor(const QString &file);
@@ -417,41 +417,5 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Generator::Options)
typedef QSharedPointer<Generator> GeneratorPtr;
typedef QVector<GeneratorPtr> Generators;
-/**
-* Utility class to store the identation level, use it in a QTextStream.
-*/
-class Indentor
-{
-public:
- Indentor() : indent(0) {}
- int indent;
-};
-
-/**
-* Class that use the RAII idiom to set and unset the identation level.
-*/
-class Indentation
-{
-public:
- Indentation(Indentor &indentor) : indentor(indentor)
- {
- indentor.indent++;
- }
- ~Indentation()
- {
- indentor.indent--;
- }
-
-private:
- Indentor &indentor;
-};
-
-inline QTextStream &operator <<(QTextStream &s, const Indentor &indentor)
-{
- for (int i = 0; i < indentor.indent; ++i)
- s << " ";
- return s;
-}
-
#endif // GENERATOR_H