Class Generator - Users Manual



Table of contents
-----------------

1. Introduction
2. Restrictions in the demo version
3. Install
4. Uninstall
5. Generating classes
6. Tag reference
7. Command line reference
8. Final words


1. Introduction
---------------

Class Generator is a simple-to-use, still very customizable command line tool for generating C++ classes. As input it takes class name, namespaces, template files and the output directory for the generated .h and .cpp files. You may easily create your own template files in order to give the generated files the structure you require.

Class Generator runs on Windows 95/98/NT/ME/2000.


2. Restrictions in the demo version
-----------------------------------

The software has 30 evaluation days. No features are disabled.


3. Install
----------

Installing Class Generator is a simple procedure:
1. Create a directory suitable for installation For example, "c:\Program Files\classgenerator\"
2. Extract the zip file into the directory. Make sure you keep the directory structure from the zip file. If you don't have a zip extractor, please download Winzip at http://www.winzip.com/.

The installation is now finished.

If you like, add the directory where you installed Class Generator to the PATH environment variable. The system will search that directory when looking for executable files.


4. Uninstall
------------

Simple. Just delete the files added during installation. (Class Generator does not make any changes to the registry.)


5. Generating classes
---------------------

Class Generator generates classes from what we call template files. The template files contains tags, which will be replaced by the generator. If no templates are specified Class Generator will use the default templates. These two files are called Default.h and Default.cpp and are located in the templates subfolder.

You may easily create your own template files in an appropriate text editor.

For examples, see chapter 7.


6. Tag reference
----------------

<CLASSNAME>
This tag will be replaced with the class name that you specify.
Example:

class <CLASSNAME> {};
Let the class name be TestClass, the output will then be:
class TestClass {};

<CLASSNAME_FOR_DEFINE>
This tag will be the same as class name, but in uppercase.
Example:

#define <CLASSNAME_FOR_DEFINE>_H
Let the class name be TestClass, the ouput will then be:
#define TESTCLASS_H

<NAMESPACE>
This tag will be replaced with the namespace scope.
Example:

using namespace <NAMESPACE>;
If the namespaces specified are ns1 and ns2, then the output will be:
using namespace ns1::ns2;

<NAMESPACE_FOR_DEFINE>
This tag will be replaced with the namespace names in uppercase separated by underscores.
Example:

#define <NAMESPACE_FOR_DEFINE>_HELPERS_H
If the namespaces specified are ns1 and ns2, then the output will be:
#define NS1_NS2_HELPERS_H

<NAMESPACE_START>
This tag indicates where a namespace definition starts. It must have a corresponding <NAMESPACE_STOP> tag.


<NAMESPACE_STOP>
This ends a namespace scope that was created with the <NAMESPACE_START> tag.
Example:

<NAMESPACE_START>
class ClassInNamespace {};
<NAMESPACE_STOP>
If the namespaces specified are ns1 and ns2, then the output will be:
namespace ns1
{
  namespace ns2
  {
     class ClassInNamespace {};
  } //namespace ns2
} //namespace ns1


7. Command line reference
-------------------------

Here is a description of the Class Generator arguments.

-help
Displays help and version information.

-classname <name>
Sets the name of the class to generate, replaces the <CLASSNAME> tag. The generated files are named <name>.h and <name>.cpp.

-namespace <name1;name2;...>
Sets the name of the namespace created between the <NAMESPACE_START> and <NAMESPACE_STOP> tag. Use ; to separate multiple namespaces.

-outputdir <dir>
Sets the output directory for the generated .h and .cpp files. If not specified the files are generated in the current working directory.

-namespacerelative
Generate the classes in a subfolder specified by the namespace. For example, if -namespace is set to org;apache and the output directory is set to c:\source\ the generated class is saved in c:\source\org\apache\. The subfolder is not created.

-overwrite
Overwrite existing files in the output directory.

-htemplate <file>
Specifies the .h template file. If not specified the default template is used.

-cpptemplate <file>
Specifies the .cpp template file. If not specified the default template is used.


Example 1
Generate a class in the namespace org::apache from the default templates:

classgenerator -classname TestClass -namespace org;apache

The generated files TestClass.h and TestClass.cpp are saved in the current directory.

Example 2
Generate a class in the namespace com::mycompany from the MyCompany templates:

classgenerator -classname TestClass -namespace com;mycompany -htemplate c:\mytemplates\MyCompany.h -cpptemplate c:\mytemplates\MyCompany.cpp

The generated files TestClass.h and TestClass.cpp are saved in the current directory.

Example 3
Generate a class in the namespace org::apache from the default template. Specify the root of the generated files with the -outputdir flag. Set the -namespacerelative flag to generate the classes relative from the output directory in a subfolder specified by the namespace.

classgenerator -classname TestClass -namespace org;apache -outputdir c:\source -namespacerelative

The generated files TestClass.h and TestClass.cpp are saved in c:\source\org\apache\. If -namespacerelative is not specified the files are saved in c:\source\.

7. Final words
-------------
-
Thank you for using Class Generator. If you have questions or comments, please contact
sureshot@bysoft.se
http://sureshot.virtualave.net/