cpptree2uml.h 4.04 KB
Newer Older
1
2
3
4
5
6
/***************************************************************************
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
Oliver Kellogg's avatar
Oliver Kellogg committed
7
 *   copyright (C) 2005-2014                                               *
Ralf Habacker's avatar
Ralf Habacker committed
8
 *   Umbrello UML Modeller Authors <umbrello-devel@kde.org>                *
9
10
11
12
13
14
 ***************************************************************************/

#ifndef CPPTREE2UML_H
#define CPPTREE2UML_H

#include "tree_parser.h"
15
#include "model_utils.h"
16

17
#include <QStringList>
Andi Fischer's avatar
Andi Fischer committed
18

19
// fwd decls
20
class CodeImpThread;
21
class UMLClassifier;
22
class UMLFolder;
23
24
class UMLOperation;
class UMLPackage;
25
26
27
28

class CppTree2Uml: public TreeParser
{
public:
29
    explicit CppTree2Uml(const QString& fileName, CodeImpThread* thread = 0);
30
31
    virtual ~CppTree2Uml();

32
    void clear();
33
    void setRootPath(const QString &rootPath);
34
35
36
    //FileDom file() { return m_file; }

    // translation-unit
37
    virtual void parseTranslationUnit(const ParsedFile &file);
38
39

    // declarations
40
41
42
43
44
45
46
47
48
49
50
51
    //virtual void parseDeclaration(DeclarationAST*);  // use parent method
    //virtual void parseLinkageSpecification(LinkageSpecificationAST*);  // use parent method
    virtual void parseNamespace(NamespaceAST*);
    //virtual void parseNamespaceAlias(NamespaceAliasAST*);  // use parent method
    //virtual void parseUsing(UsingAST*);  // use parent method
    //virtual void parseUsingDirective(UsingDirectiveAST*);  // use parent method
    virtual void parseTypedef(TypedefAST*);
    virtual void parseTemplateDeclaration(TemplateDeclarationAST*);
    virtual void parseSimpleDeclaration(SimpleDeclarationAST*);
    virtual void parseFunctionDefinition(FunctionDefinitionAST*);
    //virtual void parseLinkageBody(LinkageBodyAST*);  // use parent method
    virtual void parseAccessDeclaration(AccessDeclarationAST*);
52
53

    // type-specifier
54
55
56
57
    //virtual void parseTypeSpecifier(TypeSpecifierAST*);  // use parent method
    virtual void parseClassSpecifier(ClassSpecifierAST*);
    virtual void parseEnumSpecifier(EnumSpecifierAST*);
    virtual void parseElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST*);
58
59
60

    // non-overriding (locally added) methods

61
62
63
64
    virtual void parseDeclaration2(GroupAST* funSpec, GroupAST* storageSpec, TypeSpecifierAST* typeSpec, InitDeclaratorAST* decl);
    virtual void parseFunctionDeclaration(GroupAST* funSpec, GroupAST* storageSpec, TypeSpecifierAST* typeSpec, InitDeclaratorAST* decl);
    void parseFunctionArguments(DeclaratorAST* declarator, UMLOperation* method);
    virtual void parseBaseClause(BaseClauseAST* baseClause, UMLClassifier* klass);
65
66

private:
67
    //NamespaceDom findOrInsertNamespace(NamespaceAST* ast, const QString& name);
68

69
70
71
    QString typeOfDeclaration(TypeSpecifierAST* typeSpec, DeclaratorAST* declarator);
    QStringList scopeOfName(NameAST* id, const QStringList& scope);
    QStringList scopeOfDeclarator(DeclaratorAST* d, const QStringList& scope);
72
    void flushTemplateParams(UMLClassifier *klass);
73
74
75
76
77

private:
    //FileDom m_file;
    QString m_fileName;
    QStringList m_currentScope;
Andi Fischer's avatar
Andi Fischer committed
78
    Uml::Visibility::Enum m_currentAccess;
79
80
81
82
83
    bool m_inSlots;
    bool m_inSignals;
    int m_anon;
    bool m_inStorageSpec;
    bool m_inTypedef;
84
    QString m_comment;
85
    Model_Utils::NameAndType_List m_templateParams;
86
87

    DeclaratorAST* m_currentDeclarator;
88
89
#   define STACKSIZE 30
    UMLPackage* m_currentNamespace[STACKSIZE+1];  ///< stack
90
    UMLClassifier* m_currentClass[STACKSIZE+1];  ///< stack
91
    int m_nsCnt;  ///< stack top for m_currentNamespace
Oliver Kellogg's avatar
Oliver Kellogg committed
92
    int m_clsCnt;  ///< stack top for m_currentClass
93
    CodeImpThread* m_thread;
94
95
    QString m_rootPath; ///< root path of project
    UMLFolder *m_rootFolder;
96
    UMLDoc *m_doc;
97

98
private:
99
100
    CppTree2Uml(const CppTree2Uml& source);
    void operator = (const CppTree2Uml& source);
101
102
103
};

#endif // CPPTREE2UML