Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

dbscMain.cpp File Reference

File containing IOPC DBSC's main() function and some functions used by it. More...

#include "StdString.h"
#include <iostream>
#include <fstream>
#include "dbscStrings.h"
#include "messagePrinting.h"
#include "DBSchemaGenerator.h"
#include "MetadataLoader.h"

Include dependency graph for dbscMain.cpp:

Include dependency graph

Defines

#define DEFAULT_CREATE_SCRIPT_NAME   "create.sql"
#define DEFAULT_DROP_SCRIPT_NAME   "drop.sql"
#define DEFAULT_EXPLAIN_SCRIPT_NAME   "explain.sql"

Functions

void showProgramInfo ()
void showHelpHint ()
void showHelp ()
int setSourceFile (char *arg, CStdString &inputFile, bool useMissingParameterMsg=0, bool printMessage=1)
int parseCommandLine (int argc, char **argv, CStdString &inputFile, CStdString &createScriptFile, CStdString &dropScriptFile, CStdString &explainScriptFile, bool &generateCreationComments)
int processMetadata (const char *inputFile, const char *createScriptFile, const char *dropScriptFile, const char *explainScriptFile, bool generateCreationComments)
int main (int argc, char **argv)

Detailed Description

File containing IOPC DBSC's main() function and some functions used by it.

Author:
Josef Troch (josef.troch@email.cz)
Date:
2003 - 2004

Define Documentation

#define DEFAULT_CREATE_SCRIPT_NAME   "create.sql"
 

Default name of DB schema creation script (used if user specifies "-c" switch without filename).

#define DEFAULT_DROP_SCRIPT_NAME   "drop.sql"
 

Default name of DB schema drop script (used if user specifies "-d" switch without filename).

#define DEFAULT_EXPLAIN_SCRIPT_NAME   "explain.sql"
 

Default name of explain plan script (used if user specifies "-e" switch without filename).


Function Documentation

void showProgramInfo  )  [static]
 

Shows program info (DBSC_PROGRAM_INFO).

void showHelpHint  )  [static]
 

Shows hint how to get help (DBSC_HELP_HINT).

void showHelp  )  [static]
 

Shows help - IOPC DBSC usage (DBSC_HELP).

int setSourceFile char *  arg,
CStdString &  inputFile,
bool  useMissingParameterMsg = 0,
bool  printMessage = 1
[static]
 

Helper function - tests whether arg specifies a file, if so and inputFile is empty returns the filename in inputFile. If inputFile is non-empty displays error message and return 1. If printMessage is set and the file is not found, another error message is printed.

Parameters:
arg Argument that could be the file name.
inputFile Reference to string specifying name of file which should be processed by IOPC DBSC. (In/out parameter!)
useMissingParameterMsg Which message should be used if the file is not found - if the flag is set DBSC_ERROR_MISSING_PARAMETER is used, otherwise DBSC_ERROR_UNKNOWN_OPTION is used.
printMessage Whether an error message should be printed if some error is encountered.
Returns:
0 if OK, 1 in case of error.

int parseCommandLine int  argc,
char **  argv,
CStdString &  inputFile,
CStdString &  createScriptFile,
CStdString &  dropScriptFile,
CStdString &  explainScriptFile,
bool &  generateCreationComments
[static]
 

Parses IOPC DBSC's command line (argc, argv), returns acquired values in the remaining parameters.

Note:
If options "-c" or "-d" or "-e" are given without any filename DEFAULT_CREATE_SCRIPT_NAME, DEFAULT_DROP_SCRIPT_NAME and DEFAULT_EXPLAIN_SCRIPT_NAME are used.
Parameters:
argc Input - argc parameter of main() function.
argv Input - argv parameter of main() function.
inputFile Output - name of file to be processed.
createScriptFile Output - name of file into which DB schema creation script should be output (empty if this script is not desired).
dropScriptFile Output - name of file into which drop DB schema script should be output (empty if this script is not desired).
explainScriptFile Output - name of file into which explain plan script should be output (empty if this script is not desired).
generateCreationComments Should comments be generated into DB schema creation script?
Return values:
0 OK
1 Invalid command line
2 Option "-h" selected, help displayed.

int processMetadata const char *  inputFile,
const char *  createScriptFile,
const char *  dropScriptFile,
const char *  explainScriptFile,
bool  generateCreationComments
 

Processes the metadata, creates desired scripts

Loads the metadata using XMLMetadataLoader, using DBSchemaGenerator checks whether the metadata are valid (DBSchemaGenerator::createInheritanceHierarchy(), DBSchemaGenerator::checkInheritanceHierarchy()) and generates missing values such as DB table names (DBSchemaGenerator::generateMissingValues(), DBSchemaGenerator::generateColumnTypes()).

Then generates all the scripts for which non empty filename was given (DBSchemaGenerator::generateCreationScript(), DBSchemaGenerator::generateDropScript(), DBSchemaGenerator::generateExplainScript()).

  • Schema creation script: creates database structures (tables, views, indexes etc.) needed for the application whose metadata we are processing to run.
  • Drop schema script: destroys the database structures.
  • Explain plan script: explains execution plans for selecting all columns from classes' persistent and simple views.

Parameters:
inputFile Name of file to be processed
createScriptFile Name of schema creation script (empty if the script should not be generated).
dropScriptFile Name of drop schema script (empty if the script should not be generated).
explainScriptFile Name of explain plan script (empty if the script should not be generated).
generateCreationComments Should comments be generated into DB schema creation script?
Returns:
0 if OK, 1 in case of error.

int main int  argc,
char **  argv
 

Main function of IOPC DBSC.

Parses its command line (argc, argv) using parseCommandLine(). If the command line is valid processMetadata() is called.

Returns:
0 if OK, non-zero in case of error.


Generated on Wed Aug 11 22:33:45 2004 for IOPC by Doxygen 1.3.6