Made a tool you C++ guys may be interested in

Started by
23 comments, last by dominicoder 18 years, 10 months ago
In addition to the operator overloading, it would be nice to be able to specify function names and parameters as well, and maybe a quick comment description of what the function does. This way in the end all that would need to be done would be to open up the .cpp file and throw the code into the functions.

EDIT: Very cool idea by the way. I like it a lot. It can see it saving quite a bit of time if you are making lots of different classes...which I often do.
-Dan- Can't never could do anything | DansKingdom.com | Dynamic Particle System Framework for XNA
Advertisement
Quote:Original post by deadlydog
In addition to the operator overloading, it would be nice to be able to specify function names and parameters as well, and maybe a quick comment description of what the function does. This way in the end all that would need to be done would be to open up the .cpp file and throw the code into the functions.


I thought about that, but decided it wouldn't be worth the effort. I can't think of an effecient way to provide that functionality. In the time you'd select options and specify names and parameters, you could just have written the function in the files. Of course, if you can think of an effective way to do it, I'll consider it.

Quote:
EDIT: Very cool idea by the way. I like it a lot. It can see it saving quite a bit of time if you are making lots of different classes...which I often do.


Thanks! Glad you like and find it useful.

BTW, I'm adding the functionality to select a template base as suggested above. I'll update that and post soon.

Quote:Original post by ldramire
I'm not familiar with inline files ... I'll look into that.

Oh, Inline Files? They could as well just be named .cpp files. The only difference is that they are usually included directly into the .h files. Some people also call them .inc (Include) files (used in PHP as well). The point is that they are meant to avoid needing to place all the code in the header files when you want a class's functions to be inlined by the compiler. Its a way of making the code more readable. In the end, I basically use it for stuffing the definition of class's methods inside the header file.


Quote:Original post by ldramire
Quote:
(2) I can specify a templated class, but I can not specify to inherit from a templated class. The syntax for inheriting from templated classes is slightly different than inheriting from non-templated classes.

Interesting ... never knew that ... I'll look into that as well.

Here's an example:
-----
template < typename T >
class Derived : public Base< T >
-----
Notice that when inheriting from class Base, you need the < T > after the class. But thats only if the type T from the derived and base classes will match, do you know what I mean? It would be perfectly legal to say " public Base< float > ", but I have never found I need to specialize in that way.

Quote:Original post by ldramire
Quote:
Also, I think the generated syntax for C++ class templates is not correct OR VS.NET is not standards compliant (I think its the former though).


Strange ... that's how my textbook does it. Guess I'll look into that as well...

Hmm. I had a textbook that told me to write it in a fashion very similar, but to include the ".cpp" file at the botton of the .h file, because the compiler needs the definitions of all the class methods available at *compile time*, not run-time.

It doesn't compile with MS VS.NET. VS 6 and lower have a reputation for being non-standards compliant, but I have heard good things about templates and VS.NET.

Quote:Original post by ldramire
Quote:
...
2) Include the .cpp (I usually name them .inl) right after the class definition in the .cpp file. So you'll have in the .h file
*** Source Snippet Removed ***


You lost me there ... include the cpp after the definition in the cpp? Could you elaborate?

No, include the .cpp file for the class right after the closing Brace in the header file. This allows the compiler to have access to the definitions of all the class methods at compile time. I usually name the .cpp a .inl file instead, just to remind me that I'm including it directly into the header.

Here's another example:
// Header file for class A#ifndef A_H#define A_Htemplate < typename T >class A{  A();  ~A();  void DoStuff();};//Notice I include the .cpp file in the .h file, effectively moving all the text from the .cpp file to this line on the header file#include "a.cpp" #endif

// Source file for class A (i.e. Method Definitions)//Notice how you *Do Not* #include "a.h" in this file//constructortemplate < typename T >A< T >::A(){}//destructortemplate < typename T >A< T >::~A(){}//DoStufftemplate < typename T >void A< T >::DoStuff(){}


I could have just typed those 3 method definitions right after the Closing Brace and the semi-colon for class A, instead of #include'ing "a.cpp" in the header file.

The above example is a complete templated class (while is does essentially nothing).
Thanks for the tips on inline files and template inheritance. I hate it when textbooks don't cover such useful information.

Just for you wyrzy I've updated the tool with options to allow inheritance from template base classes and inlining the source file.

The class you make must have at least as many parameters as the base, and must also be a template if the base is a template. I think that's the most common implementation I found and it saves me alot of headaches.

I tried including the .cpp file in the inline version, but that wouldn't compile (I think VS goes for the cpps first and craps out when it can't find the accompanying header), though the .inl version did, so it just defaults to that extension if you inline the source file.

Here's the link again of the updated version http://www.rit.edu/~ldr2567/ClassMaker/

Hopefully I didn't break something in adding new features. Thanks again everyone for all the suggestions. If you have any more, post 'em or PM me. Thanks.
Thats great, I like it alot. On the subject of filling in functions and parameters, how about having a page with say 10 text fields on it. You tap in a bunch of function protypes, and a bit of a comment, then hit apply and it adds all those functions to the class, clears the boxes, then you're ready to go again. Certainly would beat typing them by hand, or using that damn AddFunction wizard in VS.NET!
Dammit, you just gave me an idea, which means I have to stop what I'm doing and put that in there! [grin]

I'll see how quickly I can get that option in and post back. Thanks.
If anyone's still interested, I've updated the tool to allow adding member functions to the files. Not competely perfect, but should still be useful.
I don't know but for me it loads pretty slow.. like 10 secs to start up, 512megs of ram 2.4ghz processor and a mean graphics card :P just a good old radeon 9000 but it probably takes longer for me to load this program than adobe photoshop, dunno
Nice additions, thanks! Something going wrong though, I made a test class, and then added a class, but the class delcaration appears outside the class!

#ifndef GTVECTOR_H#define GTVECTOR_Hclass gtVector{	public:		gtVector();		~gtVector();		gtVector operator/(const gtVector& gtvector) const;		gtVector operator%(const gtVector& gtvector) const;		gtVector operator&(const gtVector& gtvector) const;};#endif		bool IsAlive();


Nice work though. What would be nice is the ability to load classes back in to modify them, and also maybe the ability to list the functions that you have added, so you know where you're up to (maybe just have a pane that lets you view the actual .h file. That would be great!
Quote:Original post by Anonymous Poster
I don't know but for me it loads pretty slow.. like 10 secs to start up, 512megs of ram 2.4ghz processor and a mean graphics card :P just a good old radeon 9000 but it probably takes longer for me to load this program than adobe photoshop, dunno


That's really odd ... don't know what to tell you.

Quote:Original post by JohnHurt
Nice additions, thanks! Something going wrong though, I made a test class, and then added a class, but the class delcaration appears outside the class!


I think you mean member function, right? Yeah ... appending to the end of the file was the easiest way to do it, even if it is outside the class definition. I made a note of this on that tab indicating that's what happens. Otherwise I'd have to parse through the file and figure out where to stick the thing and it felt like too much trouble [grin].

I'll work on it though ... shouldn't be too bad if I put some thought into it...check back after the weekend.

Quote:
Nice work though. What would be nice is the ability to load classes back in to modify them ...


I'd like to do that, but it'd be quite a challenge to be able to acurately parse a file that's been edited and fill in all the form's attributes accordingly. Doable, but it'll take time ... lots of time. I'll definitely make a note of that however, and keep in mind for later.

Quote:
... , and also maybe the ability to list the functions that you have added, so you know where you're up to (maybe just have a pane that lets you view the actual .h file. That would be great!


Good idea! I too keep losing track of which functions I've added ... that's definitely doable.

Thanks for the suggestions. Glad you're finding it useful. I'll work on some of the suggestions. Meanwhile I've made a few tweaks (fixed a bug or two, added "friend" functions) that's a slight improvement. Man I wish I'd actually put time into actually designing this thing...

This topic is closed to new replies.

Advertisement