Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
673 lines (650 loc) · 20 KB
/
Copy pathmain.cpp
File metadata and controls
673 lines (650 loc) · 20 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
#include <iostream>
#include <string>
#include <map>
#include <cctype>
#include <vector>
#include "database.h"
using namespace std;
string data_keep_filename="data_keep.txt";
void read_data(map<string,Database*>& database,vector<string>& all_database){
fstream fin;
fin.open(data_keep_filename,ios::in);
if(!fin.is_open()) return;
string x;
Database* now_database;
Table* now_table;
while(getline(fin,x)){
auto t=cut(x);
if(t[0]=="database:"){
database[t[1]]=new Database(t[1]);
now_database=database[t[1]];
all_database.push_back(t[1]);
}
else if(t[0]=="table:"){
string tablename=t[1],prime_key=t[2];
now_database->create(tablename,prime_key);
now_table=(*now_database)[tablename];
}
else if(t[0]=="column:"){
for(int i=1;i<t.size();i+=3){
bool q;
if(t[i+2]=="1") q=true;
else q=false;
if(t[i+1][0]=='i') t[i+1]="INT";
else if(t[i+1][0]=='c') t[i+1]="CHAR";
now_table->create(t[i],t[i+1],q);
}
}
else if(t[0]=="data:"){
for(int i=1;i<t.size();++i){
(*now_table)[i-1]->insert(t[i]);
}
}
/*else if(t[0]=="nowdatabase:"){
now_database=database[t[1]];
}*/
}
fin.close();
}
void print_result(vector<vector<string>>& result){
if(result.size()<2) return;
for(int i=0;i<result[0].size();++i){
cout<<result[0][i]<<'\t';
}
cout<<endl;
for(int i=1;i<result.size();++i){
for(int j=0;j<result[i].size()-1;++j){
cout<<result[i][j]<<'\t';
}
cout<<endl;
}
}
void print_result_norows(vector<vector<string>>& result){
if(result.size()<2) return;
for(int i=0;i<result[0].size();++i){
cout<<result[0][i]<<'\t';
}
cout<<endl;
for(int i=1;i<result.size();++i){
for(int j=0;j<result[i].size();++j){
cout<<result[i][j]<<'\t';
}
cout<<endl;
}
}
int main() {
string todo; Database* now = NULL; //now表示现在正在使用的数据库,便于切换操作
map<string,Database*> database; //从数据库名映射至相应的数据库指针
vector<string>all_database;
//便于测试,先不从存档中读入数据
//read_data(database,all_database);
//使用该函数即可完成存档数据的读取(数据默认保存在"data_keep.txt"中,可以通过修改data_keep_filename的值来修改储存数据的文件名)
while(getline(cin,todo,';')) {
if (todo=="") continue;
getchar();
if (todo[todo.length()-1]==' ') todo.erase(todo.end()-1); //删除行末空格
todo.push_back(';');//适应之前的代码
if (str_com(todo.substr(0,8).c_str(),"CREATE D")) { //创建数据库
string dname = todo.substr(16,todo.length()-17); //截取数据库名dname,下同
database[dname] = new Database(dname);
all_database.push_back(dname);
}
else if (str_com(todo.substr(0,6),"DROP D")) { //删除数据库
string dname = todo.substr(14,todo.length()-15);
if (database.find(dname)==database.end()) { //讨论待删除的数据库不存在的情况
cout << "Database Not Found!\n";
continue;
}
int i;
for(i=0;i<all_database.size();++i){
if(all_database[i]==dname){
//all_database.erase(all_database.begin()+i);
all_database.erase(all_database.begin()+i);
break;
}
}
delete database[dname]; //释放内存
database.erase(dname);
}
else if (str_com(todo.substr(0,4),"USE ")) { //利用now指针切换数据库
string dname = todo.substr(4,todo.length()-5);
if (database.find(dname)==database.end()) {
cout << "Database Not Found!\n";
continue;
}
now = database[dname];
}
else if (str_com(todo.substr(0,6),"SHOW D")) { //打印现有数据库名
if (!database.empty()) { //没有数据库则不输出
cout << "Database\n";
for (auto t=database.begin();t!=database.end();t++) {
cout << (t->second->getname()) << endl;
}
}
}
else if (str_com(todo.substr(0,8),"CREATE T")) { //创建表格
int p = todo.find("(",13);
string tname = todo.substr(13,p-13); //截取表格名tname,下同
int q = todo.find("PRIMARY KEY",p); //寻找主键
if (q==-1) q = todo.find("primary key",p);
int s = todo.find(")",q);
string prime = todo.substr(q+12,s-q-12); //截取主键名
now->create(tname,prime); //调用成员函数建表
if (todo[s+1]==')') { //将定义主键的子串移除
if (todo[q-1]==' ') q-=2; else q--; s++;
todo.erase(todo.begin()+q,todo.begin()+s);
}
else {
if (todo[q-1]==' ') q--; s+=2;
todo.erase(todo.begin()+q,todo.begin()+s);
}
p++; bool n;
while (true) {
s = todo.find(" ",p);
string cname = todo.substr(p,s-p); //截取表头变量名cname,下同
int t = todo.find(" ",s+1);
int w = todo.find(",",s+1);
if (w==-1) w = todo.find(")",s+1);
n = true; string type;
if (t>w||t==-1) { //判断该表头变量是否not null,用布尔值n表示
type = todo.substr(s+1,w-s-1);
(*now)[tname]->create(cname,type,n); //创建表格的一列
}
else {
n = false;
type = todo.substr(s+1,t-s-1);
(*now)[tname]->create(cname,type,n);
}
p = todo.find(",",p); //继续建立下一列
if (p==-1) break;
if (todo[p+1]==' ') p += 2;
else p++;
}
}
else if (str_com(todo.substr(0,6),"DROP T")) { //删除表格
string tname = todo.substr(11,todo.length()-12);
if (!(now->find_table(tname))) { //讨论表格不存在的情况
cout << "Table Not Found!\n";
continue;
}
now->del(tname);
}
else if (str_com(todo.substr(0,6),"SHOW T")) { //展示现有数据库的表格
now->show();
}
else if (str_com(todo.substr(0,6),"SHOW c")) { //展示建表信息
string tname = todo.substr(18,todo.length()-19);
if (!(now->find_table(tname))) {
cout << "Table Not Found!\n";
continue;
}
(*now)[tname]->show_column();
}
else if (str_com(todo.substr(0,8),"INSERT I")) { //在表格中插入数据
int p = todo.find("(",0);
string tname = todo.substr(12,p-12);
if (!(now->find_table(tname))) {
cout << "Table Not Found!\n";
continue;
}
p++; int q = todo.find("(",p); q++; //用两套指针,分别截取表头变量名cname和其数值value
int pt = todo.find(")",p); int qt = todo.find(")",q);
int pp = todo.find(",",p); int qq = todo.find(",",q);
string cname,value; string to_check = todo.substr(p,pt-p); //to_check为tname(...)括号中的内容
if ((*now)[tname]->null_check(to_check)) { //检查是否有not null变量没有赋值,有则报错
cout << "Wrong Insert! Some Not Null field is not filled!\n";
continue;
}
while ((pp<pt)&&(qq<qt)&&(pp!=-1)&&(qq!=-1)) {
cname = todo.substr(p,pp-p);
value = todo.substr(q,qq-q);
if ((*now)[tname]->find_column(cname)) (*((*now)[tname]))[cname]->insert(value);
else cout << "Column " << cname << " Is Not Found! Filled As Default!\n"; //讨论所指示的表头变量名不存在的情况,此时它将用缺省值填充
if (todo[pp+1]==' ') p=pp+2; else p=pp+1;
if (todo[qq+1]==' ') q=qq+2; else q=qq+1;
pp = todo.find(",",p); qq = todo.find(",",q);
}
cname = todo.substr(p,pt-p);
value = todo.substr(q,qt-q);
if ((*now)[tname]->find_column(cname)) (*((*now)[tname]))[cname]->insert(value);
else cout << "Column " << cname << " Is Not Found! Filled As Default!\n";
(*now)[tname]->default_fill(); //对于该次赋值,如果表中有某些变量没有赋值,则调用default_fill函数用缺省值NULL填充
(*now)[tname]->sort_prime(); //根据主键给各行排序
}
else if (str_com(todo.substr(0,7),"DELETE ")) { //删除行
int p = todo.find(' ',12);
if (p==-1) p = todo.length()-1;
string tname = todo.substr(12,p-12);
if (!(now->find_table(tname))) {
cout << "Table Not Found!\n";
continue;
}
string clause; //截取whereclause
int pp = todo.find(" WHERE ");
if (pp==-1) pp = todo.find(" where ");
if (pp==-1) clause = ""; //若没有whereclause,则设为空,下同
else clause = todo.substr(pp+7,todo.length()-pp-8);
(*now)[tname]->del_row((*now)[tname]->whereClauses(clause)); //调用函数删除行
}
else if (str_com(todo.substr(0,7),"UPDATE ")) { //修改表格信息
int p = todo.find(' ',7);
string tname = todo.substr(7,p-7);
if (!(now->find_table(tname))) {
cout << "Table Not Found!\n";
continue;
}
int q = todo.find('=',p+5);
int s = todo.find(' ',p+5);
if (s==-1) s = todo.length()-1;
string clause;
int pp = todo.find(" WHERE ");
if (pp==-1) pp = todo.find(" where ");
if (pp==-1) clause = "";
else clause = todo.substr(pp+7,todo.length()-pp-8);
string cname = todo.substr(p+5,q-p-5);
string value = todo.substr(q+1,s-q-1);
(*now)[tname]->update_row(cname,value,(*now)[tname]->whereClauses(clause));
}
else{
todo.erase(todo.size()-1);
auto t=cut(todo);int l=t.size();
if (str_com(todo.substr(0,7).c_str(),"ADDTIME") || str_com(todo.substr(0,7).c_str(),"ADDDATE")) {
string s1, s2;
if(t.size() == 2){
s1 = t[0].substr(t[0].find('(') + 1);
s1 = s1.substr(0, s1.length() - 1);
s2 = t[1].substr(0, t[1].find(')'));
} else{
s1 = t[1].substr(0, t[1].length() - 1);
s2 = t[2].substr(0, t[2].find(')'));
}
clear_qua(s1);
if(str_com(todo.substr(0,7).c_str(),"ADDTIME")) cout << addtime(s1, s2) << endl;
else cout << adddate(s1, s2) << endl;
}
else if (Tolower(todo).find("outfile")!=-1){//数据导出
fstream fout;
string filename=t[l-3].substr(1,t[l-3].size()-2);
ifstream check_if_exist(filename);
if(check_if_exist.is_open()){
continue;
}
fout.open(filename,ios::out);
if(now->find_table(t[l-1])){
Table* ptable=now->get_table(t[l-1]);
if(t[1]=="*"){
//cout<<"getin";
for(int i=0;i<ptable->getrowsize();++i){
//cout<<"get";
for(int j=0;j<ptable->getsize();++j){
fout<<(*((*ptable)[j]))[i]<<"\t";
//cout<<"write";
}
fout<<endl;
}
}
else{
vector<string>columnname;
for(int i=1;i<=l-6;++i){
if(i!=l-6){
columnname.push_back(t[i].erase(t[i].size()-1));
}
else{
columnname.push_back(t[i]);
}
}
for(int i=0;i<ptable->getrowsize();++i){
for(int j=0;j<columnname.size();++j){
fout<<(*(*ptable)[columnname[j]])[i]<<"\t";
}
}
}
}
fout.close();
}
else if(Tolower(todo).find("infile")!=-1){//数据导入
string filename;
for(int i=0;i<l;++i){
if(Tolower(t[i])=="infile"){
filename=t[i+1].substr(1,t[i+1].size()-2);
break;
}
}
fstream fin;
fin.open(filename,ios::in);
if(t[l-1].back()!=')'){
string s;
Table* ptable=now->get_table(t[l-1]);
while(getline(fin,s)){
auto u=cut(s);
for(int i=0;i<u.size();++i){
(*ptable)[i]->insert(u[i]);
}
}
}
else{
string tablename="";
int i;int j;
for(i=0;i<l;++i){
if(Tolower(t[i])=="table"){
for(j=0;j<t[i+1].size();++j){
if(t[i+1][j]=='(') break;
tablename+=t[i+1][j];
}
break;
}
}
Table* ptable=now->get_table(tablename);
vector<string>columnname;
columnname.push_back(t[i+1].substr(j+1,t[i+1].size()-j-2));
for(int u=i+2;u<l;++u){
columnname.push_back(t[u].substr(0,t[u].size()-1));
}
string s;
while(getline(fin,s)){
auto u=cut(s);
for(int i=0;i<u.size();++i){
(*ptable)[columnname[i]]->insert(u[i]);
}
ptable->default_fill();
}
ptable->sort_prime();
}
fin.close();
}
else if(find_pos(t,"join",true)!=-1){//实现join功能
int pos_from=find_pos(t,"from");
vector<string>joins,alltable;
vector<vector<string>>needs;
vector<string>temp;
vector<string>nowtables;
for(int i=pos_from+1;i<l;++i){
string x=Tolower(t[i]);
if(x=="inner"||x=="left"||x=="right"){
string u=x+' ';
u+="join";++i;
joins.push_back(u);
needs.push_back(temp);
temp.clear();
}
else if(x=="join"){
string u="inner join";
joins.push_back(u);
needs.push_back(temp);
temp.clear();
}
else{
if(temp.empty()) alltable.push_back(t[i]);
temp.push_back(t[i]);
if(i==l-1) needs.push_back(temp);
}
}
vector<vector<pair<int,bool>>>r;//bool为true表示需要显示,否则为NULL
for(int i=0;i<(*now)[needs[0][0]]->getrowsize();++i){
vector<pair<int,bool>>temp;
temp.push_back(make_pair(i,true));
r.push_back(temp);
}
nowtables.push_back(needs[0][0]);
for(int i=0;i<joins.size();++i){
nowtables.push_back(needs[i+1][0]);
r=now->join_it(r,nowtables,needs[i+1],joins[i]);
}
vector<string>_columnname=get_show_columnname(t);
map<string,int>sub_table;
for(int i=0;i<alltable.size();++i) sub_table[alltable[i]]=i;
vector<vector<string>>result;result.push_back(clear_tablename(_columnname));
for(int i=0;i<r.size();++i){
vector<string>temp;
for(int j=0;j<_columnname.size();++j){
int u=_columnname[j].find(".");
string x=_columnname[j].substr(0,u);
string y=_columnname[j].substr(u+1,_columnname[j].size()-u-1);
int o=sub_table[x];
string str="NULL";
if(r[i][o].second){
str=(*(*(*now)[x])[y])[r[i][o].first];
}
temp.push_back(str);
}
result.push_back(temp);
}
print_result_norows(result);
}
else if(Tolower(todo).find("union")!=-1){//实现union操作符
//先实现UNION连接两个结果集,有需要再改进(已实现连接多个结果集)
//之前组只实现了select之后有一个属性,这里已改进为可以有多个属性(单表)
auto columnname=get_show_columnname(t);
vector<string>selects,unions;int last_pos=0;
int pos_order=find_pos(t,"order");
string ordername="";
vector<vector<vector<string>>>results;
for(int i=0;i<l;++i){
if(Tolower(t[i])=="union"){
selects.push_back(putvector_tostring(t,last_pos,i-1));
if(Tolower(t[i+1])=="all"){
unions.push_back("union all");
last_pos=i+2;++i;
}
else{
unions.push_back("union");
last_pos=i+1;
}
}
else if(Tolower(t[i])=="order"){
selects.push_back(putvector_tostring(t,last_pos,i-1));
ordername=t[i+2];break;
}
if(i==l-1){
selects.push_back(putvector_tostring(t,last_pos,i));
}
}
for(int i=0;i<selects.size();++i){
results.push_back(now->multiple_select(selects[i]));
}
vector<vector<string>>result=results[0];
int pos_start;//在unions中"union"第一次出现的位置
for(pos_start=unions.size()-1;pos_start>=0;pos_start--){
if(unions[pos_start]=="union") break;
}
for(int i=0;i<=pos_start;++i){
result=(*now)[0]->combine(columnname,result,results[i+1],1);
}
for(int i=pos_start+1;i<unions.size();++i){
result=(*now)[0]->combine(columnname,result,results[i+1],0);
}
result.insert(result.begin(),columnname);
auto final_result=result;
if(pos_order!=-1){
final_result=(*now)[0]->orderit(result,ordername);
}
print_result(final_result);
}
else if(Tolower(todo).find("order by")!=-1){//排序语句
Table* ptable;
int i;//i对应from出现的下标
for(i=0;i<t.size();++i){
if(Tolower(t[i])=="from"){
ptable=now->get_table(t[i+1]);
break;
}
}
int pos_group,pos_order;//记录order和group在t中的下标
pos_group=find_pos(t,"group");
pos_order=find_pos(t,"order");
string todo="";
for(int i=0;i<(pos_group==-1?pos_order:pos_group);++i){
if(!i) todo+=t[i];
else{
todo+=' ';todo+=t[i];
}
}
auto need_group=now->multiple_select(todo);
auto columnname=get_show_columnname(t);
need_group.insert(need_group.begin(),columnname);
vector<vector<string>>need_order;
if(pos_group!=-1){
vector<string>group;
for(int i=pos_group+2;i<pos_order;++i){
group.push_back(getvalid_string(t[i]));
}
need_order=ptable->groupit(need_group,group);
}
else{
need_order=need_group;
}
string order=t[pos_order+2];
auto result=ptable->orderit(need_order,order);
print_result(result);
}
else if(Tolower(todo).find("group by")!=-1){//分组语句
Table* ptable=nullptr;
int i;//i对应from出现的下标
for(i=0;i<t.size();++i){
if(Tolower(t[i])=="from"){
ptable=now->get_table(t[i+1]);
break;
}
}
if(ptable==nullptr) continue;
int pos_group=find_pos(t,"group");//记录group在t中的下标
string todo="";
for(int i=0;i<pos_group;++i){
if(!i) todo+=t[i];
else{
todo+=' ';todo+=t[i];
}
}
auto need_group=now->multiple_select(todo);
auto columnname=get_show_columnname(t);
need_group.insert(need_group.begin(),columnname);
vector<string>group;
for(int i=pos_group+2;i<l;++i){
group.push_back(getvalid_string(t[i]));
}
auto result=ptable->groupit(need_group,group);
print_result(result);
}
else if(Tolower(todo).find("count")!=-1 || Tolower(todo).find("sum")!=-1 || Tolower(todo).find("max")!=-1
|| Tolower(todo).find("min")!=-1 || Tolower(todo).find("ave")!=-1 || Tolower(todo).find("var_samp")!=-1){//实现聚合函数
Table* ptable=nullptr;
int i;//i对应from出现的下标
for(i=0;i<t.size();++i){
if(Tolower(t[i])=="from"){
ptable=now->get_table(t[i+1]);
break;
}
}
if(ptable==nullptr) continue;
string todo="";
for(int i=0;i<t.size();++i){
if(!i) todo+=t[i];
else{
todo+=' ';todo+=t[i];
}
}
auto need_group=now->multiple_select(todo);
auto columnname=get_show_columnname(t);
need_group.insert(need_group.begin(),columnname);
vector<string>group;
auto result=ptable->groupit(need_group,group);
print_result(result);
}
else if(Tolower(t[0])=="select"){//查询表格信息,包括单表和多表
int pos_from=0,pos_where=0;
for(int i=0;i<l;++i){
if(Tolower(t[i])=="from") pos_from=i;
if(Tolower(t[i])=="where") {
pos_where=i;break;
}
}
if(pos_where-pos_from>2||(!pos_where&&pos_from<l-2)){//多表
vector<string>tablename;//存储from后面的表名
int pos_from=0,pos_where=0;
for(int i=0;i<l;++i){
if(Tolower(t[i])=="from"){
pos_from=i;
}
if(Tolower(t[i])=="where"){
pos_where=i;
break;
}
}
string condition;
if(pos_where){
for(int i=pos_from+1;i<pos_where;++i){
if(i==pos_where-1){
tablename.push_back(t[i]);
}
else{
tablename.push_back(t[i].substr(0,t[i].size()-1));
}
}
int u=todo.find(" WHERE ");
if(u==-1) u=todo.find(" where ");
condition=todo.substr(u+7,todo.size()-u-7);
}
else{
condition="*";
}
vector<string>columnname;
vector<string>ctablename;//存储输出时每个列对应的表格的名字
map<string,int>table_sub;//存储输出时的表名在v中的vector中的第几个
for(int i=0;i<tablename.size();++i){
table_sub[tablename[i]]=i;
}
for(int i=1;i<pos_from;++i){
int x=t[i].find('.');
ctablename.push_back(t[i].substr(0,x));
if(i==pos_from-1){
columnname.push_back(t[i].substr(x+1,t[i].size()-x-1));
}
else{
columnname.push_back(t[i].substr(x+1,t[i].size()-x-2));
}
}
vector<vector<int>>v=now->where_multiple(tablename,condition);
if(!v.empty()){
for(int i=0;i<columnname.size();++i){
cout<<columnname[i]<<'\t';
}
cout<<endl;
}
for(int i=0;i<v.size();++i){
for(int j=0;j<columnname.size();++j){
int x=table_sub[ctablename[j]];
cout<<(*(*(*now)[ctablename[j]])[columnname[j]])[v[i][x]]<<'\t';
}
cout<<endl;
}
}
else{//单表
vector<string>columnname;
if(t[1]!="*"){
for(int i=1;i<pos_from;++i){
columnname.push_back(getvalid_string(t[i]));
}
}
else{
string tablename=t[pos_from+1];
for(int i=0;i<(*now)[tablename]->getsize();++i){
columnname.push_back((*((*now)[tablename]))[i]->getname());
}
}
auto u=now->multiple_select(todo);
u.insert(u.begin(),columnname);
print_result(u);
}
}
}
fstream fout;
fout.open(data_keep_filename,ios::out|ios::ate);
for(int i=0;i<all_database.size();++i){
database[all_database[i]]->keep_data(data_keep_filename,fout);
}
//fout<<"nowdatabase: "<<now->getname()<<endl;
fout.close();
//将数据储存
}
return 0;
}
You can’t perform that action at this time.
