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
|
@ -52,6 +52,19 @@ void DBEngine::save(){
|
|||
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(){
|
||||
return tables;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ public:
|
|||
Relation product(string s1, Relation r1, Relation r2);
|
||||
void rename(Relation& r, vector<string> oldnames, vector<string> newnames);
|
||||
void save();
|
||||
void save(string n);
|
||||
void storeCommands(string s);
|
||||
Relation setUnion(Relation r1, Relation r2);
|
||||
//void setDiff();
|
||||
|
|
|
@ -66,8 +66,8 @@ vector<string> saveCMD(vector<string> input, DBEngine &engine)
|
|||
//PRelation pr(input[0]);
|
||||
|
||||
// send save command to DBEngine
|
||||
//engine.save();
|
||||
|
||||
engine.save(input[0]);
|
||||
/*
|
||||
Relation r = engine.getTableFromName(input[0]);
|
||||
ofstream output;
|
||||
string name = r.getTableName() + ".txt";
|
||||
|
@ -96,7 +96,7 @@ vector<string> saveCMD(vector<string> input, DBEngine &engine)
|
|||
output << "-------------\n";
|
||||
}
|
||||
output << "\n--------------------------";
|
||||
|
||||
*/
|
||||
input.erase(input.begin());
|
||||
|
||||
return input;
|
||||
|
|
BIN
test
BIN
test
Binary file not shown.
Reference in a new issue