56 lines
998 B
C++
Executable file
56 lines
998 B
C++
Executable file
#include <fstream>
|
|
#include <iostream>
|
|
#include <vector>
|
|
#include "Relation.h"
|
|
|
|
//still in progress
|
|
class DBEngine {
|
|
vector<Relation> tables;
|
|
int size;
|
|
|
|
public:
|
|
DBEngine(){
|
|
size = 0;
|
|
}
|
|
|
|
void createTable(string n) {
|
|
Relation r(n);
|
|
tables.push_back(r);
|
|
size++;
|
|
}
|
|
|
|
void createTable(string n, vector<Attribute> a) {
|
|
Relation r(n, a);
|
|
tables.push_back(r);
|
|
size++;
|
|
}
|
|
|
|
void createTable(Relation r){
|
|
tables.push_back(r);
|
|
size++;
|
|
}
|
|
|
|
vector<Relation> getRelations(){ return tables; }
|
|
//void showTable(Relation r){}
|
|
|
|
Relation getTableFromName(string n){
|
|
//will return first occurence
|
|
for(int i = 0; i < tables.size(); i++){
|
|
if (tables[i].getTableName() == n){
|
|
return tables[i];
|
|
}
|
|
}
|
|
}
|
|
|
|
void saveToFile(vector<string> cmds){
|
|
//writes nothing meaningful
|
|
ofstream file;
|
|
file.open("savefile.db");
|
|
|
|
for(int i = 0; i < cmds.size(); ++i){
|
|
file << cmds[i] << endl;
|
|
}
|
|
|
|
file.close();
|
|
}
|
|
};
|