473,665 Members | 2,820 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Automatic C++ header generation?

I have begun designing and programming in C++ after a several years
away from software engineering/programming.

I am looking for an "automatic C++ header generator." I have what
seems to be fairly simple requirements:

1) command-line oriented tool
2) input .cpp files, output .h files
3) do not change the .cpp files if directed

The only tools I have found are "chic" and "lzz".

Chic apparently wants to talk to an Xserver, thus leading me to
believe it runs as a gui and is therefore does not appear to have a
cmdline-only option. (...and I'm unable to run it on a remote machine
easily)

lzz appears to 1) want to change the input .cpp file, and 2) can not
parse my more-complex .cpp file.

All of this seems quite disappointing. I was hoping this task would
not be hard to automate.

All of my source "g++ -ansi" compiles nicely.

Any toughts/suggestions?

-Matt

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.m oderated. First time posters: Do this! ]
Jul 22 '05 #1
6 10235
Matt wrote:
I have begun designing and programming in C++ after a several years
away from software engineering/programming.

I am looking for an "automatic C++ header generator." I have what
seems to be fairly simple requirements:

1) command-line oriented tool
2) input .cpp files, output .h files
3) do not change the .cpp files if directed

The only tools I have found are "chic" and "lzz".

Chic apparently wants to talk to an Xserver, thus leading me to
believe it runs as a gui and is therefore does not appear to have a
cmdline-only option. (...and I'm unable to run it on a remote machine
easily)

lzz appears to 1) want to change the input .cpp file, and 2) can not
parse my more-complex .cpp file.

All of this seems quite disappointing. I was hoping this task would
not be hard to automate.

All of my source "g++ -ansi" compiles nicely.

Any toughts/suggestions?

-Matt

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.m oderated. First time posters: Do this! ]


I been working on my own header generator tool, a GUI for
Windows platform. I was working on a database for inheritance
and include files. For example, you could select from various
design patterns: Singleton, equality, comparable, binary I/O,
and it would create the stencils for those methods in the class.

When specifying members, it would look up the types in the
database and provide the necessary include headers.

I've learned a lot more about C++, and coding styles since I
started the project. When I get the time, I need to go back
and redesign (refactor?) it. ;-)

In summary, this should not be a big task to write one yourself.
--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.l earn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.m oderated. First time posters: Do this! ]
Jul 22 '05 #2
Matt wrote:
I have begun designing and programming in C++ after a several years
away from software engineering/programming.

I am looking for an "automatic C++ header generator." I have what
seems to be fairly simple requirements:

1) command-line oriented tool
2) input .cpp files, output .h files
3) do not change the .cpp files if directed


Most things should be in .cpp files.

..h file should be very light.

If a brute-force script read a .cpp file and wrote a .h file, it wouldn't
know what to exclude. Large C++ programs can compile very slowly when their
..h files include more .h files, all containing much more stuff than each
translation unit actually needs.

Small C++ programs have no need of a .h file generator, because they should
have only a very few things to put in a .h file.

--
Phlip
http://industrialxp.org/community/bi...UserInterfaces
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.m oderated. First time posters: Do this! ]
Jul 22 '05 #3
Matt wrote:
I am looking for an "automatic C++ header generator." I have what
seems to be fairly simple requirements:

1) command-line oriented tool
2) input .cpp files, output .h files
3) do not change the .cpp files if directed


I think you're doing it in the wrong direction. The interface has to be
determined and written first, and then the implementation should follow.

So, what you probably need is a program that reads the interface from
the given header file and generates the stub for the implementation.
For example:

////////////////////////////////////////////////////////
// input: C.h
////////////////////////////////////////////////////////

class C
{
public:
void foo(char a, int b) const;

private:
static const double data[];
};

////////////////////////////////////////////////////////
// output: C.c++
////////////////////////////////////////////////////////

#include "C.h"

const double C::data[] = { };

void C::foo(char a, int b) const
{
}

--
Seungbeom Kim

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.m oderated. First time posters: Do this! ]
Jul 22 '05 #4

Hi,

Matt <ma**@downwiths pammers-mengland.net> writes:
1) command-line oriented tool
Tick mark for lzz.
2) input .cpp files, output .h files
3) do not change the .cpp files if directed
I think that point 2 and 3 cannot be both satisfied in C++. The
problem constructs being templates and inlining.

In order for the inline and template bodies to be available, they
should either go into the header file or a seperate file to be
included by other translation units.

In order for the generator to see these definitions, it will need to
be in the 'source' to the tool, and if this 'source' is also going to
be seen by your compiler, then the tool would have to modify the
source so that the compiler doesn't get a duplicate definition.
lzz appears to 1) want to change the input .cpp file,
lzz was designed to be driven by a seperate '.lzz' file. However, the
syntax in this file was kept as *standard* C++. lzz then
intelligently places declarations and definitions into the resulting
'.h' and '.cpp' files. Where you desire seperate files for template
bodies or inline functions, it can also be configured to create those
files too.
and 2) can not parse my more-complex .cpp file.
I would be very interested to see exactly what you are trying to
parse. The author of lzz is responsible for the grammar
implementation in the front end of our C++ parser. We also use 'lzz'
in house, and we are not shy about using C++ features.

For someone just looking at lzz, I can imagine that there are some
simple things that might not be obvious. For example, so that lzz
doesn't need to worry about C++ declaration ambiguities you must
always declare function parameter names.

void foo (int const &) {} // not accepted
void foo (int const &i) {} // ok

This allows lzz to parse C++ without needing a heavy semantic backend.
All of this seems quite disappointing. I was hoping this task would
not be hard to automate.


We now have about 350k of lines of lzz code, and I now find it alien
to have to write both a header and source file. As you may have
noticed, I am not shy about promoting the use of lzz, I think it
should be part of everybodies tool kit.
If you have a set of examples that you feel should be handled, I know
that the author will be very responsive, even if it is just to modify
the help.

Since it would be OT here, if you mail me directly some of the
examples I too maybe able to help.
Regards,

Richard
--
Richard Corden
To reply remove 's' from address

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.m oderated. First time posters: Do this! ]
Jul 22 '05 #5
"Matt" <ma**@downwiths pammers-mengland.net> wrote in message
news:3s******** *************** *********@4ax.c om...
I have begun designing and programming in C++ after a several years
away from software engineering/programming.

I am looking for an "automatic C++ header generator." I have what
seems to be fairly simple requirements:

1) command-line oriented tool
2) input .cpp files, output .h files
3) do not change the .cpp files if directed


Google for "Lazy C++".

Andrei

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.m oderated. First time posters: Do this! ]
Jul 22 '05 #6
Hello Richard, et al,

Thanks so much for all the feedback to this point.

One of the problems I had to conquer was my misunderstandin g of C++
header-file and body-file relationships. Once I got over that, things
became easier to understand.

In the end, however, I see that it might be difficult for me to
completely automate the generation of head files; there seems too much
benefit from human formatting and commenting. However, the automation
can help save a lot of mundane work.

The lzz problem with a specific part of source code remains; however,
it's not at this point a stumbling block, but if it is in the future,
I may email the lzz author(s) with the question/info.

Thanks again!
-Matt
On 21 Nov 2004 18:29:24 -0500, Richard Corden
<ri************ *@hotmail.com> wrote:
We now have about 350k of lines of lzz code, and I now find it alien
to have to write both a header and source file. As you may have
noticed, I am not shy about promoting the use of lzz, I think it
should be part of everybodies tool kit.


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.m oderated. First time posters: Do this! ]
Jul 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2440
by: Rasmus Fogh | last post by:
Someone raised the question of automatic code generation a few weeks back. And yes, we (CCPN) are using automatic Python code generation in a major way. Basically we are making data models in UML, and using automatic code generation to make Python APIs, XML I/O etc. (more below). We can be found at http://www.ccpn.ac.uk/index.html As a general point, automtic code generation would seem like a good idea in special cases where:
15
7883
by: Kannan Goundan | last post by:
Maintaining a C++ header file can be painful. I want a way to automatically generate header files from the implementation file. Does anybody know of a program that does this? If not, I'd like to try writing one. The input file would consist of function definitions and class definitions (with all methods defined inline). The program would extract all the signatures and place them in a header file. I can see some small problems...
6
4181
by: Mike Koerner | last post by:
Hi, I am having problems setting the HttpWebRequest Date header. I understand that it is a restricted header and I do receive the "This header must be modified with the appropriate property." Is there a way to make sure that the date header is sent over or a way to work around this exception? Here's a sample of the code:
4
2523
by: Petterson Mikael | last post by:
Hi, Anyone out there that knows of a automatic test generation tool for cpp? Another requirement is that the test results should be presented in xml. All hints appreciated. cheers, //mikael
1
2504
by: woessner | last post by:
I have a lot of classes which derive from a common base class. I want to be able to clone objects of these types so I have given the base class a pure virtual clone method. The derived classes all have complete copy constructors so the cloning process will consiste of "return new Derived(*this);". Here's the setup: struct Base { virtual Base* Clone() const = 0; };
0
312
by: JoshforRefugee | last post by:
heard that we can do automatic code generation using macros, but not sure how can I pursue this. Here is my problem. In my env, I have class A,B and C. All of them has constructors, and few common methods, like reset, and execute. now my env(main) class actually is where I am creating this objects. in .h A myA; B myB;
9
2887
by: puzzlecracker | last post by:
From my understanding, if you declare any sort of constructors, (excluding copy ctor), the default will not be included by default. Is this correct? class Foo{ public: Foo(int); // no Foo() is included, i believe. };
25
2646
by: sidd | last post by:
In the following code: int i = 5; ---it goes to .data segment int j; ---it goes to bss segment int main() { int c; int i = 5; ---stack
34
3663
by: =?ISO-8859-1?Q?Marcel_M=FCller?= | last post by:
Hi, is there a way to avoid the automatic copy constructor generation. I do not want the object to be non-copyable. I simply do not want that copying is done by the default copy constructor. But there is a constructor that accepts the base class. This one should be used for copying. In fact i have a set of classes with a common abstract base. The implementations do not have own data members. They only implement
0
8348
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8549
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8636
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6187
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5660
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4356
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2765
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2004
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.