示例#1
0
void API::ShowTables()
{
	if (current_db_.size() == 0) throw NoDatabaseSelectedException();
	Database *db = catalog_m_->GetDB(current_db_);
	if (db == NULL) throw DatabaseNotExistException();
	if (db->GetTables().size() == 0)
	{
		cout << "No table exist now." << endl;
		cout << "Use 'create table' command to create a new table." << endl;
		return;
	}
	cout << setiosflags(ios::left) << endl;
	cout << "+------------------------+" << endl;
	cout << "| " << setw(22) << "Tables_in_"+ current_db_ << " |" << endl;
	cout << "+------------------------+" << endl;
	for (auto tb = db->GetTables().begin(); tb != db->GetTables().end(); tb++)
		cout << "| " << setw(22) << (*tb).get_tb_name() << " |" << endl;
	cout << "+------------------------+" << endl;
}