That is what I did earlier today:
- Extract the comment out of the C++ files
- Use regex to extract the namespace definition
- Use a simple string search to get the open & close braces positions
The various sanity check added show that I am successfully processing 99.925% of my files (5 failures ouf of 6678 files). The issues are due to mismatches in numbers of { and } cause by few '{' or '}' in strings, and unclean usage of the preprocessor instruction.
However, I am only dealing with header files, and I own the code. That limits the number of scenari that could cause some issues and I can manually modify the ones I don't cover.
Of course I know there are plenty of cases where it would fail but it is probably enough for what I want to achieve.
Thanks for your answers.