解释C++语言

来源:百度知道 编辑:UC知道 时间:2024/09/22 12:33:04
#include "cli.h"

void Cli::show_prompt(){
cout<<"sql> ";
}

void Cli::show_continue(){
cout<<" -> ";
}

void Cli::start(){
string sql="";
Db db;
StmType stm_type;
cout<<"Simple DB"<<endl;
cout<<"press Ctrl + C to exit"<<endl;
while(1){
show_prompt();
sql=read_query();
if(sql=="\\q")
return;
try{
stm_type=db.query(sql);
if(stm_type==STM_SELECT)
show_record_set(db.get_record_set());
}catch(string e){
cout<<e<<endl;
}
}
}

string Cli::read_query(){
string sql="";
string snippet;
char last_char=' ';
getline(

#include "cli.h" //引用

void Cli::show_prompt(){
cout<<"sql> "; //输出提示
}

void Cli::show_continue(){
cout<<" -> "; //输出->
}

void Cli::start(){
string sql=""; //定义SQL
Db db; //定义数年据库
StmType stm_type;
cout<<"Simple DB"<<endl;
cout<<"press Ctrl + C to exit"<<endl;
while(1){
show_prompt();
sql=read_query();
if(sql=="\\q")
return;
try{
stm_type=db.query(sql);
if(stm_type==STM_SELECT)
show_record_set(db.get_record_set());
}catch(string e){
cout<<e<<endl;
}
}
}

string Cli::read_query(){
string sql="";
string snippet;
char last_char=' ';
getline(cin,snippet);
while(last_char!=';'){
last_char=snippet[snippet.size()-1