How can I generate UML class diagrams from C++ source files? [closed]
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this questionWith doxygen I can generate nice diagrams but doxygen lacks a deeper analysis of the relationships between classes. It recognizes derivation but other relations are not understood by the tool. Which better utilities are there (commercial or not) that generate more complete UML class diagrams out of C++ source files?
The tools available for C#/Java are a bit better but do not interest me right now.
For parsing C++ code, the best tool I have used is BoUML. It is not perfect, and it won't generate the diagrams for you, but it does understand the relationships. If you pull two classes into a class diagram, it will automatically draw the relationships, and it allows you to grow the diagram by selecting a particular class and having the tool bring up related classes (both classes that depend on the selected one and classes that the selected one depends on).
It recognizes derivation but other relations are not understood by the tool.
Doxygen also supports generating collaboration diagrams which does provide an image for non-inheritance relations.
From the Doxygen manual:
COLLABORATION_GRAPH
If the COLLABORATION_GRAPH
andHAVE_DOT
tags are set toYES
then doxygen will generate a graph for each documented class showing the direct and indirect implementation dependencies (inheritance, containment, and class references variables) of the class with other documented classes.
I myself don't do anything fancy with UML, but these diagrams are good enough for my purposes (graphing inheritance and composition).
@jdehaan looks like lot of us are sailing in the same boat today ;)
codedrawer for C++(http://www.codedrawer.com/) is one such tool.
I will link to some started today that might interest you.
Qt Dependency Visualizer
Code refactoring
Enterprise Architect. Deeply analyzes the code, can generate diagrams from code, code from diagram, and support round-trip code generation which means modifying the generated diagram and saving the changes into source code. And it knows C, C++, C#, Java, Python, VB.NET & VB, PHP, Java, Delphi. Also, it support a whole bunch of diagram types including complete UML2.0 of course. (I don't know what it does in C :P)
Besides doing these stuff right, it does LOTS of other things, and I think it's really worth its price, which is 135-239 USD depending on the edition.
精彩评论