📜 ⬆️ ⬇️

C ++ class hierarchy on the knee

Foreword


How with awk, tiddlywiki and such a mother to understand the structure of classes that you see for the first time, but you need to do something just yesterday.
Attention: the use of this method is very limited, moreover, in normal development environments this technique is not needed. But I had a C ++ project in BCB6, so I had to do it myself.

What we have


A set of classes, about 150 pieces. In the process of developing the system, the names of some of them changed, and the file names remained the same. And immediately find out who someone relative is not possible. There is a Class Explorer - but it is not informative, and most importantly, it is impossible to find out exactly which classes are inherited from this one.

What is required to perform the analysis

(it is assumed that we conduct surveys in Windows)



Unfortunately, the for command in the Windows command interpreter does not work with subdirectories (yes, I know about / R, but for returns an absolute path with backslashes, which you then need to deploy later, but I'm still lazy), so we can process only one directory. But if you have bin-utils and win-bash at hand, then a simple rename of bin / find to bin / gfind will be possible to use the version for bash. For * nix systems, the file with the corresponding name is used.
')

Analysis

the points

  1. Download the archive - in it modified TW, scripts bat, sh, awk
  2. Unpacking
  3. In the src folder we add files for analysis (for the time being I analyze only * .h).
  4. If necessary, download GAWK for Windows
  5. After that, run the necessary script and after its completion open the classes.html browser.


What we get at the output


Tags:



View Records

TFilterStateKeeper
File ./uFilter.h
Parent TStateKeeper


Glossary



TW - TiddlyWiki
BCB - Borland C ++ Builder (the builder of the boring lands, the terrible development environment that still caught the absence of code folding and code refactoring)
AWK / GAWK is an interpreted scripted C-like language for line-by-line parsing and processing of the input stream (for example, a text file) using specified templates. GAWK is the GNU version, with various improvements.

TW modification consists solely in the separation of JavaScript and the actual page with the data - this does not affect the results of the work, but it becomes easier to modify and debug.

Example: classes.html (Remember to allow scripts). In this example, it is clear that the “parser” is not ideal (“that” and “to” classes).
Yes, you can (and should) use doxygen. But there is no search using regular expressions, and you cannot quickly make and save notes. And most importantly - there is no animation in it! :)

Source: https://habr.com/ru/post/44891/


All Articles