2

Is there a script or tool that changes a code's style to google style not completely at least partially (maybe just syntax formatting)? We are reusing some of our C++ legacy code which is not formatted by google style standards and even just formatting it syntactically would take a few hours for a developer.

For now, we wrote some regular expressions that search and replace some basic style

Thanks

Chenna V
  • 10,185
  • 11
  • 77
  • 104
  • 6
    why pick the most infamously bad c++ style guide in existence? you have bad advisers. get copy of andre and herb's c++ style book. – Cheers and hth. - Alf Sep 23 '11 at 14:53
  • also there are lots of c++ prettyfiers, including the one bundled with code::blocks – Cheers and hth. - Alf Sep 23 '11 at 14:55
  • third, regarding the "regex" tag, regex is often a sure way to multiply your problems – Cheers and hth. - Alf Sep 23 '11 at 14:55
  • @Alf: hmmm.. I didn't know that google style had that reputation. I am just following what my team has been doing so I really can't change at this point. btw, are you referring to "Exceptional C++ Style"?? – Chenna V Sep 23 '11 at 14:57
  • 3
    http://www.gotw.ca/publications/c++cs.htm – Cheers and hth. - Alf Sep 23 '11 at 14:59
  • well i strongly disagree with "84. Prefer algorithm calls to handwritten loops. 162 ", and also there is bad advice in there about using static_cast instead of reinterpret_cast. but otherwise it's reportedly very fine book. like, the best there is. – Cheers and hth. - Alf Sep 23 '11 at 15:06
  • @Alf: funny coincidence, I was actually debating on that yesterday about calling a function that takes 2 arguments on every element of a vector. And I ended up using loop just because it's readable. But I do prefer algorithm calls to handwritten loops. Is there a specific reason why you disagree? – Chenna V Sep 23 '11 at 15:18
  • 1
    @blueskin: without C++0x support you may need to create a predicate, the logic of the predicate is then far from its call site, unfortunately. `BOOST_FOREACH` is a good remedy for now, I think. – Matthieu M. Sep 23 '11 at 15:27

1 Answers1

3

Your best bet would be AStyle, however as you said this only does "syntax formatting":

Artistic Style is a source code indenter, formatter, and beautifier for the C, C++, C# and Java programming languages.

orlp
  • 112,504
  • 36
  • 218
  • 315