Search code examples
c++parsingnumbersparam

C++ file parse number of arguments


I got a pack of c++ files with static source code (already developped, not needed to do anything to them).

There is an program/lib/way to get a list of the number of params each function withing one of those files?

I mean, getting a result like:

#File a.cpp
##a() -> 3 paramss
##foo() -> 0 params (void)

#File b.cpp
##test() -> 1 param

....

And a better question.

There is any way to also process the number of returns it has?

#File a.cpp
##a() -> 3 params, 1 return
##foo() -> 0 params (void), 2 returns

For example if "foo" has a return if condition is true and another if false

Thanks in advance.


Solution

  • You could try running Doxygen over the source files.

    Since the content is (presumably) undocumented, you need to configure doxygen to extract content from undocumented files.

    If you just want to browse a list of the available functions, you could use the HTML output.

    You could also configure Doxygen output to be XML, and then write a parser to pull statistics that you are looking for on each function.