umbrello 2.39.2 Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology

- Main Page
- Related Pages
- Topics
- Namespaces
- Classes
- Files

- File List
- File Members

cppwriter.h
Go to the documentation of this file.
1/*
2 SPDX-License-Identifier: GPL-2.0-or-later
3
4 SPDX-FileCopyrightText: 2003 Brian Thomas
5 <brian.thomas@gsfc.nasa.gov>
6 SPDX-FileCopyrightText: 2004-2021 Umbrello UML Modeller Authors
7 <umbrello-devel@kde.org>
8*/
9
10#ifndef CPPWRITER_H
11#define CPPWRITER_H
12
13#include "simplecodegenerator.h"
14#include "cppcodegenerationpolicy.h"
15#include "umloperationlist.h"
16#include "umlattributelist.h"
17#include "umlassociationlist.h"
18
19 class QFile;
20
31 class CppWriter : public SimpleCodeGenerator
32{
33 public:
34
35 CppWriter();
36 virtual ~CppWriter();
37
38 virtual void writeClass(UMLClassifier *c);
39
40 virtual Uml::ProgrammingLanguage::Enum language() const;
41
42 QStringList defaultDatatypes() const;
43
44 virtual QStringList reservedKeywords() const;
45
46 private:
47 void writeIncludes(UMLClassifier *c, QTextStream &cpp);
48 void writeClassDecl(UMLClassifier *c, QTextStream &cpp);
49 void writeConstructorDecls(QTextStream &h);
50 void writeConstructorMethods(UMLClassifier * c, QTextStream &cpp);
51
52// /**
53// * Write all field declarations, for both attributes and associations for the
54// * given permitted scope.
55// */
56// void writeFieldDecl(UMLClassifier *c, Uml::Visibility::Enum permitScope, QTextStream &stream);
57
58// /**
59// * Write all method declarations, for attributes and associations
60// * for the given permitted scope.
61// */
62// void writeAccessorMethodDecl(UMLClassifier *c, Uml::Visibility::Enum permitScope, QTextStream &stream);
63
64 void writeOperations(UMLClassifier *c, bool isHeaderMethod, Uml::Visibility::Enum permitScope, QTextStream &cpp);
65 void writeOperations(UMLClassifier *c, UMLOperationList &oplist, bool isHeaderMethod, QTextStream &cpp);
66
67// /**
68// * Write all attributes for a given class.
69// * @param c the class for which we are generating code
70// * @param j the stream associated with the output file
71// */
72// void writeAttributes(UMLClassifier *c, QTextStream &j);
73
74 void writeAttributeDecls(UMLClassifier *c, Uml::Visibility::Enum visibility, bool writeStatic, QTextStream &stream);
75
76 void writeHeaderFieldDecl(UMLClassifier *c, Uml::Visibility::Enum permitVisibility, QTextStream &stream);
77
78 void writeHeaderAttributeAccessorMethods(UMLClassifier *c, Uml::Visibility::Enum visibility, bool writeStatic, QTextStream &stream);
79
80 void writeHeaderAttributeAccessorMethodDecls(UMLClassifier *c, Uml::Visibility::Enum permitVisibility, QTextStream &stream);
81 void writeHeaderAccessorMethodDecl(UMLClassifier *c, Uml::Visibility::Enum permitScope, QTextStream &stream);
82
83 void writeAssociationDecls(UMLAssociationList associations, Uml::Visibility::Enum permit, Uml::ID::Type id, QTextStream &stream);
84
85 void writeAssociationRoleDecl(QString fieldClassName, QString roleName, QString multi,
86 QString doc, QTextStream &stream);
87
88 void writeAttributeMethods(UMLAttributeList attribs, Uml::Visibility::Enum visib, bool isHeaderMethod,
89 bool isStatic,
90 bool writeMethodBody, QTextStream &stream);
91
92 void writeAssociationMethods(UMLAssociationList associations, Uml::Visibility::Enum permitVisib,
93 bool isHeaderMethod,
94 bool writeMethodBody, bool writePointerVar, Uml::ID::Type id, QTextStream &stream);
95
96 void writeAssociationRoleMethod(const QString &fieldClassName, bool isHeaderMethod, bool writeMethodBody,
97 const QString &roleName, const QString &multi,
98 const QString &description, Uml::Changeability::Enum change,
99 QTextStream &stream);
100
101 void writeSingleAttributeAccessorMethods(
102 const QString &fieldClassName, const QString &Name,
103 const QString &fieldName, const QString &description,
104 Uml::Changeability::Enum change,
105 bool isHeaderMethod,
106 bool isStatic, bool writeMethodBody, QTextStream &cpp);
107
108 void writeVectorAttributeAccessorMethods(
109 const QString &fieldClassName, const QString &fieldVarName,
110 const QString &fieldName, const QString &description,
111 Uml::Changeability::Enum change,
112 bool isHeaderMethod,
113 bool writeMethodBody,
114 QTextStream &stream);
115
116 void writeComment(const QString &text, const QString &indent, QTextStream &cpp);
117 void writeDocumentation(QString header, QString body, QString end, QTextStream &cpp);
118
119 void writeHeaderFile(UMLClassifier *c, QFile &file);
120 void writeSourceFile(UMLClassifier *c, QFile &file);
121
122 void printTextAsSeparateLinesWithIndent (const QString &text, const QString &indent,
123 QTextStream &stream);
124
125 void printAssociationIncludeDecl(UMLAssociationList list, Uml::ID::Type this_id, QTextStream &stream);
126
127 void writeInitAttributeMethod(UMLClassifier * c, QTextStream &stream);
128 void writeInitAttributeDecl(UMLClassifier * c, QTextStream &stream);
129 void writeDataTypes(UMLClassifier *c, Uml::Visibility::Enum permitScope, QTextStream &stream);
130
131 QString umlObjectName(UMLObject *obj);
132
133 QString fixTypeName(const QString &string);
134 QString fixInitialStringDeclValue(const QString &value, const QString &type);
135
136 QString getAttributeVariableName(UMLAttribute *at);
137 QString getAttributeMethodBaseName(const QString &fieldName);
138
139 void writeBlankLine(QTextStream &stream);
140
141 CPPCodeGenerationPolicy *policyExt();
142
143 QString VECTOR_METHOD_APPEND;
144 QString VECTOR_METHOD_REMOVE;
145 QString VECTOR_METHOD_INIT;
146 QString OBJECT_METHOD_INIT;
147
151 bool INLINE_ASSOCIATION_METHODS;
152
153 QStringList ObjectFieldVariables;
154 QStringList VectorFieldVariables;
155 bool m_stringIncludeRequired;
156};
157
158
159#endif // CPPWRITER_H
CPPCodeGenerationPolicy
Definition cppcodegenerationpolicy.h:19
CppWriter
Definition cppwriter.h:32
CppWriter::VECTOR_METHOD_APPEND
QString VECTOR_METHOD_APPEND
Definition cppwriter.h:143
CppWriter::writeAssociationMethods
void writeAssociationMethods(UMLAssociationList associations, Uml::Visibility::Enum permitVisib, bool isHeaderMethod, bool writeMethodBody, bool writePointerVar, Uml::ID::Type id, QTextStream &stream)
Definition cppwriter.cpp:789
CppWriter::CppWriter
CppWriter()
Definition cppwriter.cpp:41
CppWriter::writeHeaderAccessorMethodDecl
void writeHeaderAccessorMethodDecl(UMLClassifier *c, Uml::Visibility::Enum permitScope, QTextStream &stream)
Definition cppwriter.cpp:174
CppWriter::writeConstructorMethods
void writeConstructorMethods(UMLClassifier *c, QTextStream &cpp)
Definition cppwriter.cpp:1124
CppWriter::getAttributeVariableName
QString getAttributeVariableName(UMLAttribute *at)
Definition cppwriter.cpp:1415
CppWriter::writeVectorAttributeAccessorMethods
void writeVectorAttributeAccessorMethods(const QString &fieldClassName, const QString &fieldVarName, const QString &fieldName, const QString &description, Uml::Changeability::Enum change, bool isHeaderMethod, bool writeMethodBody, QTextStream &stream)
Definition cppwriter.cpp:866
CppWriter::writeBlankLine
void writeBlankLine(QTextStream &stream)
Definition cppwriter.cpp:1391
CppWriter::writeHeaderFieldDecl
void writeHeaderFieldDecl(UMLClassifier *c, Uml::Visibility::Enum permitVisibility, QTextStream &stream)
Definition cppwriter.cpp:197
CppWriter::writeSingleAttributeAccessorMethods
void writeSingleAttributeAccessorMethods(const QString &fieldClassName, const QString &Name, const QString &fieldName, const QString &description, Uml::Changeability::Enum change, bool isHeaderMethod, bool isStatic, bool writeMethodBody, QTextStream &cpp)
Definition cppwriter.cpp:948
CppWriter::writeDocumentation
void writeDocumentation(QString header, QString body, QString end, QTextStream &cpp)
Definition cppwriter.cpp:655
CppWriter::writeAttributeDecls
void writeAttributeDecls(UMLClassifier *c, Uml::Visibility::Enum visibility, bool writeStatic, QTextStream &stream)
Definition cppwriter.cpp:517
CppWriter::ObjectFieldVariables
QStringList ObjectFieldVariables
Definition cppwriter.h:153
CppWriter::fixTypeName
QString fixTypeName(const QString &string)
Definition cppwriter.cpp:1179
CppWriter::printTextAsSeparateLinesWithIndent
void printTextAsSeparateLinesWithIndent(const QString &text, const QString &indent, QTextStream &stream)
Definition cppwriter.cpp:1400
CppWriter::getAttributeMethodBaseName
QString getAttributeMethodBaseName(const QString &fieldName)
Definition cppwriter.cpp:1427
CppWriter::fixInitialStringDeclValue
QString fixInitialStringDeclValue(const QString &value, const QString &type)
Definition cppwriter.cpp:1365
CppWriter::writeAssociationDecls
void writeAssociationDecls(UMLAssociationList associations, Uml::Visibility::Enum permit, Uml::ID::Type id, QTextStream &stream)
Definition cppwriter.cpp:692
CppWriter::~CppWriter
virtual ~CppWriter()
Definition cppwriter.cpp:68
CppWriter::writeOperations
void writeOperations(UMLClassifier *c, bool isHeaderMethod, Uml::Visibility::Enum permitScope, QTextStream &cpp)
Definition cppwriter.cpp:1197
CppWriter::writeHeaderAttributeAccessorMethodDecls
void writeHeaderAttributeAccessorMethodDecls(UMLClassifier *c, Uml::Visibility::Enum permitVisibility, QTextStream &stream)
CppWriter::VECTOR_METHOD_INIT
QString VECTOR_METHOD_INIT
Definition cppwriter.h:145
CppWriter::defaultDatatypes
QStringList defaultDatatypes() const
Definition cppwriter.cpp:1439
CppWriter::language
virtual Uml::ProgrammingLanguage::Enum language() const
Definition cppwriter.cpp:76
CppWriter::umlObjectName
QString umlObjectName(UMLObject *obj)
Definition cppwriter.cpp:1383
CppWriter::policyExt
CPPCodeGenerationPolicy * policyExt()
Definition cppwriter.cpp:84
CppWriter::writeInitAttributeMethod
void writeInitAttributeMethod(UMLClassifier *c, QTextStream &stream)
Definition cppwriter.cpp:1068
CppWriter::VectorFieldVariables
QStringList VectorFieldVariables
Definition cppwriter.h:154
CppWriter::writeAttributeMethods
void writeAttributeMethods(UMLAttributeList attribs, Uml::Visibility::Enum visib, bool isHeaderMethod, bool isStatic, bool writeMethodBody, QTextStream &stream)
Definition cppwriter.cpp:596
CppWriter::writeHeaderAttributeAccessorMethods
void writeHeaderAttributeAccessorMethods(UMLClassifier *c, Uml::Visibility::Enum visibility, bool writeStatic, QTextStream &stream)
Definition cppwriter.cpp:577
CppWriter::writeDataTypes
void writeDataTypes(UMLClassifier *c, Uml::Visibility::Enum permitScope, QTextStream &stream)
Definition cppwriter.cpp:1161
CppWriter::INLINE_ASSOCIATION_METHODS
bool INLINE_ASSOCIATION_METHODS
Definition cppwriter.h:151
CppWriter::writeInitAttributeDecl
void writeInitAttributeDecl(UMLClassifier *c, QTextStream &stream)
Definition cppwriter.cpp:1058
CppWriter::writeIncludes
void writeIncludes(UMLClassifier *c, QTextStream &cpp)
Definition cppwriter.cpp:337
CppWriter::writeSourceFile
void writeSourceFile(UMLClassifier *c, QFile &file)
Definition cppwriter.cpp:213
CppWriter::printAssociationIncludeDecl
void printAssociationIncludeDecl(UMLAssociationList list, Uml::ID::Type this_id, QTextStream &stream)
Definition cppwriter.cpp:1336
CppWriter::writeHeaderFile
void writeHeaderFile(UMLClassifier *c, QFile &file)
Definition cppwriter.cpp:144
CppWriter::OBJECT_METHOD_INIT
QString OBJECT_METHOD_INIT
Definition cppwriter.h:146
CppWriter::writeComment
void writeComment(const QString &text, const QString &indent, QTextStream &cpp)
Definition cppwriter.cpp:632
CppWriter::writeConstructorDecls
void writeConstructorDecls(QTextStream &h)
Definition cppwriter.cpp:1034
CppWriter::writeAssociationRoleDecl
void writeAssociationRoleDecl(QString fieldClassName, QString roleName, QString multi, QString doc, QTextStream &stream)
Definition cppwriter.cpp:736
CppWriter::m_stringIncludeRequired
bool m_stringIncludeRequired
Definition cppwriter.h:155
CppWriter::writeClass
virtual void writeClass(UMLClassifier *c)
Definition cppwriter.cpp:93
CppWriter::VECTOR_METHOD_REMOVE
QString VECTOR_METHOD_REMOVE
Definition cppwriter.h:144
CppWriter::reservedKeywords
virtual QStringList reservedKeywords() const
Definition cppwriter.cpp:1448
CppWriter::writeAssociationRoleMethod
void writeAssociationRoleMethod(const QString &fieldClassName, bool isHeaderMethod, bool writeMethodBody, const QString &roleName, const QString &multi, const QString &description, Uml::Changeability::Enum change, QTextStream &stream)
Definition cppwriter.cpp:842
CppWriter::writeClassDecl
void writeClassDecl(UMLClassifier *c, QTextStream &cpp)
Definition cppwriter.cpp:363
SimpleCodeGenerator
Definition simplecodegenerator.h:30
SimpleCodeGenerator::indent
QString indent()
Definition simplecodegenerator.cpp:69
UMLAttributeList
Definition umlattributelist.h:21
UMLAttribute
Sets up attribute information.
Definition attribute.h:23
UMLClassifier
Information for a non-graphical Concept/Class.
Definition classifier.h:35
UMLObject
The base class for UML objects.
Definition umlobject.h:70
cppcodegenerationpolicy.h
description
static const char description[]
Definition main.cpp:32
Uml::Changeability::Enum
Enum
Definition basictypes.h:202
Uml::ID::Type
std::string Type
Definition basictypes.h:371
Uml::ProgrammingLanguage::Enum
Enum
Definition basictypes.h:291
Uml::Visibility::Enum
Enum
Definition basictypes.h:45
visibility
Definition visibility.py:1
simplecodegenerator.h
umlassociationlist.h
UMLAssociationList
QList< UMLAssociation * > UMLAssociationList
Definition umlassociationlist.h:14
umlattributelist.h
umloperationlist.h
UMLOperationList
QList< UMLOperation * > UMLOperationList
Definition umloperationlist.h:14