# class toExtract

This class can be used to reverse engineered database objects. More...

Definition | `#include <toextract.h>`
List of all Methods

Annotated List
Files
Globals
Hierarchy
Index

#### Public Types

- class datatype
- class extractor
- struct columnInfo

#### Public Methods

- toExtract (toConnection &conn,QWidget *parent)
- QString create (std::list<QString> &object)
- void create (QTextStream &stream,std::list<QString> &object)
- std::list<QString> describe (std::list<QString> &object)
- QString drop (std::list<QString> &object)
- void drop (QTextStream &stream,std::list<QString> &object)
- QString migrate (std::list<QString> &drpLst,std::list<QString> &crtLst)
- void migrate (QTextStream &stream,std::list<QString> &drpLst,std::list<QString> &crtLst)
- void setState (const QCString &name,const QVariant &val)
- QVariant state (const QCString &name)
- void setSchema (const QString &schema)
- void setResize (const QString &resize)
- void setPrompt (bool prompt)
- void setHeading (bool heading)
- void setConstraints (bool constraints)
- void setIndexes (bool indexes)
- void setGrants (bool val)
- void setStorage (bool val)
- void setParallel (bool val)
- void setPartition (bool val)
- void setContents (bool val,int commitdistance)
- void setComments (bool val)
- void setCode (bool val)
- void setBlockSize (int val)
- const QString & getSchema (void)
- bool getResize (void)
- bool getPrompt (void)
- bool getHeading (void)
- bool getConstraints (void)
- bool getIndexes (void)
- bool getGrants (void)
- bool getStorage (void)
- bool getParallel (void)
- bool getPartition (void)
- bool getContents (void)
- int getCommitDistance (void)
- bool getComments (void)
- bool getCode (void)
- int getBlockSize (void)
- toConnection & connection ()
- void initialNext (const QString &blocks,QString &initial,QString &next)
- QString intSchema (const QString &owner,bool desc)
- std::list<datatype> datatypes ()
- QString createFromParse (std::list<toSQLParse::statement>::iterator start, std::list<toSQLParse::statement>::iterator end)

#### Public Static Methods

- static void srcDst2DropCreate (std::list<QString> &source,std::list<QString> &destination, std::list<QString> &drop,std::list<QString> &creat)
- static bool canHandle (toConnection &conn)
- static void addDescription (std::list<QString> &ret,const std::list<QString> &ctx, const QString &arg1=QString::null,const QString &arg2=QString::null, const QString &arg3=QString::null,const QString &arg4=QString::null, const QString &arg5=QString::null,const QString &arg6=QString::null, const QString &arg7=QString::null,const QString &arg8=QString::null, const QString &arg9=QString::null)
- static std::list<QString> splitDescribe (const QString &str)
- static QString partDescribe (const QString &str,int level)
- static QString contextDescribe (const QString &str,int level)
- static std::list<columnInfo> parseColumnDescription (std::list<QString>::const_iterator begin, std::list<QString>::const_iterator end, int level=3)
- static std::list<columnInfo> parseColumnDescription (const std::list<QString> &description,int level=3)

#### Public Members

- friend class extractor

## Detailed Description

This class can be used to reverse engineered database objects.

datatype (class)

### datatype

Describes an available datatype for the database.

extractor (class)

### extractor

This is an abstract class to implement part of an extractor for a database. Observe that an extractor must be stateless and threadsafe except for constructors and destructors. Use the toExtract::context function for saving context.

toExtract (toConnection &conn,QWidget *parent)

### toExtract

Create a new extractor.

Parameters:

conn | Connection to extract from.
parent | Parent widget of progress indicator.

QString create (std::list<QString> &object)

### create

Create script to recreate list of objects.

Parameters:

object

List of object. This has the format {type}:{schema}.{object}. The type is database dependent but can as an example be of CONSTRAINT, DATABASE LINK, EXCHANGE INDEX, EXCHANGE TABLE, FUNCTION, INDEX, MATERIALIZED VIEW, MATERIALIZED VIEW LOG, PACKAGE, PACKAGE BODY, PROCEDURE, PROFILE, ROLE, ROLE GRANTS, ROLLBACK SEGMENT, SEQUENCE, SNAPSHOT, SNAPSHOT LOG, SYNONYM, TABLE, TABLE FAMILY, TABLE CONTENTS, TABLE REFERENCES, TABLESPACE, TRIGGER, TRIGGER, TYPE, USER, USER GRANTS for Oracle databases.

Returns: A string containing a script to recreate the specified objects.

void create (QTextStream &stream,std::list<QString> &object)

### create

Create script to recreate list of objects.

Parameters:

stream | Stream to write result to.

object

List of object. This has the format {type}:{schema}.{object}. The type is database dependent but can as an example be of CONSTRAINT, DATABASE LINK, EXCHANGE INDEX, EXCHANGE TABLE, FUNCTION, INDEX, MATERIALIZED VIEW, MATERIALIZED VIEW LOG, PACKAGE, PACKAGE BODY, PROCEDURE, PROFILE, ROLE, ROLE GRANTS, ROLLBACK SEGMENT, SEQUENCE, SNAPSHOT, SNAPSHOT LOG, SYNONYM, TABLE, TABLE FAMILY, TABLE CONTENTS, TABLE REFERENCES, TABLESPACE, TRIGGER, TRIGGER, TYPE, USER, USER GRANTS for Oracle databases.

std::list<QString> describe (std::list<QString> &object)

### describe

Create a description of objects.

Parameters:

object

List of object. This has the format {type}:{schema}.{object}. The type is database dependent but can as an example be of CONSTRAINT, DATABASE LINK, EXCHANGE INDEX, EXCHANGE TABLE, FUNCTION, INDEX, MATERIALIZED VIEW, MATERIALIZED VIEW LOG, PACKAGE, PACKAGE BODY, PROCEDURE, PROFILE, ROLE, ROLE GRANTS, ROLLBACK SEGMENT, SEQUENCE, SNAPSHOT, SNAPSHOT LOG, SYNONYM, TABLE, TABLE FAMILY, TABLE CONTENTS, TABLE REFERENCES, TABLESPACE, TRIGGER, TRIGGER, TYPE, USER, USER GRANTS for Oracle databases.

Returns: A list of strings describing the objects. Each string should be considered like a list of strings separated by the character '\001'. The later in each string the smaller item the change and it is hierachical.

QString drop (std::list<QString> &object)

### drop

Create script to drop a list of objects.

Parameters:

object

List of object. This has the format {type}:{schema}.{object}. The type is database dependent but can as an example be of CONSTRAINT, DATABASE LINK, EXCHANGE INDEX, EXCHANGE TABLE, FUNCTION, INDEX, MATERIALIZED VIEW, MATERIALIZED VIEW LOG, PACKAGE, PACKAGE BODY, PROCEDURE, PROFILE, ROLE, ROLE GRANTS, ROLLBACK SEGMENT, SEQUENCE, SNAPSHOT, SNAPSHOT LOG, SYNONYM, TABLE, TABLE FAMILY, TABLE CONTENTS, TABLE REFERENCES, TABLESPACE, TRIGGER, TRIGGER, TYPE, USER, USER GRANTS for Oracle databases.

Returns: A string containing a script to drop the specified objects.

void drop (QTextStream &stream,std::list<QString> &object)

### drop

Create script to drop a list of objects.

Parameters:

stream | Stream to write result to.

object

List of object. This has the format {type}:{schema}.{object}. The type is database dependent but can as an example be of CONSTRAINT, DATABASE LINK, EXCHANGE INDEX, EXCHANGE TABLE, FUNCTION, INDEX, MATERIALIZED VIEW, MATERIALIZED VIEW LOG, PACKAGE, PACKAGE BODY, PROCEDURE, PROFILE, ROLE, ROLE GRANTS, ROLLBACK SEGMENT, SEQUENCE, SNAPSHOT, SNAPSHOT LOG, SYNONYM, TABLE, TABLE FAMILY, TABLE CONTENTS, TABLE REFERENCES, TABLESPACE, TRIGGER, TRIGGER, TYPE, USER, USER GRANTS for Oracle databases.

Returns: A string containing a script to drop the specified objects.

QString migrate (std::list<QString> &drpLst,std::list<QString> &crtLst)

### migrate

Called to generate a script to migrate a database object from one description to another description.

Parameters:

stream | Stream to write result to.
src | Source description list, generated by describes for the same database.
dst | Destination description list, generated by describes for the same database.

Returns: A script to change the src database object to dst.

void migrate (QTextStream &stream,std::list<QString> &drpLst,std::list<QString> &crtLst)

### migrate

Called to generate a script to migrate a database object from one description to another description.

Parameters:

stream | Stream to write result to.
src | Source description list, generated by describes for the same database.
dst | Destination description list, generated by describes for the same database.

Returns: A script to change the src database object to dst.

void setState (const QCString &name,const QVariant &val)

### setState

Set a context for this extractor.

Parameters:

name | Name of this context
val | Value of this context

QVariant state (const QCString &name)

### state

Get the value of a context for the current extractor.

Parameters:

name | Name of the context to extract.

Returns: The value of the context.

void setSchema (const QString &schema)

### setSchema

Set the schema of the extraction.

Parameters:

schema | Specify the schema of the output script or description. If empty don't specify any object. If the string "1" use same object as input. Otherwise use the specified schema.

void setResize (const QString &resize)

### setResize

Set sizes to use for resize of object on extraction.

Parameters:

A | list of sizes separated by ':'. Should be an even multiple of three where the first value is the largest current size to use these values. The next value is the initial value to use, the last is the next increment value to use. As a special case the string "1" can be used to set up auto resize.

void setPrompt (bool prompt)

### setPrompt

Set inclusion of prompts.

Parameters:

prompt | If prompt generation should be generated.

void setHeading (bool heading)

### setHeading

Include heading in scripts.

Parameters:

heading | Include heading in scripts.

void setConstraints (bool constraints)

### setConstraints

Include constraints in extraction.

Parameters:

constraints | Include constraints.

void setIndexes (bool indexes)

### setIndexes

Include indexes in extraction.

Parameters:

indexes | Include indexes.

void setGrants (bool val)

### setGrants

Include grants in extraction.

Parameters:

val | Include grants.

void setStorage (bool val)

### setStorage

Include storage specification in extraction.

Parameters:

val | Include storage specification.

void setParallel (bool val)

### setParallel

Include parallel specification in extraction.

Parameters:

val | Include parallel specification.

void setPartition (bool val)

### setPartition

Include partition specification in extraction.

Parameters:

val | Include partition specification.

void setContents (bool val,int commitdistance)

### setContents

Include contents of tables in scripts.

Parameters:

val | Include contents of tables.
commitdistance | The commit distance of the contents 0 means whole tables.

void setComments (bool val)

### setComments

Include comments in extraction.

Parameters:

val | Include indexes.

void setCode (bool val)

### setCode

Include code in extraction.

Parameters:

val | Include code.

void setBlockSize (int val)

### setBlockSize

Set blocksize of database.

Parameters:

val | New value of blocksize.

const QString & getSchema (void)

### getSchema

Get schema specification.

Returns: Schema specification.

See also: setSchema

bool getResize (void)

### getResize

Get resize specification.

Returns: Resize specification.

See also: setResize

bool getPrompt (void)

### getPrompt

Check if prompt are generated.

Returns: If prompts are generated.

bool getHeading (void)

### getHeading

Check if headings are generated.

Returns: If headings are generated.

bool getConstraints (void)

### getConstraints

Check if constraints are generated.

Returns: If constraints are generated.

bool getIndexes (void)

### getIndexes

Check if indexes are generated.

Returns: If indexes are generated.

bool getGrants (void)

### getGrants

Check if grants are generated.

Returns: If grants are generated.

bool getStorage (void)

### getStorage

Check if storage specification are generated.

Returns: If storage specification are generated.

bool getParallel (void)

### getParallel

Check if parallell specification are generated.

Returns: If parallell specification are generated.

bool getPartition (void)

### getPartition

Check if partition specification are generated.

Returns: If partition specification are generated.

bool getContents (void)

### getContents

Check if contents of tables are generated.

Returns: If content is generated.

int getCommitDistance (void)

### getCommitDistance

Get the distance of the commits when content is generated.

Returns: Commit distance.

bool getComments (void)

### getComments

Check if comments are generated.

Returns: If comments are generated.

bool getCode (void)

### getCode

Check if code is generated.

Returns: If code is generated.

int getBlockSize (void)

### getBlockSize

Get blocksize.

toConnection & connection ()

### connection

Get the connection this extractor is working on.

void initialNext (const QString &blocks,QString &initial,QString &next)

### initialNext

Fill in the initial and next value for an object currently holding a number of allocated blocks. Uses the resize or default sizes.

Parameters:

blocks | Blocks currently allocated.
initial | New initial value.
next | New next value.

QString intSchema (const QString &owner,bool desc)

### intSchema

Get the schema name specified by the extractor setup. Will include the following '.' if needed.

Parameters:

owner | Owner of object to get schema for.
desc | Used from describe and not to generate script.

Returns: The translated schema.

std::list<datatype> datatypes ()

### datatypes

Get the available datatypes for a database.

Returns: A list of datatypes.

QString createFromParse (std::list<toSQLParse::statement>::iterator start, std::list<toSQLParse::statement>::iterator end)

### createFromParse

Utility function, creates a statement from the start to the end specified by the parameters. The connection used to specify parsing is the one of the extractor.

Parameters:

start | Start of parameters.
end | End of parameters.

Returns: The indented statement.

void srcDst2DropCreate (std::list<QString> &source,std::list<QString> &destination, std::list<QString> &drop,std::list<QString> &creat)

### srcDst2DropCreate

[static]

Create a source and destination object list to two other lists containing dropped and created objects or attributes.

Parameters:

source | Source list input (Will not be modified).
destination | Destination list input (Will not be modified).
drop | Drop list output (Will be overwritten).
create | Create list output (Will be overwritten).

bool canHandle (toConnection &conn)

### canHandle

[static]

Check if a database is supported at all by the extractor.

Parameters:

conn | Connection to check for support.

Returns: True if the database is supported.

void addDescription (std::list<QString> &ret,const std::list<QString> &ctx, const QString &arg1=QString::null,const QString &arg2=QString::null, const QString &arg3=QString::null,const QString &arg4=QString::null, const QString &arg5=QString::null,const QString &arg6=QString::null, const QString &arg7=QString::null,const QString &arg8=QString::null, const QString &arg9=QString::null)

### addDescription

[static]

Add a list to description.

Parameters:

ret | The return list to add a line to.
ctx | The current description context.
arg1 | First extra argument to add.

std::list<QString> splitDescribe (const QString &str)

### splitDescribe

[static]

Split a description line into its components.

Parameters:

str | The description line to split.

Returns: The list of components.

QString partDescribe (const QString &str,int level)

### partDescribe

[static]

Get the part of a description indicated by the level

Parameters:

str | Description string
level | The level to get (0 is the first level)

QString contextDescribe (const QString &str,int level)

### contextDescribe

[static]

Get the context of a given level.

Parameters:

str | Description string
level | The level to get the context for (1 is the first to not return empty string.

Returns: The context, if not enough parts are available null is returned.

columnInfo (struct)

### columnInfo

Used to get column information from a describe list

std::list<columnInfo> parseColumnDescription (std::list<QString>::const_iterator begin, std::list<QString>::const_iterator end, int level=3)

### parseColumnDescription

[static]

Parse a column description and return a sorted list of column data.

Parameters:

begin | The iterator indicating the beginning to start searching from (Inclusive).
end | The iterator indicating the end to end searching at (Not inclusive).
level | Number of levels of context to discard before looking for "COLUMN" definition.

Returns: The list of column definitions. Sorted by column order.

std::list<columnInfo> parseColumnDescription (const std::list<QString> &description,int level=3)

### parseColumnDescription

[static]

Parse a column description and return a sorted list of column data.

Parameters:

description | A description list. Will go through entire list.
level | Number of levels of context to discard before looking for "COLUMN" definition.

Returns: The list of column definitions. Sorted by column order.

friend class extractor

### extractor

Generated by: nneul on skyhawk on Wed Feb 23 19:49:58 2005, using kdoc 2.0a54.