droogstore
droogstore

Reputation: 13

extract list of functions in header file

I am looking for a way to extract all functions found in a C++ header file including comments for that respective function which sit on top of the function definition.

The idea is to produce a list of all functions in the file in order to get it into a CSV or Excel file. I would like to have on each line:

Header file name;Function name only;Complete function signature;Comments in code for that function

Example (from file someHeader.h):

// This is the multi-line
// comment for the DoSomething function.
void            DoSomething (int CleverParameter);

turned into

someHeader.h;DoSomething;void DoSomething (int CleverParameter);This is the multi-line comment for the DoSomething function.

I don't need clever parsing and type/dependency resolution or such things. I have VisualStudio 2010 and 2012 at my hands. Also not afraid of Linux or Windows command-line tools. If whitespace gets cleaned up in the process, that would be great.

Upvotes: 1

Views: 4305

Answers (1)

zakinster
zakinster

Reputation: 10698

Writing a decent C++ parser won't be an easy task.

A possible solution would be to use a documentation generator such as doxygen's, it doesn't include a complete C++ parser but it should be sufficient for your purpose:

  • Use doxygen to generates an XML output containing all function definitions and comments
  • Use an XSLT stylesheet or an XML parser to generates your CSV file

It's not the perfect solution, but it would definitely be more robust than a regex approach and won't require a lot of code to get it working.

Upvotes: 3

Related Questions