Author Topic: Idea : generate boilerplate code  (Read 4232 times)

Offline bugmenot

  • Multiple posting newcomer
  • *
  • Posts: 32
Idea : generate boilerplate code
« on: March 28, 2008, 06:38:38 pm »
Hello,

I really like CodeBlocks and would like to make a suggestion for an improvment.

The class Wizard is nice but it doesn't really speed coding up. I'd love to see a plugin that does the following:
  • When I create a header it automatically inserts header guards. The macro name should automatically be unique so either it is a mangled version of the file name or a GUID. When that is done positioning the cursor between the include guards would be nice.
  • A button that auto generates a skeleton cpp based on the header. For example you have the following header:
Code
#ifndef HEADER_HPP
#define HEADER_HPP
class Foo{
  void test();
  void bar(int, unsigned =3)const;
  static int a;
  int b;
};
void func();
#endif
and it generates:
Code
void Foo::test(){

}

void Foo::bar(int, unsigned)const{

}

int Foo::a;

void func(){

}
Now that code competition is implemented it should be possible to scan the header file and use that information the generate cpp file.


Offline Kos

  • Single posting newcomer
  • *
  • Posts: 7
Re: Idea : generate boilerplate code
« Reply #1 on: March 28, 2008, 11:15:19 pm »
  • When I create a header it automatically inserts header guards. The macro name should automatically be unique so either it is a mangled version of the file name or a GUID. When that is done positioning the cursor between the include guards would be nice.
  • A button that auto generates a skeleton cpp based on the header.
1) I just type "guard" and press ctrl+J, see "Abbreviations" in Editor options for details.
2) Rightclick in the editor, and in the context menu there should be something like "Insert->All class methods without implementation", or something like this (I don't have C::B on this machine, but you will probably find it easily).

Hope that helps :)