• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

umbrello/umbrello

  • sources
  • kde-4.12
  • kdesdk
  • umbrello
  • umbrello
  • codegenerators
  • cpp
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-2013 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 
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 
133  QString umlObjectName(UMLObject *obj);
134 
135  QString fixTypeName(const QString &string);
136  QString fixInitialStringDeclValue(const QString &value, const QString &type);
137 
138  QString getAttributeVariableName(UMLAttribute *at);
139 
140  void writeBlankLine(QTextStream &stream);
141 
142  CPPCodeGenerationPolicy *policyExt();
143 
144  QString VECTOR_METHOD_APPEND;
145  QString VECTOR_METHOD_REMOVE;
146  QString VECTOR_METHOD_INIT;
147  QString OBJECT_METHOD_INIT;
148 
152  bool INLINE_ASSOCIATION_METHODS;
153 
154  QStringList ObjectFieldVariables;
155  QStringList VectorFieldVariables;
156 
157 };
158 
159 
160 #endif // CPPWRITER_H
CppWriter::defaultDatatypes
QStringList defaultDatatypes()
Add C++ primitives as datatypes.
Definition: cppwriter.cpp:1322
UMLClassifier
This class defines the non-graphical information required for a UML Classifier (ie a class or interfa...
Definition: classifier.h:39
Uml::Visibility::Enum
Enum
Definition: basictypes.h:56
CppWriter::~CppWriter
virtual ~CppWriter()
Destructor, empty.
Definition: cppwriter.cpp:68
Uml::ProgrammingLanguage::Enum
Enum
Definition: basictypes.h:241
SimpleCodeGenerator
A simple code generator interface designed to work with the existing codewriters. ...
Definition: simplecodegenerator.h:28
UMLAttribute
This class is used to set up information for an attribute.
Definition: attribute.h:27
UMLAttributeList
This sub-class adds copyInto and clone to the QPtrList base class.
Definition: umlattributelist.h:26
CppWriter
Class CppWriter is a code generator for UMLClassifier objects.
Definition: cppwriter.h:34
description
static const char description[]
Definition: docgenerators/main.cpp:37
UMLObject
This class is the non-graphical version of UMLWidget.
Definition: umlobject.h:41
simplecodegenerator.h
umlattributelist.h
Uml::TextRole::Name
Definition: basictypes.h:154
cppcodegenerationpolicy.h
umloperationlist.h
CppWriter::writeClass
virtual void writeClass(UMLClassifier *c)
Call this method to generate cpp code for a UMLClassifier.
Definition: cppwriter.cpp:93
Uml::ID::Type
std::string Type
Definition: basictypes.h:317
umlassociationlist.h
Uml::Changeability::Enum
Enum
Definition: basictypes.h:175
CPPCodeGenerationPolicy
Definition: cppcodegenerationpolicy.h:23
CppWriter::reservedKeywords
virtual QStringList reservedKeywords() const
Get list of reserved keywords.
Definition: cppwriter.cpp:1331
CppWriter::CppWriter
CppWriter()
Constructor, initialises a couple of variables.
Definition: cppwriter.cpp:42
CppWriter::language
virtual Uml::ProgrammingLanguage::Enum language() const
Returns "C++".
Definition: cppwriter.cpp:76
SimpleCodeGenerator::indent
QString indent()
Returns the current indent string based on m_indentLevel and m_indentation.
Definition: simplecodegenerator.cpp:74
QList
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:05:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

umbrello/umbrello

Skip menu "umbrello/umbrello"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal