kexi

#include <tableschema.h>

Inheritance diagram for KexiDB::TableSchema:
KexiDB::FieldList KexiDB::SchemaData KexiDB::InternalTableSchema

Public Types

typedef TQPtrList< TableSchema > List
typedef TQPtrListIterator< TableSchema > ListIterator

Public Member Functions

 TableSchema (const TQString &name)
 TableSchema (const SchemaData &sdata)
 TableSchema (const TableSchema &ts, bool copyId=true)
 TableSchema (const TableSchema &ts, int setId)
virtual FieldList & insertField (uint index, Field *field)
virtual void removeField (KexiDB::Field *field)
IndexSchema * primaryKey () const
void setPrimaryKey (IndexSchema *pkey)
const IndexSchema::ListIterator indicesIterator () const
const IndexSchema::List * indices ()
virtual void clear ()
TQString debugString (bool includeTableName)
virtual TQString debugString ()
Connection * connection () const
bool isKexiDBSystem () const
void setKexiDBSystem (bool set)
virtual bool isNative () const
virtual void setNative (bool set)
QuerySchema * query ()
Field * anyNonPKField ()
bool setLookupFieldSchema (const TQString &fieldName, LookupFieldSchema *lookupFieldSchema)
LookupFieldSchema * lookupFieldSchema (const Field &field) const
LookupFieldSchema * lookupFieldSchema (const TQString &fieldName)
const TQPtrVector< LookupFieldSchema > & lookupFieldsList ()
Public Member Functions inherited from KexiDB::FieldList
 FieldList (bool owner=false)
 FieldList (const FieldList &fl, bool deepCopyFields=true)
virtual ~FieldList ()
uint fieldCount () const
FieldList & addField (Field *field)
Field * field (uint id)
virtual Field * field (const TQString &name)
bool hasField (const Field *field)
int indexOf (const Field *field)
TQStringList names () const
Field::ListIterator fieldsIterator () const
Field::List * fields ()
Field::List * autoIncrementFields ()
bool isOwner () const
void debug ()
FieldList * subList (const TQString &n1, const TQString &n2=TQString(), const TQString &n3=TQString(), const TQString &n4=TQString(), const TQString &n5=TQString(), const TQString &n6=TQString(), const TQString &n7=TQString(), const TQString &n8=TQString(), const TQString &n9=TQString(), const TQString &n10=TQString(), const TQString &n11=TQString(), const TQString &n12=TQString(), const TQString &n13=TQString(), const TQString &n14=TQString(), const TQString &n15=TQString(), const TQString &n16=TQString(), const TQString &n17=TQString(), const TQString &n18=TQString())
FieldList * subList (const TQStringList &list)
FieldList * subList (const TQValueList< uint > &list)
TQString sqlFieldsList (Driver *driver, const TQString &separator=TQString::fromLatin1(","), const TQString &tableAlias=TQString(), int drvEscaping=Driver::EscapeDriver|Driver::EscapeAsNecessary)
void renameField (const TQString &oldName, const TQString &newName)
void renameField (KexiDB::Field *field, const TQString &newName)
Public Member Functions inherited from KexiDB::SchemaData
 SchemaData (int obj_type=KexiDB::UnknownObjectType)
int type () const
int id () const
TQString name () const
TQString objectName () const
void setName (const TQString &n)
TQString caption () const
void setCaption (const TQString &c)
TQString description () const
void setDescription (const TQString &desc)
virtual TQString schemaDataDebugString () const

Protected Member Functions

 TableSchema (Connection *conn, const TQString &name=TQString())
Protected Member Functions inherited from KexiDB::SchemaData
void clear ()

Protected Attributes

IndexSchema::List m_indices
TQGuardedPtr< Connection > m_conn
IndexSchema * m_pkey
QuerySchema * m_query
Private * d
Protected Attributes inherited from KexiDB::FieldList
Field::List m_fields
TQDict< Field > m_fields_by_name
Field::List * m_autoinc_fields
Protected Attributes inherited from KexiDB::SchemaData
int m_type
int m_id
TQString m_name
TQString m_caption
TQString m_desc
bool m_native: 1

Friends

class Connection

Additional Inherited Members

Static Public Member Functions inherited from KexiDB::FieldList
static TQString sqlFieldsList (Field::List *list, Driver *driver, const TQString &separator=TQString::fromLatin1(","), const TQString &tableAlias=TQString(), int drvEscaping=Driver::EscapeDriver|Driver::EscapeAsNecessary)

Detailed Description

KexiDB::TableSchema provides information about native database table that can be stored using KexiDB database engine.

Definition at line 42 of file tableschema.h.

Member Typedef Documentation

◆ List

typedef TQPtrList<TableSchema> KexiDB::TableSchema::List

Type of tables list.

Definition at line 45 of file tableschema.h.

◆ ListIterator

typedef TQPtrListIterator<TableSchema> KexiDB::TableSchema::ListIterator

Iterator for tables list.

Definition at line 46 of file tableschema.h.

Constructor & Destructor Documentation

◆ TableSchema() [1/6]

TableSchema::TableSchema ( const TQString & name)

Definition at line 64 of file tableschema.cpp.

◆ TableSchema() [2/6]

TableSchema::TableSchema ( const SchemaData & sdata)

Definition at line 74 of file tableschema.cpp.

◆ TableSchema() [3/6]

TableSchema::TableSchema ( )

Definition at line 83 of file tableschema.cpp.

◆ TableSchema() [4/6]

TableSchema::TableSchema ( const TableSchema & ts,
bool copyId = true )

Copy constructor. if copyId is true, it's copied as well, otherwise the table id becomes -1, what is usable when we want to store the copy as an independent table.

Definition at line 92 of file tableschema.cpp.

◆ TableSchema() [5/6]

TableSchema::TableSchema ( const TableSchema & ts,
int setId )

Copy constructor like TableSchema(const TableSchema&, bool). setId is set as the table identifier. This is rarely usable, e.g. in project and data migration routines when we need to need deal with unique identifiers;

See also
KexiMigrate::performImport().

Definition at line 99 of file tableschema.cpp.

◆ ~TableSchema()

TableSchema::~TableSchema ( )
virtual

Definition at line 123 of file tableschema.cpp.

◆ TableSchema() [6/6]

TableSchema::TableSchema ( Connection * conn,
const TQString & name = TQString() )
protected

Automatically retrieves table schema via connection.

Definition at line 108 of file tableschema.cpp.

Member Function Documentation

◆ anyNonPKField()

Field * TableSchema::anyNonPKField ( )
Returns
any field not being a part of primary key of this table. If there is no such field, returns 0.

Definition at line 372 of file tableschema.cpp.

◆ clear()

void TableSchema::clear ( )
virtual

Removes all fields from the list, clears name and all other properties.

See also
FieldList::clear()

Reimplemented from KexiDB::FieldList.

Definition at line 271 of file tableschema.cpp.

◆ connection()

Connection * KexiDB::TableSchema::connection ( ) const
inline
Returns
connection object if table was created/retrieved using a connection, otherwise 0.

Definition at line 109 of file tableschema.h.

◆ debugString() [1/2]

TQString TableSchema::debugString ( )
virtual
Returns
String for debugging purposes. Equal to debugString(true).

Reimplemented from KexiDB::FieldList.

Definition at line 326 of file tableschema.cpp.

◆ debugString() [2/2]

TQString TableSchema::debugString ( bool includeTableName)
Returns
String for debugging purposes, if includeTableName is true, table name, caption, etc. is prepended, else only debug string for the fields are returned.

Definition at line 331 of file tableschema.cpp.

◆ indices()

const IndexSchema::List * KexiDB::TableSchema::indices ( )
inline

Definition at line 93 of file tableschema.h.

◆ indicesIterator()

const IndexSchema::ListIterator KexiDB::TableSchema::indicesIterator ( ) const
inline

Definition at line 90 of file tableschema.h.

◆ insertField()

FieldList & TableSchema::insertField ( uint index,
Field * field )
virtual

Inserts field into a specified position (index). 'order' property of field is set automatically.

Reimplemented from KexiDB::FieldList.

Definition at line 184 of file tableschema.cpp.

◆ isKexiDBSystem()

bool KexiDB::TableSchema::isKexiDBSystem ( ) const
inline
Returns
true if this is KexiDB storage system's table (used internally by KexiDB). This helps in hiding such tables in applications (if desired) and will also enable lookup of system tables for schema export/import functionality.

Any internal KexiDB system table's schema (kexi__*) has cleared its SchemaData part, e.g. id=-1 for such table, and no description, caption and so on. This is because it represents a native database table rather that extended Kexi table.

isKexiDBSystem()==true implies isNative()==true.

By default (after allocation), TableSchema object has this property set to false.

Definition at line 125 of file tableschema.h.

◆ isNative()

virtual bool KexiDB::TableSchema::isNative ( ) const
inlinevirtual
Returns
true if this is schema of native database object, When this is kexiDBSystem table, native flag is forced to be on.

Reimplemented from KexiDB::SchemaData.

Definition at line 134 of file tableschema.h.

◆ lookupFieldSchema() [1/2]

LookupFieldSchema * TableSchema::lookupFieldSchema ( const Field & field) const
Returns
lookup field schema for field. 0 is returned if there is no such field in the table or this field has no lookup schema. Note that even id non-zero is returned here, you may want to check whether lookup field's rowSource().name() is empty (if so, the field should behave as there was no lookup field defined at all).

Definition at line 405 of file tableschema.cpp.

◆ lookupFieldSchema() [2/2]

LookupFieldSchema * TableSchema::lookupFieldSchema ( const TQString & fieldName)

Definition at line 410 of file tableschema.cpp.

◆ lookupFieldsList()

const TQPtrVector< LookupFieldSchema > & TableSchema::lookupFieldsList ( )
Returns
list of lookup field schemas for this table. The order is the same as the order of fields within the table.

Definition at line 418 of file tableschema.cpp.

◆ primaryKey()

IndexSchema * KexiDB::TableSchema::primaryKey ( ) const
inline
Returns
list of fields that are primary key of this table. This method never returns 0 value, if there is no primary key, empty IndexSchema object is returned. IndexSchema object is owned by the table schema.

Definition at line 76 of file tableschema.h.

◆ query()

QuerySchema * TableSchema::query ( )
Returns
query schema object that is defined by "select * from <this_table_name>" This query schema object is owned by the table schema object. It is convenient way to get such a query when it is not available otherwise. Always returns non-0.

Definition at line 364 of file tableschema.cpp.

◆ removeField()

void TableSchema::removeField ( KexiDB::Field * field)
virtual

Reimplemented for internal reasons.

Reimplemented from KexiDB::FieldList.

Definition at line 225 of file tableschema.cpp.

◆ setKexiDBSystem()

void TableSchema::setKexiDBSystem ( bool set)

Sets KexiDBSystem flag to on or off. When on, native flag is forced to be on. When off, native flag is not affected.

See also
isKexiDBSystem()

Definition at line 347 of file tableschema.cpp.

◆ setLookupFieldSchema()

bool TableSchema::setLookupFieldSchema ( const TQString & fieldName,
LookupFieldSchema * lookupFieldSchema )

Sets lookup field schema lookupFieldSchema for fieldName. Passing null lookupFieldSchema will remove the previously set lookup field.

Returns
true if lookupFieldSchema has been added, or false if there is no such field fieldName.

Definition at line 387 of file tableschema.cpp.

◆ setNative()

void TableSchema::setNative ( bool set)
virtual

Reimplemented from KexiDB::SchemaData.

Definition at line 354 of file tableschema.cpp.

◆ setPrimaryKey()

void TableSchema::setPrimaryKey ( IndexSchema * pkey)

Sets table's primary key index to pkey. Pass pkey==0 if you want to unassign existing primary key ("primary" property of given IndexSchema object will be cleared then so this index becomes ordinary index, still existing on table indeices list).

If this table already has primary key assigned, it is unassigned using setPrimaryKey(0) call.

Before assigning as primary key, you should add the index to indices list with addIndex() (this is not done automatically!).

Definition at line 163 of file tableschema.cpp.

◆ Connection

friend class Connection
friend

Definition at line 193 of file tableschema.h.

Member Data Documentation

◆ d

Private* KexiDB::TableSchema::d
protected

Definition at line 182 of file tableschema.h.

◆ m_conn

TQGuardedPtr<Connection> KexiDB::TableSchema::m_conn
protected

Definition at line 175 of file tableschema.h.

◆ m_indices

IndexSchema::List KexiDB::TableSchema::m_indices
protected

Definition at line 173 of file tableschema.h.

◆ m_pkey

IndexSchema* KexiDB::TableSchema::m_pkey
protected

Definition at line 177 of file tableschema.h.

◆ m_query

QuerySchema* KexiDB::TableSchema::m_query
protected

cached query schema that is defined by "select * from <this_table_name>"

Definition at line 179 of file tableschema.h.


The documentation for this class was generated from the following files: