cpp: copy across boilerplate formatter and associated classes

- move code from cpp formatters.
cpp: start making use of boilerplate in class header formatter