本文整理汇总了C++中Table::GetIndexNum方法的典型用法代码示例。如果您正苦于以下问题:C++ Table::GetIndexNum方法的具体用法?C++ Table::GetIndexNum怎么用?C++ Table::GetIndexNum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Table
的用法示例。
在下文中一共展示了Table::GetIndexNum方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DropTable
/*删除数据表*/
void API::DropTable(SQLDropTable& sql_statement)
{
cout << "Droping table: " << sql_statement.get_table_name() << endl;
if (current_database_.length() == 0)/*判断当前数据库是否选定*/
{
throw NoDatabaseSelectedException();
}
Database *db = catalog_manager_->GetDB(current_database_);
if (db == NULL)/*判断该当前数据库是否存在*/
{
throw DatabaseNotExistException();
}
Table *tb = db->GetTable(sql_statement.get_table_name());
if (tb == NULL)/*判断该数据库是否存在数据表*/
{
throw TableNotExistException();
}
string file_name(path_ + current_database_ + "/" + sql_statement.get_table_name() + ".records");/*获取该数据表的文件地址*/
if (!boost::filesystem::exists(file_name))/*【file system】利用boost库判断该文件是否存在*/
{
cout << sql_statement.get_table_name() +" 数据表文件不存在。" << endl;
}
else
{
boost::filesystem::remove(file_name);/*【file system】利用boost库删除该文件*/
cout << sql_statement.get_table_name() + "数据表文件已删除。" << endl;
}
cout << "删除数据表下索引文件。" << endl;
for (unsigned int i = 0; i < tb->GetIndexNum(); i++)
{
string file_name(path_ + current_database_ + "/" + tb->GetIndex(i)->get_name() + ".index");/*获取该数据表的文件地址*/
if (!boost::filesystem::exists(file_name))/*【file system】利用boost库判断该文件是否存在*/
{
cout << "索引文件不存在。" << endl;
}
else
{
boost::filesystem::remove(file_name);
cout << "索引文件已删除" << endl;
}
}
db->DropTable(sql_statement);/*【catalog manager】在目录中删除该数据表*/
cout << "目录文件已写入。" << endl;
catalog_manager_->WriteArchiveFile();/*【catalog manager】在catalog中写文档*/
//cout << "删除数据表。" << endl;
}
示例2: DropTable
void API::DropTable(SQLDropTable& statement)
{
cout << "Droping table: " << statement.get_tb_name() << endl;
if (current_db_.length() == 0) throw NoDatabaseSelectedException();
Database *db = catalog_m_->GetDB(current_db_);
if (db == NULL) throw DatabaseNotExistException();
Table *tb = db->GetTable(statement.get_tb_name());
if (tb == NULL) throw TableNotExistException();
string file_name(path_ + current_db_ + "/" + statement.get_tb_name() + ".records");
if (!boost::filesystem::exists(file_name)) cout << "Table file doesn't exists!" << endl;
else
{
boost::filesystem::remove(file_name);
cout << "Table file deleted!" << endl;
}
cout << "Removing Index files!" << endl;
for (unsigned int i = 0; i < tb->GetIndexNum(); i++)
{
string file_name(path_ + current_db_ + "/" + tb->GetIndex(i)->get_name() + ".index");
if (!boost::filesystem::exists(file_name)) cout << "Index file doesn't exist!" << endl;
else
{
boost::filesystem::remove(file_name);
cout << "Index file removed!" << endl;
}
}
db->DropTable(statement);
cout << "Catalog written!" << endl;
catalog_m_->WriteArchiveFile();
}