📄 database.cpp
字号:
#include "file.h"
void show_welcome()
{
cout<<"*************************************************\n";
cout<<"* Tiny In-Men DataBase\n";
cout<<"* Copyright reserved.\n";
cout<<"*************************************************\n";
}
void show_bye()
{
cout<<"bye\n";
system("pause");
exit(0);
}
void show_help()
{
cout<<"help:\n";
//cout<<"DB=>";
}
int main()
{
show_welcome();
SQL.clear();
while(1)
{
cout<<"DB=>";
string cmd;
getline(cin,cmd,'\n');
istringstream explain(cmd);
string temp_cmd;
explain>>temp_cmd;
if(temp_cmd=="-h")
{
show_help();
}
else if(temp_cmd=="-q")
{
show_bye();
break;
}
else if(temp_cmd=="-c")
{
explain>>temp_cmd;
int return_code = create_table(temp_cmd.c_str());
if(return_code==0)
{
cout<<"please check whether the path and the file is right!!!\n";
//continue;
}
else if (return_code==1)
{
cout<<"the format of the content in the create file is not right,please check it\n";
//continue;
}
else
{
cout<<"Create the table completed\n";
//continue;
}
}
else if(temp_cmd=="-i")
{
string table_name;
string data_path;
explain>>table_name>>data_path;
int return_code = establish(table_name,data_path.c_str());
if(-1==return_code)
{
cout<<"please check the table name and the file path and try it again!!!\n";
//continue;
}
else if(-2==return_code)
{
cout<<"please check the file path and try it again!!!\n";
//continue;
}
else
{
cout<<"Import the data completed!!!\n";
cout<<return_code<<" records imported successfully!!!\n";
//continue;
}
}
else if(temp_cmd=="-s")
{
explain>>temp_cmd;
select(temp_cmd.c_str());
}
else if(temp_cmd=="-u")
{
explain>>temp_cmd;
update(temp_cmd.c_str());
}
else if(temp_cmd=="-d")
{
explain>>temp_cmd;
int return_code = delete_data(temp_cmd.c_str());
if (return_code==0)
{
cerr<<"please check the file name and the file path and try it again!!!\n";
//continue;
}
else if (return_code==1)
{
cerr<<"the content in the file is not right,please check it\n";
//continue;
}
else
{
cout<<"delete successfully\n";
//continue;
}
}
else if(temp_cmd=="-index")
{
int index_num = 0;
explain>>index_num;
cout<<index_num;
}
else
{
cout<<"wrong input you may type: -h to get more help\n";
//continue;
}
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -