This repository has been archived on 2025-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
dmspine64backup/DBEngine.cpp
2015-09-17 18:30:45 -05:00

70 lines
1.3 KiB
C++
Executable file

#include <fstream>
#include <iostream>
#include <vector>
#include "DBEngine.h"
DBEngine::DBEngine(){
size = 0;
}
void DBEngine::createTable(string n){
Relation r(n);
tables.push_back(r);
size++;
}
void DBEngine::createTable(string n, vector<Attribute> a){
Relation r(n, a);
tables.push_back(r);
size++;
}
void DBEngine::createTable(Relation r){
tables.push_back(r);
size++;
}
vector<Relation> DBEngine::getRelations(){
return tables;
}
Relation DBEngine::getTableFromName(string n){
//will return first occurence
for(int i = 0; i < tables.size(); i++){
if (tables[i].getTableName() == n){
return tables[i];
}
}
}
void DBEngine::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();
}
//assumes that all attribute titles are unique
Relation DBEngine::projection(vector<string> input, Relation r){
// for(int i = 0; i < input.size(); i++) {
// it = find(r.getAttributes().begin(), r.getAttributes().end(), input[i])
//if(r[i].getName == input[])
// }
}
/*
void renameAttribute(vector<Attribute> v, string o, string s){
for(int i = 0; i < v.size(); ++i){
if(v[i].getName() == o){
v[i].setName(s);
}
}
}
*/