File indexing completed on 2024-11-10 04:40:46

0001 /*
0002     SPDX-FileCopyrightText: 2017 Daniel Vrátil <dvratil@kde.og>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QFile>
0010 #include <QTextStream>
0011 
0012 class Node;
0013 class DocumentNode;
0014 class ClassNode;
0015 class EnumNode;
0016 class PropertyNode;
0017 
0018 class CppGenerator
0019 {
0020 public:
0021     explicit CppGenerator();
0022     ~CppGenerator();
0023 
0024     bool generate(Node const *node);
0025 
0026 private:
0027     bool generateDocument(DocumentNode const *node);
0028     bool generateClass(ClassNode const *node);
0029 
0030 private:
0031     void writeHeaderHeader(DocumentNode const *node);
0032     void writeHeaderFooter(DocumentNode const *node);
0033     void writeHeaderClass(ClassNode const *node);
0034     void writeHeaderEnum(EnumNode const *node);
0035 
0036     void writeImplHeader(DocumentNode const *node);
0037     void writeImplFooter(DocumentNode const *node);
0038     void writeImplSerializer(DocumentNode const *node);
0039     void writeImplClass(ClassNode const *node);
0040     void writeImplSerializer(PropertyNode const *node, const char *streamingOperator);
0041 
0042     void writeImplPropertyDependencies(PropertyNode const *node);
0043 
0044 private:
0045     QFile mHeaderFile;
0046     QTextStream mHeader;
0047     QFile mImplFile;
0048     QTextStream mImpl;
0049 };