本文整理汇总了C++中Database::GetTableVector方法的典型用法代码示例。如果您正苦于以下问题:C++ Database::GetTableVector方法的具体用法?C++ Database::GetTableVector怎么用?C++ Database::GetTableVector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database::GetTableVector方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTablesForView
//std::vector<Table> &DrawingView::GetTablesForView(Database *db)
void TableView::GetTablesForView(Database *db)
{
std::vector<wxString> tables;
wxDynamicLibrary lib;
#ifdef __WXMSW__
lib.Load( "dialogs" );
#elif __WXMAC__
lib.Load( "liblibdialogs.dylib" );
#else
lib.Load( "libdialogs" );
#endif
if( lib.IsLoaded() )
{
TABLESELECTION func = (TABLESELECTION) lib.GetSymbol( "SelectTablesForView" );
int res = func( m_frame, db, tables, GetDocument()->GetTableNames(), true );
if( res != wxID_CANCEL )
{
bool found = false;
Database *db = ((TableDocument *) GetDocument())->GetDatabase();
std::map<std::wstring, std::vector<DatabaseTable *> > tbls = db->GetTableVector().m_tables;
std::vector<DatabaseTable *> tableVec = tbls.at( db->GetTableVector().m_dbName );
for( std::vector<DatabaseTable *>::iterator it = tableVec.begin(); it < tableVec.end() && !found; it++ )
{
if( (*it)->GetTableName() == tables.at( 0 ).ToStdWstring() )
{
m_table = (*it);
found = true;
}
}
((TableDocument *) GetDocument())->AddTables( tables );
}
}
// return tables;
}
示例2: OnDropTable
//.........这里部分代码省略.........
constraint = sign->GetConstraint();
constraint->GetLocalColumns( localColumns );
constraint->GetRefColumns( refColumn );
match = constraint->GetPGMatch();
}
int eventId = event.GetId();
if( eventId == wxID_DROPOBJECT )
{
wxString message = _( "You are about to delete " );
if( isTable )
message += _( "table " ) + name + _( ". Are you sure?" );
else
{
message += _( "foreign key " );
wxString fkName = constraint->GetName();
if( !fkName.empty() )
message += fkName;
else
message += _( " on " ) + const_cast<DatabaseTable *>( constraint->GetFKTable() )->GetTableName() + _( " references " ) + constraint->GetRefTable() + _( ". Are you sure?" );
}
answer = wxMessageBox( message, _( "Database" ), wxYES_NO | wxNO_DEFAULT );
}
else
answer = wxYES;
if( answer == wxYES )
{
if( isTable && ( ( eventId == wxID_DROPOBJECT && !db->DeleteTable( name.ToStdWstring(), errors ) ) || eventId != wxID_DROPOBJECT ) )
{
if( m_realSelectedShape == m_selectedShape )
{
m_realSelectedShape = NULL;
ShapeList listShapes;
m_pManager.GetShapes( CLASSINFO( MyErdTable ), listShapes );
int size = listShapes.size();
if( listShapes.size() == 1 )
m_realSelectedShape = NULL;
else
{
MyErdTable *tableToRemove = (MyErdTable *) ( listShapes.Item( size - 1 )->GetData() );
if( tableToRemove == erdTable )
m_realSelectedShape = (MyErdTable *) ( listShapes.Item( size - 2 )->GetData() );
else
{
bool found = false;
int i;
for( i = 0; i < size - 1 || !found; i++ )
if( listShapes.Item( i )->GetData() == erdTable )
found = true;
m_realSelectedShape = listShapes.Item( i + 1 )->GetData();
}
}
}
m_pManager.RemoveShape( erdTable );
/* for( ShapeList::iterator it = listShapes.begin(); it != listShapes.end() || !nextShapeFound; ++it )
{
CommentFieldShape *shape = wxDynamicCast( (*it), CommentFieldShape );
if( m_showComments )
{
shape->SetText( const_cast<Field *>( shape->GetFieldForComment() )->GetComment() );
}
else
{
shape->SetText( wxEmptyString );
}
}*/
std::map<std::wstring, std::vector<DatabaseTable *> > tables = db->GetTableVector().m_tables;
std::vector<DatabaseTable *> tableVec = tables.at( db->GetTableVector().m_dbName );
std::vector<std::wstring> &names = doc->GetTableNameVector();
if( event.GetId() == wxID_DROPOBJECT )
{
tableVec.erase( std::remove( tableVec.begin(), tableVec.end(), table ), tableVec.end() );
}
else
names.erase( std::remove( names.begin(), names.end(), table->GetTableName() ), names.end() );
/* if( m_realSelectedShape == m_selectedShape )
{
}
else
{*/
if( m_realSelectedShape )
m_realSelectedShape->Select( true );
// }
}
else if( !isTable && !db->ApplyForeignKey( command, constraint->GetName().ToStdWstring(), *( const_cast<DatabaseTable *>( constraint->GetFKTable() ) ), localColumns, constraint->GetRefTable().ToStdWstring(), refColumn, constraint->GetOnDelete(), constraint->GetOnUpdate(), false, newFK, false, match, errors ) )
{
sign->DeleteConstraint();
m_pManager.RemoveShape( sign->GetParentShape() );
Refresh();
}
else
{
for( std::vector<std::wstring>::iterator it = errors.begin(); it < errors.end(); it++ )
{
wxMessageBox( (*it) );
}
}
}
Refresh();
}