Changed SAVE command functionality
This commit is contained in:
parent
b42b05dc38
commit
479a1e3029
4 changed files with 18 additions and 4 deletions
13
DBEngine.cpp
13
DBEngine.cpp
|
@ -51,6 +51,19 @@ void DBEngine::save(){
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DBEngine::save(string n){
|
||||||
|
|
||||||
|
ofstream file;
|
||||||
|
string name = n + ".txt";
|
||||||
|
file.open(name);
|
||||||
|
|
||||||
|
for(int i = 0; i < commands.size(); ++i){
|
||||||
|
file << commands[i] << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
vector<Relation> DBEngine::getRelations(){
|
vector<Relation> DBEngine::getRelations(){
|
||||||
return tables;
|
return tables;
|
||||||
|
|
|
@ -23,8 +23,9 @@ public:
|
||||||
Relation selection(string attName, string s, Relation r);
|
Relation selection(string attName, string s, Relation r);
|
||||||
Relation projection(vector<string> input, Relation r);
|
Relation projection(vector<string> input, Relation r);
|
||||||
Relation product(string s1, Relation r1, Relation r2);
|
Relation product(string s1, Relation r1, Relation r2);
|
||||||
void rename(Relation& r, vector<string> oldnames, vector<string> newnames);
|
void rename(Relation& r, vector<string> oldnames, vector<string> newnames);
|
||||||
void save();
|
void save();
|
||||||
|
void save(string n);
|
||||||
void storeCommands(string s);
|
void storeCommands(string s);
|
||||||
Relation setUnion(Relation r1, Relation r2);
|
Relation setUnion(Relation r1, Relation r2);
|
||||||
//void setDiff();
|
//void setDiff();
|
||||||
|
|
|
@ -66,8 +66,8 @@ vector<string> saveCMD(vector<string> input, DBEngine &engine)
|
||||||
//PRelation pr(input[0]);
|
//PRelation pr(input[0]);
|
||||||
|
|
||||||
// send save command to DBEngine
|
// send save command to DBEngine
|
||||||
//engine.save();
|
engine.save(input[0]);
|
||||||
|
/*
|
||||||
Relation r = engine.getTableFromName(input[0]);
|
Relation r = engine.getTableFromName(input[0]);
|
||||||
ofstream output;
|
ofstream output;
|
||||||
string name = r.getTableName() + ".txt";
|
string name = r.getTableName() + ".txt";
|
||||||
|
@ -96,7 +96,7 @@ vector<string> saveCMD(vector<string> input, DBEngine &engine)
|
||||||
output << "-------------\n";
|
output << "-------------\n";
|
||||||
}
|
}
|
||||||
output << "\n--------------------------";
|
output << "\n--------------------------";
|
||||||
|
*/
|
||||||
input.erase(input.begin());
|
input.erase(input.begin());
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
|
|
BIN
test
BIN
test
Binary file not shown.
Reference in a new issue