LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parsing a C++ File

Folks:

I am trying to parse a file for function names in the "public:" section of a
C++ header file. I want to pull specific information from the functions:

i.e. here is a function ...

USHORT GetDiagFcallResp(const int i) {
if ((i>=0) && (i else {return TDU_FCALL_RESPONSE_ERROR;}
}

I want to get the return type (USHORT), the function name
(GetDiagFcallResp), the parameter(s) (const int i).

that's it and there are many of these similiar functions; any suggestions on
how to proceed?

--
Best Regards,

Kevin
0 Kudos
Message 1 of 2
(2,828 Views)
Using Scan From String.vi you should be able to separate the desired components of your initial string.

I add a simple vi that parses your example header into three fields: return value, function name and parameters. Be careful: in the last item of the format string, a space is added in order to extract all the parameteres string, otherwise only the first 'const' will be extracted.

This last item must be modified in case of a function with more than one parameter: add a comma in the format string of Scan From String.vi in order to extract all parameters in a single output string, and scan from this one extracting characters in set [ A-Za-z], so dividing tokens when a comma is encountered.

Hope this helps
Roberto


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 2
(2,828 Views)