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.h

57 lines
998 B
C
Raw Normal View History

2015-09-15 16:30:25 -05:00
#include <fstream>
#include <iostream>
#include <vector>
#include "Relation.h"
2015-09-15 23:48:50 -05:00
//still in progress
2015-09-15 21:13:15 -05:00
class DBEngine {
2015-09-15 21:31:19 -05:00
vector<Relation> tables;
2015-09-15 23:48:50 -05:00
int size;
2015-09-15 16:30:25 -05:00
public:
2015-09-15 21:31:19 -05:00
DBEngine(){
size = 0;
}
2015-09-17 17:14:28 -05:00
void createTable(string n) {
Relation r(n);
tables.push_back(r);
size++;
}
2015-09-15 21:31:19 -05:00
void createTable(string n, vector<Attribute> a) {
Relation r(n, a);
tables.push_back(r);
2015-09-17 17:14:28 -05:00
size++;
2015-09-15 21:31:19 -05:00
}
2015-09-15 21:13:15 -05:00
2015-09-17 17:14:28 -05:00
void createTable(Relation r){
tables.push_back(r);
size++;
}
2015-09-15 21:13:15 -05:00
2015-09-17 17:14:28 -05:00
vector<Relation> getRelations(){ return tables; }
//void showTable(Relation r){}
Relation getTableFromName(string n){
2015-09-15 21:58:44 -05:00
//will return first occurence
2015-09-17 17:14:28 -05:00
for(int i = 0; i < tables.size(); i++){
if (tables[i].getTableName() == n){
2015-09-15 21:58:44 -05:00
return tables[i];
2015-09-15 21:42:08 -05:00
}
}
}
2015-09-17 17:14:28 -05:00
void saveToFile(vector<string> cmds){
//writes nothing meaningful
2015-09-15 23:13:28 -05:00
ofstream file;
2015-09-15 23:38:44 -05:00
file.open("savefile.db");
2015-09-15 23:13:28 -05:00
for(int i = 0; i < cmds.size(); ++i){
file << cmds[i] << endl;
}
file.close();
2015-09-17 17:18:51 -05:00
}
2015-09-15 16:30:25 -05:00
};