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

cpptree2uml.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) 2005-2014 *
8 * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
9 ***************************************************************************/
10
11 #ifndef CPPTREE2UML_H
12 #define CPPTREE2UML_H
13
14 #include "tree_parser.h"
15 #include "model_utils.h"
16
17 #include <QStringList>
18
19 // fwd decls
20 class CodeImpThread;
21 class UMLClassifier;
22 class UMLFolder;
23 class UMLOperation;
24 class UMLPackage;
25
26 class CppTree2Uml: public TreeParser
27 {
28 public:
29 explicit CppTree2Uml(const QString& fileName, CodeImpThread* thread = 0);
30 virtual ~CppTree2Uml();
31
32 void clear();
33 void setRootPath(const QString &rootPath);
34 //FileDom file() { return m_file; }
35
36 // translation-unit
37 virtual void parseTranslationUnit(const ParsedFile &file);
38
39 // declarations
40 //virtual void parseDeclaration(DeclarationAST*); // use parent method
41 //virtual void parseLinkageSpecification(LinkageSpecificationAST*); // use parent method
42 virtual void parseNamespace(NamespaceAST*);
43 //virtual void parseNamespaceAlias(NamespaceAliasAST*); // use parent method
44 //virtual void parseUsing(UsingAST*); // use parent method
45 //virtual void parseUsingDirective(UsingDirectiveAST*); // use parent method
46 virtual void parseTypedef(TypedefAST*);
47 virtual void parseTemplateDeclaration(TemplateDeclarationAST*);
48 virtual void parseSimpleDeclaration(SimpleDeclarationAST*);
49 virtual void parseFunctionDefinition(FunctionDefinitionAST*);
50 //virtual void parseLinkageBody(LinkageBodyAST*); // use parent method
51 virtual void parseAccessDeclaration(AccessDeclarationAST*);
52
53 // type-specifier
54 //virtual void parseTypeSpecifier(TypeSpecifierAST*); // use parent method
55 virtual void parseClassSpecifier(ClassSpecifierAST*);
56 virtual void parseEnumSpecifier(EnumSpecifierAST*);
57 virtual void parseElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST*);
58
59 // non-overriding (locally added) methods
60
61 virtual void parseDeclaration2(GroupAST* funSpec, GroupAST* storageSpec, TypeSpecifierAST* typeSpec, InitDeclaratorAST* decl);
62 virtual void parseFunctionDeclaration(GroupAST* funSpec, GroupAST* storageSpec, TypeSpecifierAST* typeSpec, InitDeclaratorAST* decl);
63 void parseFunctionArguments(DeclaratorAST* declarator, UMLOperation* method);
64 virtual void parseBaseClause(BaseClauseAST* baseClause, UMLClassifier* klass);
65
66 private:
67 //NamespaceDom findOrInsertNamespace(NamespaceAST* ast, const QString& name);
68
69 QString typeOfDeclaration(TypeSpecifierAST* typeSpec, DeclaratorAST* declarator);
70 QStringList scopeOfName(NameAST* id, const QStringList& scope);
71 QStringList scopeOfDeclarator(DeclaratorAST* d, const QStringList& scope);
72 void flushTemplateParams(UMLClassifier *klass);
73
74 private:
75 //FileDom m_file;
76 QString m_fileName;
77 QStringList m_currentScope;
78 Uml::Visibility::Enum m_currentAccess;
79 bool m_inSlots;
80 bool m_inSignals;
81 int m_anon;
82 bool m_inStorageSpec;
83 bool m_inTypedef;
84 QString m_comment;
85 Model_Utils::NameAndType_List m_templateParams;
86
87 DeclaratorAST* m_currentDeclarator;
88 # define STACKSIZE 30
89 UMLPackage* m_currentNamespace[STACKSIZE+1];
90 UMLClassifier* m_currentClass[STACKSIZE+1];
91 int m_nsCnt;
92 int m_clsCnt;
93 CodeImpThread* m_thread;
94 QString m_rootPath;
95 UMLFolder *m_rootFolder;
96 UMLDoc *m_doc;
97
98 private:
99 CppTree2Uml(const CppTree2Uml& source);
100 void operator = (const CppTree2Uml& source);
101 };
102
103 #endif // CPPTREE2UML
datatype.h
UMLObject::asUMLClassifier
UMLClassifier * asUMLClassifier()
Definition: umlobject.cpp:1309
template.h
Import_Utils::insertAttribute
UMLAttribute * insertAttribute(UMLClassifier *owner, Uml::Visibility::Enum scope, const QString &name, UMLClassifier *attrType, const QString &comment, bool isStatic)
Definition: import_utils.cpp:426
UMLClassifier::getOpList
UMLOperationList getOpList(bool includeInherited=false, UMLClassifierSet *alreadyTraversed=0)
Definition: classifier.cpp:939
CppTree2Uml
Definition: cpptree2uml.h:27
CppTree2Uml::m_inSignals
bool m_inSignals
Definition: cpptree2uml.h:80
CppTree2Uml::m_currentDeclarator
DeclaratorAST * m_currentDeclarator
Definition: cpptree2uml.h:87
CppTree2Uml::setRootPath
void setRootPath(const QString &rootPath)
Definition: cpptree2uml.cpp:71
UMLOperation::setInline
void setInline(bool b)
Definition: operation.cpp:470
CppTree2Uml::typeOfDeclaration
QString typeOfDeclaration(TypeSpecifierAST *typeSpec, DeclaratorAST *declarator)
Definition: cpptree2uml.cpp:736
Import_Utils::createArtifact
UMLObject * createArtifact(const QString &name, UMLFolder *parentPkg, const QString &comment)
Definition: import_utils.cpp:671
CppTree2Uml::scopeOfName
QStringList scopeOfName(NameAST *id, const QStringList &scope)
Definition: cpptree2uml.cpp:784
CppTree2Uml::CppTree2Uml
CppTree2Uml(const CppTree2Uml &source)
UMLDatatype
Non-graphical information for a Datatype.
Definition: datatype.h:26
UMLObject::ot_Class
@ ot_Class
Definition: umlobject.h:89
operation.h
UMLClassifierListItem::getTypeName
virtual QString getTypeName() const
Definition: classifierlistitem.cpp:112
CppTree2Uml::parseSimpleDeclaration
virtual void parseSimpleDeclaration(SimpleDeclarationAST *)
Definition: cpptree2uml.cpp:270
UMLOperation::isDestructorOperation
bool isDestructorOperation()
Definition: operation.cpp:391
Import_Utils::createGeneralization
UMLAssociation * createGeneralization(UMLClassifier *child, UMLClassifier *parent)
Definition: import_utils.cpp:603
UMLDoc::rootFolder
UMLFolder * rootFolder(Uml::ModelType::Enum mt)
Definition: umldoc.cpp:3205
UMLObject::ot_Interface
@ ot_Interface
Definition: umlobject.h:86
CppTree2Uml::m_thread
CodeImpThread * m_thread
Definition: cpptree2uml.h:93
Model_Utils::NameAndType::m_type
UMLObject * m_type
Definition: model_utils.h:115
CppTree2Uml::parseElaboratedTypeSpecifier
virtual void parseElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST *)
Definition: cpptree2uml.cpp:525
Import_Utils::createUMLObject
UMLObject * createUMLObject(UMLObject::ObjectType type, const QString &inName, UMLPackage *parentPkg, const QString &comment, const QString &stereotype, bool searchInParentPackageOnly, bool remapParent)
Definition: import_utils.cpp:178
UMLObject::isStatic
bool isStatic() const
Definition: umlobject.cpp:366
CppTree2Uml::CppTree2Uml
CppTree2Uml(const QString &fileName, CodeImpThread *thread=0)
Definition: cpptree2uml.cpp:40
UMLObject::ot_Package
@ ot_Package
Definition: umlobject.h:85
CppTree2Uml::m_nsCnt
int m_nsCnt
stack top for m_currentNamespace
Definition: cpptree2uml.h:91
CppTree2Uml::parseNamespace
virtual void parseNamespace(NamespaceAST *)
Definition: cpptree2uml.cpp:108
Import_Utils::insertMethod
void insertMethod(UMLClassifier *klass, UMLOperation *&op, Uml::Visibility::Enum scope, const QString &type, bool isStatic, bool isAbstract, bool isFriend, bool isConstructor, bool isDestructor, const QString &comment)
Definition: import_utils.cpp:498
CppTree2Uml::flushTemplateParams
void flushTemplateParams(UMLClassifier *klass)
Definition: cpptree2uml.cpp:809
UMLObject::ot_UMLObject
@ ot_UMLObject
Definition: umlobject.h:82
model_utils.h
UMLObject
The base class for UML objects.
Definition: umlobject.h:74
UMLObject::isAbstract
bool isAbstract() const
Definition: umlobject.cpp:348
Model_Utils::NameAndType_List
QLinkedList< NameAndType > NameAndType_List
Auxiliary type for OpDescriptor.
Definition: model_utils.h:126
import_utils.h
CppTree2Uml::m_rootPath
QString m_rootPath
root path of project
Definition: cpptree2uml.h:94
Import_Utils::putAtGlobalScope
void putAtGlobalScope(bool yesno)
Definition: import_utils.cpp:83
CppTree2Uml::m_templateParams
Model_Utils::NameAndType_List m_templateParams
Definition: cpptree2uml.h:85
UMLObject::asUMLDatatype
UMLDatatype * asUMLDatatype()
Definition: umlobject.cpp:1312
CodeImpThread::emitAskQuestion
int emitAskQuestion(const QString &question)
Definition: codeimpthread.cpp:88
Settings::optionState
OptionState & optionState()
Definition: optionstate.cpp:362
CppTree2Uml::m_currentAccess
Uml::Visibility::Enum m_currentAccess
Definition: cpptree2uml.h:78
Uml::Visibility::Public
@ Public
Definition: basictypes.h:60
CppTree2Uml::operator=
void operator=(const CppTree2Uml &source)
UMLOperation::setConst
void setConst(bool b)
Definition: operation.cpp:422
cpptree2uml.h
CppTree2Uml::m_doc
UMLDoc * m_doc
Definition: cpptree2uml.h:96
UMLApp
Definition: uml.h:100
CppTree2Uml::m_currentScope
QStringList m_currentScope
Definition: cpptree2uml.h:77
CppTree2Uml::m_anon
int m_anon
Definition: cpptree2uml.h:81
CppTree2Uml::parseClassSpecifier
virtual void parseClassSpecifier(ClassSpecifierAST *)
Definition: cpptree2uml.cpp:397
Uml::ModelType::Component
@ Component
Definition: basictypes.h:44
UMLClassifier::setBaseType
void setBaseType(UMLObject::ObjectType ot)
Definition: classifier.cpp:83
Import_Utils::createSubDir
UMLFolder * createSubDir(const QString &name, UMLFolder *parentPkg, const QString &comment)
Definition: import_utils.cpp:626
UMLClassifierListItem::setType
virtual void setType(UMLObject *type)
Definition: classifierlistitem.cpp:127
CppTree2Uml::parseFunctionDeclaration
virtual void parseFunctionDeclaration(GroupAST *funSpec, GroupAST *storageSpec, TypeSpecifierAST *typeSpec, InitDeclaratorAST *decl)
Definition: cpptree2uml.cpp:622
CppTree2Uml::parseDeclaration2
virtual void parseDeclaration2(GroupAST *funSpec, GroupAST *storageSpec, TypeSpecifierAST *typeSpec, InitDeclaratorAST *decl)
Definition: cpptree2uml.cpp:553
UMLObject::ot_Datatype
@ ot_Datatype
Definition: umlobject.h:87
CppTree2Uml::parseAccessDeclaration
virtual void parseAccessDeclaration(AccessDeclarationAST *)
Definition: cpptree2uml.cpp:610
Model_Utils::NameAndType_ListIt
QLinkedList< NameAndType >::iterator NameAndType_ListIt
Auxiliary type for OpDescriptor.
Definition: model_utils.h:127
Import_Utils::addMethodParameter
UMLAttribute * addMethodParameter(UMLOperation *method, const QString &type, const QString &name)
Definition: import_utils.cpp:572
uDebug
#define uDebug()
Definition: debug_utils.h:122
CppTree2Uml::m_currentClass
UMLClassifier * m_currentClass[STACKSIZE+1]
stack
Definition: cpptree2uml.h:90
UMLObject::setStereotype
void setStereotype(const QString &_name)
Definition: umlobject.cpp:528
Import_Utils::isDatatype
bool isDatatype(const QString &name, UMLPackage *parentPkg)
Definition: import_utils.cpp:798
CppTree2Uml::m_clsCnt
int m_clsCnt
stack top for m_currentClass
Definition: cpptree2uml.h:92
CodeImpThread
Definition: codeimpthread.h:36
umllistview.h
UMLObject::setAbstract
void setAbstract(bool bAbstract)
Definition: umlobject.cpp:356
Import_Utils::makeOperation
UMLOperation * makeOperation(UMLClassifier *parent, const QString &name)
Definition: import_utils.cpp:416
UMLDoc
Definition: umldoc.h:75
Model_Utils::NameAndType
Definition: model_utils.h:113
UMLAttribute
Sets up attribute information.
Definition: attribute.h:28
UMLClassifier::getAttributeList
UMLAttributeList getAttributeList() const
Definition: classifier.cpp:436
CppTree2Uml::parseEnumSpecifier
virtual void parseEnumSpecifier(EnumSpecifierAST *)
Definition: cpptree2uml.cpp:502
CodeImpThread::emitMessageToLog
void emitMessageToLog(const QString &file, const QString &text)
Definition: codeimpthread.cpp:102
UMLObject::setBaseType
virtual void setBaseType(ObjectType ot)
Definition: umlobject.cpp:415
UMLFolder
Non-graphical management of objects and diagrams of a Folder.
Definition: folder.h:35
STACKSIZE
#define STACKSIZE
Definition: cpptree2uml.h:88
CppTree2Uml::m_comment
QString m_comment
Definition: cpptree2uml.h:84
UMLOperation::setVirtual
void setVirtual(bool b)
Definition: operation.cpp:454
Uml::Visibility::Enum
Enum
Definition: basictypes.h:59
Import_Utils::addEnumLiteral
void addEnumLiteral(UMLEnum *enumType, const QString &literal, const QString &comment, const QString &value)
Definition: import_utils.cpp:593
UMLDoc::findUMLObject
UMLObject * findUMLObject(const QString &name, UMLObject::ObjectType type=UMLObject::ot_UMLObject, UMLObject *currentObj=0)
Definition: umldoc.cpp:1067
classifier.h
UMLDatatype::setIsReference
void setIsReference(bool isRef=true)
Definition: datatype.cpp:55
uError
#define uError()
Definition: debug_utils.h:123
UMLOperation
Definition: operation.h:25
UMLObject::ot_Enum
@ ot_Enum
Definition: umlobject.h:88
uml.h
UMLClassifier
Information for a non-graphical Concept/Class.
Definition: classifier.h:40
CppTree2Uml::m_inSlots
bool m_inSlots
Definition: cpptree2uml.h:79
debug_utils.h
CppTree2Uml::parseBaseClause
virtual void parseBaseClause(BaseClauseAST *baseClause, UMLClassifier *klass)
Definition: cpptree2uml.cpp:758
CppTree2Uml::scopeOfDeclarator
QStringList scopeOfDeclarator(DeclaratorAST *d, const QStringList &scope)
Definition: cpptree2uml.cpp:801
CppTree2Uml::m_rootFolder
UMLFolder * m_rootFolder
Definition: cpptree2uml.h:95
CppTree2Uml::m_fileName
QString m_fileName
Definition: cpptree2uml.h:76
CppTree2Uml::parseFunctionArguments
void parseFunctionArguments(DeclaratorAST *declarator, UMLOperation *method)
Definition: cpptree2uml.cpp:711
CppTree2Uml::parseFunctionDefinition
virtual void parseFunctionDefinition(FunctionDefinitionAST *)
Definition: cpptree2uml.cpp:292
UMLObject::asUMLPackage
UMLPackage * asUMLPackage()
Definition: umlobject.cpp:1325
UMLTemplate
Sets up template information.
Definition: template.h:27
CppTree2Uml::parseTypedef
virtual void parseTypedef(TypedefAST *)
Definition: cpptree2uml.cpp:154
CppTree2Uml::~CppTree2Uml
virtual ~CppTree2Uml()
Definition: cpptree2uml.cpp:50
UMLObject::stereotype
QString stereotype(bool includeAdornments=false) const
Definition: umlobject.cpp:559
UMLOperation::setOverride
void setOverride(bool b)
Definition: operation.cpp:438
codeimpthread.h
UMLEnum
Non-graphical Information for an Enum.
Definition: enum.h:29
CppTree2Uml::m_inTypedef
bool m_inTypedef
Definition: cpptree2uml.h:83
CppTree2Uml::m_currentNamespace
UMLPackage * m_currentNamespace[STACKSIZE+1]
stack
Definition: cpptree2uml.h:89
CppTree2Uml::parseTranslationUnit
virtual void parseTranslationUnit(const ParsedFile &file)
Definition: cpptree2uml.cpp:87
CppTree2Uml::m_inStorageSpec
bool m_inStorageSpec
Definition: cpptree2uml.h:82
Model_Utils::NameAndType::m_name
QString m_name
< Data structure filled by parseAttribute().
Definition: model_utils.h:114
Uml::Visibility::fromString
Enum fromString(const QString &item, bool checkUnkown)
Definition: basictypes.cpp:127
umldoc.h
CppTree2Uml::parseTemplateDeclaration
virtual void parseTemplateDeclaration(TemplateDeclarationAST *)
Definition: cpptree2uml.cpp:222
UMLDatatype::setOriginType
void setOriginType(UMLClassifier *origType)
Definition: datatype.cpp:37
UMLClassifier::addTemplate
UMLTemplate * addTemplate(const QString &name, Uml::ID::Type id=Uml::ID::None)
Definition: classifier.cpp:1024
UMLPackage
Non-graphical information for a Package.
Definition: package.h:33
CppTree2Uml::clear
void clear()
Definition: cpptree2uml.cpp:54