Menu

MainPage

Featured (1)
Anonymous

Navigate through the wiki

  • Introduction
  • Package contents
    • XmlCppClassGenerator contents
    • List of xml files
  • Help on the package
  • Requirements

Introduction

This package aims at producing nice header and implementation files for C++ classes and structures. Being a C++ developer myself, I like to have my class members to be private or protected, meaning that set/get methods have to be written. I also try to add meaningful comments, which becomes a pain in the neck when class A has around 20 protected members. I tried then to find a way to automatically build the header and implementation files from a generic class description. I didn't find anything fulfilling my purpose, then I decided to code it myself. Some examples can be found here.

I work a lot with XML files, they have the advantage to be both human and machine readable. This is why the class description is written in a XML file. This file contains information about the class name, its author, the constructors and methods (with their arguments), the members, parent class(es), etc. A complete description can be found in the XML file description page.

Since the package has to deal with string manipulation, my first idea was to use Perl, but the class hierarchy I needed was more compatible with Python. Moreover, the xml.dom.minidom python module makes XML manipulation easy. Therefore the chosen language for this package is Python.

Package contents

The package consists of two parts: the python module XmlCppClassGenerator and a directory (XmlCppClassGeneratorInfo) containing the XML schema describing the structure of the XML class file, a translation XML file with the corresponding XML schema file.

XmlCppClassGenerator contents

The XmlCppClassGenerator module consists of four related submodules :

  • a module defining python classes, each of them representing various objects found in a C++ class definition, like method, argument, member, ...
  • a module defining a customisable output messaging service, allowing to put debug, warning statements in the code, which can be enabled or disabled at runtime.
  • a module responsible for providing character strings depending on the wanted language (used for class generation and output in the terminal).
  • a module responsible for the XML reading and creation of the representation of the C++ class, this object being used to generate both header and implementation file.

List of xml files

The XmlCppClassGeneratorInfo directory contains:

  • the XML schema file XmlCppClassGenerator.xsd describing the structure of the XML file containing the class description.
  • the XML schema file Languages.xsd, which describes the structure of the translation file.
  • the XML file Translations.xml, which contains the translations (at the moment english and french are implemented).
  • the XML schema file Statements.xsd, which describes the structure of the file containing C++ statements (basically method bodies).
  • the XML file Bodies.xml, which contains the bodies of the different methods.

Help on the package

How to run the package is explain on the how to page.

Since the class you want to create has to be described in a XML file, the structure of this XML file has to be described. In this page is given a full example of a valid XML file.

The translation file (contents, how to write it, ...) is described in this page. With the given information you will be able to add your favourite language to the package.

Finally, information on the XML file providing the method bodies are given in here.

Requirements

The requirements are checked when the installation is performed, by the dedicated ./configure script.

  • libxml2-utils for xmllint (XML validation program) is needed.
  • the needed python modules are provided by the standard python package (version 2.7 and later), namely :
    • minidom
    • codecs
    • subprocess
    • argparse

Related

Wiki: ExamplesOutput
Wiki: HowTo
Wiki: WikiMap
Wiki: XmlFileContent
Wiki: XmlStatementFile
Wiki: XmlTranslationFile

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.