WORM 0.2
A C++ DAL/ORM code generation framework
Public Member Functions

WSql::WormClassGenerator Class Reference

The main class in the ORM generator. More...

#include <wormclassgenerator.h>

List of all members.

Public Member Functions

 WormClassGenerator (WSqlDatabase &db)
 Constructs a generator with the database db.
void run ()
 Run the generator.
bool init ()
 Initialize templates and metadata.
void addTable (const std::string tablename)
void setTemplateDirectory (const std::string dir)
void setOutputDirectory (const std::string dir)

Detailed Description

The main class in the ORM generator.

generator class This class is the central class in the ORM generator. It requires a valid WSqlDatabase object and is used in this manner:

    WSql::WSqlDatabase db( drivertype );
    db.setDatabaseName( dbname );
    db.setUserName( username );
    db.setHostName( hostname );
    db.setPassword( password );
 
    if ( !db.open() ) {
      some_error_func();
    }
 
     WSql::WormClassGenerator gen(db);
     gen.setTemplateDirectory(templatesdir);
     gen.setOutputDirectory(outputdir);
     if(!gen.init())
          some_error_func();
     else
          gen.run();

Definition at line 30 of file wormclassgenerator.h.


Constructor & Destructor Documentation

WSql::WormClassGenerator::WormClassGenerator ( WSqlDatabase db)

Constructs a generator with the database db.

Definition at line 88 of file wormclassgenerator.cpp.


Member Function Documentation

void WSql::WormClassGenerator::addTable ( const std::string  tablename) [inline]

Definition at line 39 of file wormclassgenerator.h.

bool WSql::WormClassGenerator::init ( )

Initialize templates and metadata.

This method initializes the database metadata and loads the available templates. It must be called (and optionally checked for success) before run().

On failure this sets a message in the database object and returns false.

Return values:
bool- true if templates and metadata successfully initialized.

Definition at line 101 of file wormclassgenerator.cpp.

void WSql::WormClassGenerator::run ( )

Run the generator.

This method iterates through the available templates for each configured table, calls expand() and writes the results to a class file. It is the principle control function for WormClassGenerator.

If no tables have been added it assumes that all tables in the database are to be generated.

See also:
addTable() setTemplateDirectory() setOutputDirectory()

Definition at line 155 of file wormclassgenerator.cpp.

void WSql::WormClassGenerator::setOutputDirectory ( const std::string  dir)

Sets the output directory to dir - also appends directory separator if necessary.

Todo:
make portable.
Parameters:
std::stringdir - write generated files to this directory

Definition at line 345 of file wormclassgenerator.cpp.

void WSql::WormClassGenerator::setTemplateDirectory ( const std::string  dir)

Sets the templates directory to dir - also appends directory separator if necessary.

Todo:
make portable.
Parameters:
std::stringdir - look for templates in this directory

Definition at line 356 of file wormclassgenerator.cpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Defines