⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 load_dictionary.cpp

📁 小型数据库源代码较多
💻 CPP
字号:

#include "min.h"

void sql::Load_Dictionary()
{
	fstream dir_file;		
	dir_file.open( "dir_file.dtb",ios::in );
	if( !dir_file )
		throw 1;
	else
	{
		dir_file.read( buf[0] , sbf );
		dir_file.close();
	}
 
	istrstream in( buf[0], sbf );
	cout << "当前数据库里的数据:";
	tablehead = new Table;
	if ( !tablehead )
		throw 1;
	if( buf[0][0] == '\0')
	{
		cout << "当前数据库不存在任何数据" << endl;
		tablehead->next = NULL;
	}
	else
	{
		cout << endl << setw(15 ) << "tablename"
			<< setw(12) << "tuple" << setw(12) << "columnlist" << endl;
		Table* table;
		Col* col;	
		table = tablehead;//牺牲一个Table 可以节约很多时间;
		for( ; ; )
		{	
			string tablename;
			in >> tablename ;

			if (  tablename.at(0) =='&' )
				break;
			table->next = new Table;		
			table = table->next;
			table->name = tablename;
			in >> table->num >> table->col;
			cout << setw(12) << table->name
				<< setw(12) << table->num;
	            		
			table->collist = new Col;
			col = table->collist;
			for( int j = 0; j < table->col ; j++ )
			{
				cout << '\t';
				col->next = new Col;
				col = col->next;
				in >> col->name >> col->type 
					>> col->att >> col->len ;
				in >> col->indexname;
				if( !col->indexname.compare(","))
					col->indexname.erase();
				else
				{
					char comma;
					in >> comma;
				}
				cout << col->name;
			}
			cout << endl;		
			col->next = NULL;
		}
		table->next = NULL;		
	}
	for( int j = 0; j < sbf ; j++)
		buf[0][j] = '\0';
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -