automatic source code

C

cedric buerfent

Hello NG,

I ve a question concerning automatic generated source code.

When I program the declarations of a class (and save it in a file

called myclass.hh for example), its a boring work to create the

..cc "basics" (I mean the empty method bodies like void

myclass::afunction() {} , the constructors, the destructors, copy
constructors etc...)

Is there a way to automate this task?


Greetings ,

Cedric Buerfent
 
O

osmium

cedric said:
I ve a question concerning automatic generated source code.

When I program the declarations of a class (and save it in a file

called myclass.hh for example), its a boring work to create the

.cc "basics" (I mean the empty method bodies like void

myclass::afunction() {} , the constructors, the destructors, copy
constructors etc...)

Is there a way to automate this task?

You could use a macro key utility, such as Recorder, which came with Windows
3.1. That's just an example, it's a pathetic bit of work but it gives you
the right kind of thing to look for. I have never found such a program that
*really* pleased me. There is a thing called "Mouse and Key Recorder" which
is almost good. But it is demo ware which quits working after a while. Or
almost quits, I don't recall whether it is a full stop or a partial
disabling.

Some editors have such capability built in.
 
C

cedric buerfent

The Idea is rather simple:

- we take a header file

<click>

- we got an implementation file


I ve around 20 classes to "implement" and copy pasting is such a
straightforward-nonsense.

(I could rather spend my time in the "hardstuff" imlementationbodies )

I m using xemacs at work.

Im not sure if a "recorder" tool would satisfy our needs (for generic
use).

Perhaps its easier for me first to program such a tool :)

(pseudo-code:
class keyword - hopp we got the class name,
new lines until class ends are our functions etc...)

Perhaps you guys know which "IDE" has this functionality-(plugin)?
(eclipse, kdevelop, xemacs, kwrite:)? )


greetings,

cedric
 
B

Buster

cedric said:
I m using xemacs at work.

Im not sure if a "recorder" tool would satisfy our needs (for generic
use).

Type "C-h C-i m emacs <RET> m keyboard macros <RET>".
 
B

Buster

Buster said:
Type "C-h C-i m emacs <RET> m keyboard macros <RET>".

Sorry, the "C-i" should be "i". Like this:
C-h i m e m a c s <return> m k e y b o a r d SPC m a c r o s <return>
 
R

Roger Leigh

cedric buerfent said:
I ve a question concerning automatic generated source code.

When I program the declarations of a class (and save it in a file
called myclass.hh for example), its a boring work to create the .cc
"basics" (I mean the empty method bodies like void
myclass::afunction() {} , the constructors, the destructors, copy
constructors etc...)

Is there a way to automate this task?

Yup.

I preprocess my sources with GNU m4. My custom macros expand certain
text in the headers, and expand all the appropriate member variables
into "properties", each with a getter, setter, property, changed
signal and some other stuff (kind of like Glib::Object properties, but
not so advanced). In the header, it expands into all the prototypes
and member variables; in the source, it expands into the functions
themselves, plus boilerplate init code to place into the constructors.

This makes adding/changing "trivial" bits as simple as adding/changing
1 line in a header, leaving me free to concentrate on the interesting
stuff rather than cranking out hundreds of identical code snippets.

It seems you want something a bit less exciting: a template generator.
Why not write one yourself, which asks you a few questions (name of
the class, extra details etc.) and spits out a sample header.
Personally, I have a set of standard templates for headers and source
files, which I just copy and fill out--a simple search and replace
fills out the class name and include guards.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top