umbrello: umbrello/codegenerators/cpp/cppwriter.h Source File

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

cppwriter.h
Go to the documentation of this file.
1 /***************************************************************************
2 * This program is free software; you can redistribute it and/or modify *
3 * it under the terms of the GNU General Public License as published by *
4 * the Free Software Foundation; either version 2 of the License, or *
5 * (at your option) any later version. *
6 * *
7 * copyright (C) 2003 Brian Thomas *
8 * <brian.thomas@gsfc.nasa.gov> *
9 * copyright (C) 2004-2014 Umbrello UML Modeller Authors *
10 * <umbrello-devel@kde.org> *
11 ***************************************************************************/
12
13 #ifndef CPPWRITER_H
14 #define CPPWRITER_H
15
16 #include "simplecodegenerator.h"
17 #include "cppcodegenerationpolicy.h"
18 #include "umloperationlist.h"
19 #include "umlattributelist.h"
20 #include "umlassociationlist.h"
21
22 class QFile;
23
34 class CppWriter : public SimpleCodeGenerator
35 {
36 public:
37
38 CppWriter();
39 virtual ~CppWriter();
40
41 virtual void writeClass(UMLClassifier *c);
42
43 virtual Uml::ProgrammingLanguage::Enum language() const;
44
45 QStringList defaultDatatypes();
46
47 virtual QStringList reservedKeywords() const;
48
49 private:
50 void writeIncludes(UMLClassifier *c, QTextStream &cpp);
51 void writeClassDecl(UMLClassifier *c, QTextStream &cpp);
52 void writeConstructorDecls(QTextStream &h);
53 void writeConstructorMethods(UMLClassifier * c, QTextStream &cpp);
54
55 // /**
56 // * Write all field declarations, for both attributes and associations for the
57 // * given permitted scope.
58 // */
59 // void writeFieldDecl(UMLClassifier *c, Uml::Visibility::Enum permitScope, QTextStream &stream);
60
61 // /**
62 // * Write all method declarations, for attributes and associations
63 // * for the given permitted scope.
64 // */
65 // void writeAccessorMethodDecl(UMLClassifier *c, Uml::Visibility::Enum permitScope, QTextStream &stream);
66
67 void writeOperations(UMLClassifier *c, bool isHeaderMethod, Uml::Visibility::Enum permitScope, QTextStream &cpp);
68 void writeOperations(UMLClassifier *c, UMLOperationList &oplist, bool isHeaderMethod, QTextStream &cpp);
69
70 // /**
71 // * Write all attributes for a given class.
72 // * @param c the class for which we are generating code
73 // * @param j the stream associated with the output file
74 // */
75 // void writeAttributes(UMLClassifier *c, QTextStream &j);
76
77 void writeAttributeDecls(UMLClassifier *c, Uml::Visibility::Enum visibility, bool writeStatic, QTextStream &stream);
78
79 void writeHeaderFieldDecl(UMLClassifier *c, Uml::Visibility::Enum permitVisibility, QTextStream &stream);
80
81 void writeHeaderAttributeAccessorMethods(UMLClassifier *c, Uml::Visibility::Enum visibility, bool writeStatic, QTextStream &stream);
82
83 void writeHeaderAttributeAccessorMethodDecls(UMLClassifier *c, Uml::Visibility::Enum permitVisibility, QTextStream &stream);
84 void writeHeaderAccessorMethodDecl(UMLClassifier *c, Uml::Visibility::Enum permitScope, QTextStream &stream);
85
86 void writeAssociationDecls(UMLAssociationList associations, Uml::Visibility::Enum permit, Uml::ID::Type id, QTextStream &stream);
87
88 void writeAssociationRoleDecl(QString fieldClassName, QString roleName, QString multi,
89 QString doc, QTextStream &stream);
90
91 void writeAttributeMethods(UMLAttributeList attribs, Uml::Visibility::Enum visib, bool isHeaderMethod,
92 bool isStatic,
93 bool writeMethodBody, QTextStream &stream);
94
95 void writeAssociationMethods(UMLAssociationList associations, Uml::Visibility::Enum permitVisib,
96 bool isHeaderMethod,
97 bool writeMethodBody, bool writePointerVar, Uml::ID::Type id, QTextStream &stream);
98
99 void writeAssociationRoleMethod(const QString &fieldClassName, bool isHeaderMethod, bool writeMethodBody,
100 const QString &roleName, const QString &multi,
101 const QString &description, Uml::Changeability::Enum change,
102 QTextStream &stream);
103
104 void writeSingleAttributeAccessorMethods(
105 const QString &fieldClassName, const QString &Name,
106 const QString &fieldName, const QString &description,
107 Uml::Changeability::Enum change,
108 bool isHeaderMethod,
109 bool isStatic, bool writeMethodBody, QTextStream &cpp);
110
111 void writeVectorAttributeAccessorMethods(
112 const QString &fieldClassName, const QString &fieldVarName,
113 const QString &fieldName, const QString &description,
114 Uml::Changeability::Enum change,
115 bool isHeaderMethod,
116 bool writeMethodBody,
117 QTextStream &stream);
118
119 void writeComment(const QString &text, const QString &indent, QTextStream &cpp);
120 void writeDocumentation(QString header, QString body, QString end, QTextStream &cpp);
121
122 void writeHeaderFile(UMLClassifier *c, QFile &file);
123 void writeSourceFile(UMLClassifier *c, QFile &file);
124
125 void printTextAsSeparateLinesWithIndent (const QString &text, const QString &indent,
126 QTextStream &stream);
127
128 void printAssociationIncludeDecl(UMLAssociationList list, Uml::ID::Type this_id, QTextStream &stream);
129
130 void writeInitAttributeMethod(UMLClassifier * c, QTextStream &stream);
131 void writeInitAttributeDecl(UMLClassifier * c, QTextStream &stream);
132 void writeDataTypes(UMLClassifier *c, Uml::Visibility::Enum permitScope, QTextStream &stream);
133
134 QString umlObjectName(UMLObject *obj);
135
136 QString fixTypeName(const QString &string);
137 QString fixInitialStringDeclValue(const QString &value, const QString &type);
138
139 QString getAttributeVariableName(UMLAttribute *at);
140 QString getAttributeMethodBaseName(const QString &fieldName);
141
142 void writeBlankLine(QTextStream &stream);
143
144 CPPCodeGenerationPolicy *policyExt();
145
146 QString VECTOR_METHOD_APPEND;
147 QString VECTOR_METHOD_REMOVE;
148 QString VECTOR_METHOD_INIT;
149 QString OBJECT_METHOD_INIT;
150
154 bool INLINE_ASSOCIATION_METHODS;
155
156 QStringList ObjectFieldVariables;
157 QStringList VectorFieldVariables;
158 bool m_stringIncludeRequired;
159 };
160
161
162 #endif // CPPWRITER_H
CPPCodeGenerationPolicy
Definition: cppcodegenerationpolicy.h:23
CppWriter
Definition: cppwriter.h:35
CppWriter::VECTOR_METHOD_APPEND
QString VECTOR_METHOD_APPEND
Definition: cppwriter.h:146
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:778
CppWriter::CppWriter
CppWriter()
Definition: cppwriter.cpp:44
CppWriter::writeHeaderAccessorMethodDecl
void writeHeaderAccessorMethodDecl(UMLClassifier *c, Uml::Visibility::Enum permitScope, QTextStream &stream)
Definition: cppwriter.cpp:180
CppWriter::writeConstructorMethods
void writeConstructorMethods(UMLClassifier *c, QTextStream &cpp)
Definition: cppwriter.cpp:1113
CppWriter::getAttributeVariableName
QString getAttributeVariableName(UMLAttribute *at)
Definition: cppwriter.cpp:1404
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:855
CppWriter::writeBlankLine
void writeBlankLine(QTextStream &stream)
Definition: cppwriter.cpp:1380
CppWriter::writeHeaderFieldDecl
void writeHeaderFieldDecl(UMLClassifier *c, Uml::Visibility::Enum permitVisibility, QTextStream &stream)
Definition: cppwriter.cpp:203
CppWriter::defaultDatatypes
QStringList defaultDatatypes()
Definition: cppwriter.cpp:1428
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:937
CppWriter::writeDocumentation
void writeDocumentation(QString header, QString body, QString end, QTextStream &cpp)
Definition: cppwriter.cpp:659
CppWriter::writeAttributeDecls
void writeAttributeDecls(UMLClassifier *c, Uml::Visibility::Enum visibility, bool writeStatic, QTextStream &stream)
Definition: cppwriter.cpp:524
CppWriter::ObjectFieldVariables
QStringList ObjectFieldVariables
Definition: cppwriter.h:156
CppWriter::fixTypeName
QString fixTypeName(const QString &string)
Definition: cppwriter.cpp:1168
CppWriter::printTextAsSeparateLinesWithIndent
void printTextAsSeparateLinesWithIndent(const QString &text, const QString &indent, QTextStream &stream)
Definition: cppwriter.cpp:1389
CppWriter::getAttributeMethodBaseName
QString getAttributeMethodBaseName(const QString &fieldName)
Definition: cppwriter.cpp:1416
CppWriter::fixInitialStringDeclValue
QString fixInitialStringDeclValue(const QString &value, const QString &type)
Definition: cppwriter.cpp:1354
CppWriter::writeAssociationDecls
void writeAssociationDecls(UMLAssociationList associations, Uml::Visibility::Enum permit, Uml::ID::Type id, QTextStream &stream)
Definition: cppwriter.cpp:681
CppWriter::~CppWriter
virtual ~CppWriter()
Definition: cppwriter.cpp:71
CppWriter::writeOperations
void writeOperations(UMLClassifier *c, bool isHeaderMethod, Uml::Visibility::Enum permitScope, QTextStream &cpp)
Definition: cppwriter.cpp:1186
CppWriter::writeHeaderAttributeAccessorMethodDecls
void writeHeaderAttributeAccessorMethodDecls(UMLClassifier *c, Uml::Visibility::Enum permitVisibility, QTextStream &stream)
CppWriter::VECTOR_METHOD_INIT
QString VECTOR_METHOD_INIT
Definition: cppwriter.h:148
CppWriter::language
virtual Uml::ProgrammingLanguage::Enum language() const
Definition: cppwriter.cpp:79
CppWriter::umlObjectName
QString umlObjectName(UMLObject *obj)
Definition: cppwriter.cpp:1372
CppWriter::policyExt
CPPCodeGenerationPolicy * policyExt()
Definition: cppwriter.cpp:87
CppWriter::writeInitAttributeMethod
void writeInitAttributeMethod(UMLClassifier *c, QTextStream &stream)
Definition: cppwriter.cpp:1057
CppWriter::VectorFieldVariables
QStringList VectorFieldVariables
Definition: cppwriter.h:157
CppWriter::writeAttributeMethods
void writeAttributeMethods(UMLAttributeList attribs, Uml::Visibility::Enum visib, bool isHeaderMethod, bool isStatic, bool writeMethodBody, QTextStream &stream)
Definition: cppwriter.cpp:601
CppWriter::writeHeaderAttributeAccessorMethods
void writeHeaderAttributeAccessorMethods(UMLClassifier *c, Uml::Visibility::Enum visibility, bool writeStatic, QTextStream &stream)
Definition: cppwriter.cpp:584
CppWriter::writeDataTypes
void writeDataTypes(UMLClassifier *c, Uml::Visibility::Enum permitScope, QTextStream &stream)
Definition: cppwriter.cpp:1150
CppWriter::INLINE_ASSOCIATION_METHODS
bool INLINE_ASSOCIATION_METHODS
Definition: cppwriter.h:154
CppWriter::writeInitAttributeDecl
void writeInitAttributeDecl(UMLClassifier *c, QTextStream &stream)
Definition: cppwriter.cpp:1047
CppWriter::writeIncludes
void writeIncludes(UMLClassifier *c, QTextStream &cpp)
Definition: cppwriter.cpp:345
CppWriter::writeSourceFile
void writeSourceFile(UMLClassifier *c, QFile &file)
Definition: cppwriter.cpp:219
CppWriter::printAssociationIncludeDecl
void printAssociationIncludeDecl(UMLAssociationList list, Uml::ID::Type this_id, QTextStream &stream)
Definition: cppwriter.cpp:1325
CppWriter::writeHeaderFile
void writeHeaderFile(UMLClassifier *c, QFile &file)
Definition: cppwriter.cpp:147
CppWriter::OBJECT_METHOD_INIT
QString OBJECT_METHOD_INIT
Definition: cppwriter.h:149
CppWriter::writeComment
void writeComment(const QString &text, const QString &indent, QTextStream &cpp)
Definition: cppwriter.cpp:637
CppWriter::writeConstructorDecls
void writeConstructorDecls(QTextStream &h)
Definition: cppwriter.cpp:1023
CppWriter::writeAssociationRoleDecl
void writeAssociationRoleDecl(QString fieldClassName, QString roleName, QString multi, QString doc, QTextStream &stream)
Definition: cppwriter.cpp:725
CppWriter::m_stringIncludeRequired
bool m_stringIncludeRequired
Definition: cppwriter.h:158
CppWriter::writeClass
virtual void writeClass(UMLClassifier *c)
Definition: cppwriter.cpp:96
CppWriter::VECTOR_METHOD_REMOVE
QString VECTOR_METHOD_REMOVE
Definition: cppwriter.h:147
CppWriter::reservedKeywords
virtual QStringList reservedKeywords() const
Definition: cppwriter.cpp:1437
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:831
CppWriter::writeClassDecl
void writeClassDecl(UMLClassifier *c, QTextStream &cpp)
Definition: cppwriter.cpp:371
SimpleCodeGenerator
Definition: simplecodegenerator.h:34
SimpleCodeGenerator::indent
QString indent()
Definition: simplecodegenerator.cpp:76
UMLAttributeList
Definition: umlattributelist.h:27
UMLAttribute
Sets up attribute information.
Definition: attribute.h:28
UMLClassifier
Information for a non-graphical Concept/Class.
Definition: classifier.h:40
UMLObject
The base class for UML objects.
Definition: umlobject.h:74
cppcodegenerationpolicy.h
description
static const char description[]
Definition: main.cpp:37
Uml::Changeability::Enum
Enum
Definition: basictypes.h:204
Uml::ID::Type
std::string Type
Definition: basictypes.h:351
Uml::ProgrammingLanguage::Enum
Enum
Definition: basictypes.h:271
Uml::TextRole::Name
@ Name
Definition: basictypes.h:182
Uml::Visibility::Enum
Enum
Definition: basictypes.h:59
visibility
Definition: visibility.py:1
simplecodegenerator.h
umlassociationlist.h
UMLAssociationList
QList< UMLAssociation * > UMLAssociationList
Definition: umlassociationlist.h:18
umlattributelist.h
umloperationlist.h
UMLOperationList
QList< UMLOperation * > UMLOperationList
Definition: umloperationlist.h:18